Mikhail Naganov | 521fc49 | 2023-07-11 17:24:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2023 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <vector> |
| 18 | |
| 19 | #define LOG_TAG "AHAL_ModulePrimary" |
| 20 | #include <Utils.h> |
| 21 | #include <android-base/logging.h> |
| 22 | |
| 23 | #include "core-impl/ModulePrimary.h" |
| 24 | #include "core-impl/StreamStub.h" |
| 25 | #include "core-impl/Telephony.h" |
| 26 | |
| 27 | using aidl::android::hardware::audio::common::SinkMetadata; |
| 28 | using aidl::android::hardware::audio::common::SourceMetadata; |
| 29 | using aidl::android::media::audio::common::AudioOffloadInfo; |
| 30 | using aidl::android::media::audio::common::AudioPort; |
| 31 | using aidl::android::media::audio::common::AudioPortConfig; |
| 32 | using aidl::android::media::audio::common::MicrophoneInfo; |
| 33 | |
| 34 | namespace aidl::android::hardware::audio::core { |
| 35 | |
| 36 | ndk::ScopedAStatus ModulePrimary::getTelephony(std::shared_ptr<ITelephony>* _aidl_return) { |
| 37 | if (!mTelephony) { |
| 38 | mTelephony = ndk::SharedRefBase::make<Telephony>(); |
| 39 | } |
| 40 | *_aidl_return = mTelephony.getPtr(); |
| 41 | LOG(DEBUG) << __func__ << ": returning instance of ITelephony: " << _aidl_return->get(); |
| 42 | return ndk::ScopedAStatus::ok(); |
| 43 | } |
| 44 | |
| 45 | ndk::ScopedAStatus ModulePrimary::createInputStream(const SinkMetadata& sinkMetadata, |
| 46 | StreamContext&& context, |
| 47 | const std::vector<MicrophoneInfo>& microphones, |
| 48 | std::shared_ptr<StreamIn>* result) { |
| 49 | return createStreamInstance<StreamInStub>(result, sinkMetadata, std::move(context), |
| 50 | microphones); |
| 51 | } |
| 52 | |
| 53 | ndk::ScopedAStatus ModulePrimary::createOutputStream( |
| 54 | const SourceMetadata& sourceMetadata, StreamContext&& context, |
| 55 | const std::optional<AudioOffloadInfo>& offloadInfo, std::shared_ptr<StreamOut>* result) { |
| 56 | return createStreamInstance<StreamOutStub>(result, sourceMetadata, std::move(context), |
| 57 | offloadInfo); |
| 58 | } |
| 59 | |
| 60 | } // namespace aidl::android::hardware::audio::core |