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(); |
Mikhail Naganov | 2eabaf9 | 2023-07-19 14:28:47 -0700 | [diff] [blame] | 41 | LOG(DEBUG) << __func__ |
| 42 | << ": returning instance of ITelephony: " << _aidl_return->get()->asBinder().get(); |
Mikhail Naganov | 521fc49 | 2023-07-11 17:24:08 -0700 | [diff] [blame] | 43 | return ndk::ScopedAStatus::ok(); |
| 44 | } |
| 45 | |
Mikhail Naganov | 6ddefdb | 2023-07-19 17:30:06 -0700 | [diff] [blame] | 46 | ndk::ScopedAStatus ModulePrimary::createInputStream(StreamContext&& context, |
| 47 | const SinkMetadata& sinkMetadata, |
Mikhail Naganov | 521fc49 | 2023-07-11 17:24:08 -0700 | [diff] [blame] | 48 | const std::vector<MicrophoneInfo>& microphones, |
| 49 | std::shared_ptr<StreamIn>* result) { |
Mikhail Naganov | 6ddefdb | 2023-07-19 17:30:06 -0700 | [diff] [blame] | 50 | return createStreamInstance<StreamInStub>(result, std::move(context), sinkMetadata, |
Mikhail Naganov | 521fc49 | 2023-07-11 17:24:08 -0700 | [diff] [blame] | 51 | microphones); |
| 52 | } |
| 53 | |
| 54 | ndk::ScopedAStatus ModulePrimary::createOutputStream( |
Mikhail Naganov | 6ddefdb | 2023-07-19 17:30:06 -0700 | [diff] [blame] | 55 | StreamContext&& context, const SourceMetadata& sourceMetadata, |
Mikhail Naganov | 521fc49 | 2023-07-11 17:24:08 -0700 | [diff] [blame] | 56 | const std::optional<AudioOffloadInfo>& offloadInfo, std::shared_ptr<StreamOut>* result) { |
Mikhail Naganov | 6ddefdb | 2023-07-19 17:30:06 -0700 | [diff] [blame] | 57 | return createStreamInstance<StreamOutStub>(result, std::move(context), sourceMetadata, |
Mikhail Naganov | 521fc49 | 2023-07-11 17:24:08 -0700 | [diff] [blame] | 58 | offloadInfo); |
| 59 | } |
| 60 | |
| 61 | } // namespace aidl::android::hardware::audio::core |