blob: 29e81264acbd0f44ec44365c79ce1125649d6d58 [file] [log] [blame]
Mikhail Naganov521fc492023-07-11 17:24:08 -07001/*
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
27using aidl::android::hardware::audio::common::SinkMetadata;
28using aidl::android::hardware::audio::common::SourceMetadata;
29using aidl::android::media::audio::common::AudioOffloadInfo;
30using aidl::android::media::audio::common::AudioPort;
31using aidl::android::media::audio::common::AudioPortConfig;
32using aidl::android::media::audio::common::MicrophoneInfo;
33
34namespace aidl::android::hardware::audio::core {
35
36ndk::ScopedAStatus ModulePrimary::getTelephony(std::shared_ptr<ITelephony>* _aidl_return) {
37 if (!mTelephony) {
38 mTelephony = ndk::SharedRefBase::make<Telephony>();
39 }
Mikhail Naganov780fefb2023-07-21 17:01:38 -070040 *_aidl_return = mTelephony.getInstance();
Mikhail Naganov2eabaf92023-07-19 14:28:47 -070041 LOG(DEBUG) << __func__
42 << ": returning instance of ITelephony: " << _aidl_return->get()->asBinder().get();
Mikhail Naganov521fc492023-07-11 17:24:08 -070043 return ndk::ScopedAStatus::ok();
44}
45
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -070046ndk::ScopedAStatus ModulePrimary::createInputStream(StreamContext&& context,
47 const SinkMetadata& sinkMetadata,
Mikhail Naganov521fc492023-07-11 17:24:08 -070048 const std::vector<MicrophoneInfo>& microphones,
49 std::shared_ptr<StreamIn>* result) {
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -070050 return createStreamInstance<StreamInStub>(result, std::move(context), sinkMetadata,
Mikhail Naganov521fc492023-07-11 17:24:08 -070051 microphones);
52}
53
54ndk::ScopedAStatus ModulePrimary::createOutputStream(
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -070055 StreamContext&& context, const SourceMetadata& sourceMetadata,
Mikhail Naganov521fc492023-07-11 17:24:08 -070056 const std::optional<AudioOffloadInfo>& offloadInfo, std::shared_ptr<StreamOut>* result) {
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -070057 return createStreamInstance<StreamOutStub>(result, std::move(context), sourceMetadata,
Mikhail Naganov521fc492023-07-11 17:24:08 -070058 offloadInfo);
59}
60
61} // namespace aidl::android::hardware::audio::core