blob: 6258c938b007a30a58600e51904e930aec60cec6 [file] [log] [blame]
Shraddha Basantwani6bb69632023-04-25 15:26:38 +05301/*
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#define LOG_TAG "AHAL_StreamRemoteSubmix"
18#include <android-base/logging.h>
Mikhail Naganov06085452023-11-27 17:28:51 -080019#include <audio_utils/clock.h>
20#include <error/Result.h>
21#include <error/expected_utils.h>
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053022
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053023#include "core-impl/StreamRemoteSubmix.h"
24
25using aidl::android::hardware::audio::common::SinkMetadata;
26using aidl::android::hardware::audio::common::SourceMetadata;
Shraddha Basantwani2e460342023-07-26 16:12:21 +000027using aidl::android::hardware::audio::core::r_submix::SubmixRoute;
28using aidl::android::media::audio::common::AudioDeviceAddress;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053029using aidl::android::media::audio::common::AudioOffloadInfo;
30using aidl::android::media::audio::common::MicrophoneDynamicInfo;
31using aidl::android::media::audio::common::MicrophoneInfo;
32
33namespace aidl::android::hardware::audio::core {
34
Shraddha Basantwani2e460342023-07-26 16:12:21 +000035StreamRemoteSubmix::StreamRemoteSubmix(StreamContext* context, const Metadata& metadata,
36 const AudioDeviceAddress& deviceAddress)
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -070037 : StreamCommonImpl(context, metadata),
Shraddha Basantwani2e460342023-07-26 16:12:21 +000038 mDeviceAddress(deviceAddress),
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053039 mIsInput(isInput(metadata)) {
Mikhail Naganov1eedc132023-07-21 17:45:28 -070040 mStreamConfig.frameSize = context->getFrameSize();
41 mStreamConfig.format = context->getFormat();
42 mStreamConfig.channelLayout = context->getChannelLayout();
43 mStreamConfig.sampleRate = context->getSampleRate();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053044}
45
46std::mutex StreamRemoteSubmix::sSubmixRoutesLock;
Shraddha Basantwani2e460342023-07-26 16:12:21 +000047std::map<AudioDeviceAddress, std::shared_ptr<SubmixRoute>> StreamRemoteSubmix::sSubmixRoutes;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053048
49::android::status_t StreamRemoteSubmix::init() {
50 {
51 std::lock_guard guard(sSubmixRoutesLock);
Shraddha Basantwani2e460342023-07-26 16:12:21 +000052 auto routeItr = sSubmixRoutes.find(mDeviceAddress);
53 if (routeItr != sSubmixRoutes.end()) {
54 mCurrentRoute = routeItr->second;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053055 }
Mikhail Naganov06085452023-11-27 17:28:51 -080056 // If route is not available for this port, add it.
57 if (mCurrentRoute == nullptr) {
58 // Initialize the pipe.
59 mCurrentRoute = std::make_shared<SubmixRoute>();
60 if (::android::OK != mCurrentRoute->createPipe(mStreamConfig)) {
61 LOG(ERROR) << __func__ << ": create pipe failed";
Mikhail Naganov49712b52023-06-27 16:39:33 -070062 return ::android::NO_INIT;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053063 }
Mikhail Naganov06085452023-11-27 17:28:51 -080064 sSubmixRoutes.emplace(mDeviceAddress, mCurrentRoute);
65 }
66 }
67 if (!mCurrentRoute->isStreamConfigValid(mIsInput, mStreamConfig)) {
68 LOG(ERROR) << __func__ << ": invalid stream config";
69 return ::android::NO_INIT;
70 }
71 sp<MonoPipe> sink = mCurrentRoute->getSink();
72 if (sink == nullptr) {
73 LOG(ERROR) << __func__ << ": nullptr sink when opening stream";
74 return ::android::NO_INIT;
75 }
76 // If the sink has been shutdown or pipe recreation is forced, delete the pipe and
77 // recreate it.
78 if (sink->isShutdown()) {
79 LOG(DEBUG) << __func__ << ": Non-nullptr shut down sink when opening stream";
80 if (::android::OK != mCurrentRoute->resetPipe()) {
81 LOG(ERROR) << __func__ << ": reset pipe failed";
82 return ::android::NO_INIT;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053083 }
84 }
85
86 mCurrentRoute->openStream(mIsInput);
Mikhail Naganov49712b52023-06-27 16:39:33 -070087 return ::android::OK;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053088}
89
90::android::status_t StreamRemoteSubmix::drain(StreamDescriptor::DrainMode) {
91 usleep(1000);
92 return ::android::OK;
93}
94
95::android::status_t StreamRemoteSubmix::flush() {
96 usleep(1000);
97 return ::android::OK;
98}
99
100::android::status_t StreamRemoteSubmix::pause() {
101 usleep(1000);
102 return ::android::OK;
103}
104
Mikhail Naganov49712b52023-06-27 16:39:33 -0700105::android::status_t StreamRemoteSubmix::standby() {
106 mCurrentRoute->standby(mIsInput);
107 return ::android::OK;
108}
109
110::android::status_t StreamRemoteSubmix::start() {
111 mCurrentRoute->exitStandby(mIsInput);
Mikhail Naganov06085452023-11-27 17:28:51 -0800112 mStartTimeNs = ::android::uptimeNanos();
113 mFramesSinceStart = 0;
Mikhail Naganov49712b52023-06-27 16:39:33 -0700114 return ::android::OK;
115}
116
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530117ndk::ScopedAStatus StreamRemoteSubmix::prepareToClose() {
118 if (!mIsInput) {
119 std::shared_ptr<SubmixRoute> route = nullptr;
120 {
121 std::lock_guard guard(sSubmixRoutesLock);
Shraddha Basantwani2e460342023-07-26 16:12:21 +0000122 auto routeItr = sSubmixRoutes.find(mDeviceAddress);
123 if (routeItr != sSubmixRoutes.end()) {
124 route = routeItr->second;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530125 }
126 }
127 if (route != nullptr) {
128 sp<MonoPipe> sink = route->getSink();
129 if (sink == nullptr) {
130 ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
131 }
132 LOG(DEBUG) << __func__ << ": shutting down MonoPipe sink";
133
134 sink->shutdown(true);
Mikhail Naganov2ebe3902023-11-07 16:43:26 -0800135 // The client already considers this stream as closed, release the output end.
136 route->closeStream(mIsInput);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530137 } else {
138 LOG(DEBUG) << __func__ << ": stream already closed.";
139 ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
140 }
141 }
142 return ndk::ScopedAStatus::ok();
143}
144
145// Remove references to the specified input and output streams. When the device no longer
146// references input and output streams destroy the associated pipe.
147void StreamRemoteSubmix::shutdown() {
148 mCurrentRoute->closeStream(mIsInput);
149 // If all stream instances are closed, we can remove route information for this port.
150 if (!mCurrentRoute->hasAtleastOneStreamOpen()) {
151 mCurrentRoute->releasePipe();
152 LOG(DEBUG) << __func__ << ": pipe destroyed";
153
154 std::lock_guard guard(sSubmixRoutesLock);
Shraddha Basantwani2e460342023-07-26 16:12:21 +0000155 sSubmixRoutes.erase(mDeviceAddress);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530156 }
Mikhail Naganov49712b52023-06-27 16:39:33 -0700157 mCurrentRoute.reset();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530158}
159
160::android::status_t StreamRemoteSubmix::transfer(void* buffer, size_t frameCount,
161 size_t* actualFrameCount, int32_t* latencyMs) {
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700162 *latencyMs = getDelayInUsForFrameCount(getStreamPipeSizeInFrames()) / 1000;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530163 LOG(VERBOSE) << __func__ << ": Latency " << *latencyMs << "ms";
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000164 mCurrentRoute->exitStandby(mIsInput);
Mikhail Naganov06085452023-11-27 17:28:51 -0800165 RETURN_STATUS_IF_ERROR(mIsInput ? inRead(buffer, frameCount, actualFrameCount)
166 : outWrite(buffer, frameCount, actualFrameCount));
167 const long bufferDurationUs =
168 (*actualFrameCount) * MICROS_PER_SECOND / mContext.getSampleRate();
169 const long totalDurationUs = (::android::uptimeNanos() - mStartTimeNs) / NANOS_PER_MICROSECOND;
170 mFramesSinceStart += *actualFrameCount;
171 const long totalOffsetUs =
172 mFramesSinceStart * MICROS_PER_SECOND / mContext.getSampleRate() - totalDurationUs;
173 LOG(VERBOSE) << __func__ << ": totalOffsetUs " << totalOffsetUs;
174 if (totalOffsetUs > 0) {
175 const long sleepTimeUs = std::min(totalOffsetUs, bufferDurationUs);
176 LOG(VERBOSE) << __func__ << ": sleeping for " << sleepTimeUs << " us";
177 usleep(sleepTimeUs);
178 }
179 return ::android::OK;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530180}
181
Mikhail Naganov459b7332023-08-03 10:26:21 -0700182::android::status_t StreamRemoteSubmix::refinePosition(StreamDescriptor::Position* position) {
Mikhail Naganov704aec42023-07-13 11:08:29 -0700183 sp<MonoPipeReader> source = mCurrentRoute->getSource();
184 if (source == nullptr) {
185 return ::android::NO_INIT;
186 }
187 const ssize_t framesInPipe = source->availableToRead();
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000188 if (framesInPipe <= 0) {
189 // No need to update the position frames
190 return ::android::OK;
Mikhail Naganov704aec42023-07-13 11:08:29 -0700191 }
192 if (mIsInput) {
193 position->frames += framesInPipe;
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000194 } else if (position->frames >= framesInPipe) {
195 position->frames -= framesInPipe;
Mikhail Naganov704aec42023-07-13 11:08:29 -0700196 }
197 return ::android::OK;
198}
199
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700200long StreamRemoteSubmix::getDelayInUsForFrameCount(size_t frameCount) {
201 return frameCount * MICROS_PER_SECOND / mStreamConfig.sampleRate;
202}
203
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530204// Calculate the maximum size of the pipe buffer in frames for the specified stream.
205size_t StreamRemoteSubmix::getStreamPipeSizeInFrames() {
206 auto pipeConfig = mCurrentRoute->mPipeConfig;
207 const size_t maxFrameSize = std::max(mStreamConfig.frameSize, pipeConfig.frameSize);
208 return (pipeConfig.frameCount * pipeConfig.frameSize) / maxFrameSize;
209}
210
211::android::status_t StreamRemoteSubmix::outWrite(void* buffer, size_t frameCount,
212 size_t* actualFrameCount) {
213 sp<MonoPipe> sink = mCurrentRoute->getSink();
214 if (sink != nullptr) {
215 if (sink->isShutdown()) {
216 sink.clear();
Mikhail Naganov06085452023-11-27 17:28:51 -0800217 LOG(DEBUG) << __func__ << ": pipe shutdown, ignoring the write";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530218 *actualFrameCount = frameCount;
219 return ::android::OK;
220 }
221 } else {
222 LOG(FATAL) << __func__ << ": without a pipe!";
223 return ::android::UNKNOWN_ERROR;
224 }
225
Mikhail Naganov06085452023-11-27 17:28:51 -0800226 LOG(VERBOSE) << __func__ << ": " << mDeviceAddress.toString() << ", " << frameCount
227 << " frames";
228
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700229 const bool shouldBlockWrite = mCurrentRoute->shouldBlockWrite();
230 size_t availableToWrite = sink->availableToWrite();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530231 // NOTE: sink has been checked above and sink and source life cycles are synchronized
232 sp<MonoPipeReader> source = mCurrentRoute->getSource();
233 // If the write to the sink should be blocked, flush enough frames from the pipe to make space
234 // to write the most recent data.
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700235 if (!shouldBlockWrite && availableToWrite < frameCount) {
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530236 static uint8_t flushBuffer[64];
237 const size_t flushBufferSizeFrames = sizeof(flushBuffer) / mStreamConfig.frameSize;
238 size_t framesToFlushFromSource = frameCount - availableToWrite;
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700239 LOG(DEBUG) << __func__ << ": flushing " << framesToFlushFromSource
240 << " frames from the pipe to avoid blocking";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530241 while (framesToFlushFromSource) {
242 const size_t flushSize = std::min(framesToFlushFromSource, flushBufferSizeFrames);
243 framesToFlushFromSource -= flushSize;
244 // read does not block
245 source->read(flushBuffer, flushSize);
246 }
247 }
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700248 availableToWrite = sink->availableToWrite();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530249
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700250 if (!shouldBlockWrite && frameCount > availableToWrite) {
Mikhail Naganov06085452023-11-27 17:28:51 -0800251 LOG(WARNING) << __func__ << ": writing " << availableToWrite << " vs. requested "
252 << frameCount;
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700253 // Truncate the request to avoid blocking.
254 frameCount = availableToWrite;
255 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530256 ssize_t writtenFrames = sink->write(buffer, frameCount);
257 if (writtenFrames < 0) {
258 if (writtenFrames == (ssize_t)::android::NEGOTIATE) {
259 LOG(ERROR) << __func__ << ": write to pipe returned NEGOTIATE";
260 sink.clear();
261 *actualFrameCount = 0;
262 return ::android::UNKNOWN_ERROR;
263 } else {
264 // write() returned UNDERRUN or WOULD_BLOCK, retry
265 LOG(ERROR) << __func__ << ": write to pipe returned unexpected " << writtenFrames;
266 writtenFrames = sink->write(buffer, frameCount);
267 }
268 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530269
270 if (writtenFrames < 0) {
271 LOG(ERROR) << __func__ << ": failed writing to pipe with " << writtenFrames;
272 *actualFrameCount = 0;
273 return ::android::UNKNOWN_ERROR;
274 }
Mikhail Naganov06085452023-11-27 17:28:51 -0800275 if (writtenFrames > 0 && frameCount > (size_t)writtenFrames) {
276 LOG(WARNING) << __func__ << ": wrote " << writtenFrames << " vs. requested " << frameCount;
277 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530278 *actualFrameCount = writtenFrames;
279 return ::android::OK;
280}
281
282::android::status_t StreamRemoteSubmix::inRead(void* buffer, size_t frameCount,
283 size_t* actualFrameCount) {
Mikhail Naganov06085452023-11-27 17:28:51 -0800284 // in any case, it is emulated that data for the entire buffer was available
285 memset(buffer, 0, mStreamConfig.frameSize * frameCount);
286 *actualFrameCount = frameCount;
287
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530288 // about to read from audio source
289 sp<MonoPipeReader> source = mCurrentRoute->getSource();
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000290 if (source == nullptr) {
Mikhail Naganov06085452023-11-27 17:28:51 -0800291 if (++mReadErrorCount < kMaxReadErrorLogs) {
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000292 LOG(ERROR) << __func__
293 << ": no audio pipe yet we're trying to read! (not all errors will be "
294 "logged)";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530295 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530296 return ::android::OK;
297 }
298
Mikhail Naganov06085452023-11-27 17:28:51 -0800299 LOG(VERBOSE) << __func__ << ": " << mDeviceAddress.toString() << ", " << frameCount
300 << " frames";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530301 // read the data from the pipe
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530302 char* buff = (char*)buffer;
Mikhail Naganov06085452023-11-27 17:28:51 -0800303 size_t actuallyRead = 0;
304 long remainingFrames = frameCount;
305 const long deadlineTimeNs = ::android::uptimeNanos() +
306 getDelayInUsForFrameCount(frameCount) * NANOS_PER_MICROSECOND;
307 while (remainingFrames > 0) {
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530308 ssize_t framesRead = source->read(buff, remainingFrames);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530309 LOG(VERBOSE) << __func__ << ": frames read " << framesRead;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530310 if (framesRead > 0) {
311 remainingFrames -= framesRead;
312 buff += framesRead * mStreamConfig.frameSize;
Mikhail Naganov06085452023-11-27 17:28:51 -0800313 LOG(VERBOSE) << __func__ << ": got " << framesRead
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700314 << " frames, remaining =" << remainingFrames;
Mikhail Naganov06085452023-11-27 17:28:51 -0800315 actuallyRead += framesRead;
316 }
317 if (::android::uptimeNanos() >= deadlineTimeNs) break;
318 if (framesRead <= 0) {
319 LOG(VERBOSE) << __func__ << ": read returned " << framesRead
320 << ", read failure, sleeping for " << kReadAttemptSleepUs << " us";
321 usleep(kReadAttemptSleepUs);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530322 }
323 }
Mikhail Naganov06085452023-11-27 17:28:51 -0800324 if (actuallyRead < frameCount) {
325 LOG(WARNING) << __func__ << ": read " << actuallyRead << " vs. requested " << frameCount;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530326 }
Mikhail Naganov06085452023-11-27 17:28:51 -0800327 mCurrentRoute->updateReadCounterFrames(*actualFrameCount);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530328 return ::android::OK;
329}
330
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -0700331StreamInRemoteSubmix::StreamInRemoteSubmix(StreamContext&& context,
332 const SinkMetadata& sinkMetadata,
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530333 const std::vector<MicrophoneInfo>& microphones)
Mikhail Naganov459b7332023-08-03 10:26:21 -0700334 : StreamIn(std::move(context), microphones), StreamSwitcher(&mContextInstance, sinkMetadata) {}
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530335
336ndk::ScopedAStatus StreamInRemoteSubmix::getActiveMicrophones(
337 std::vector<MicrophoneDynamicInfo>* _aidl_return) {
338 LOG(DEBUG) << __func__ << ": not supported";
339 *_aidl_return = std::vector<MicrophoneDynamicInfo>();
340 return ndk::ScopedAStatus::ok();
341}
342
Shraddha Basantwani2e460342023-07-26 16:12:21 +0000343StreamSwitcher::DeviceSwitchBehavior StreamInRemoteSubmix::switchCurrentStream(
344 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) {
345 // This implementation effectively postpones stream creation until
346 // receiving the first call to 'setConnectedDevices' with a non-empty list.
347 if (isStubStream()) {
348 if (devices.size() == 1) {
349 auto deviceDesc = devices.front().type;
350 if (deviceDesc.type ==
351 ::aidl::android::media::audio::common::AudioDeviceType::IN_SUBMIX) {
352 return DeviceSwitchBehavior::CREATE_NEW_STREAM;
353 }
354 LOG(ERROR) << __func__ << ": Device type " << toString(deviceDesc.type)
355 << " not supported";
356 } else {
357 LOG(ERROR) << __func__ << ": Only single device supported.";
358 }
359 return DeviceSwitchBehavior::UNSUPPORTED_DEVICES;
360 }
361 return DeviceSwitchBehavior::USE_CURRENT_STREAM;
362}
363
364std::unique_ptr<StreamCommonInterfaceEx> StreamInRemoteSubmix::createNewStream(
365 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices,
366 StreamContext* context, const Metadata& metadata) {
367 return std::unique_ptr<StreamCommonInterfaceEx>(
368 new InnerStreamWrapper<StreamRemoteSubmix>(context, metadata, devices.front().address));
369}
370
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -0700371StreamOutRemoteSubmix::StreamOutRemoteSubmix(StreamContext&& context,
372 const SourceMetadata& sourceMetadata,
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530373 const std::optional<AudioOffloadInfo>& offloadInfo)
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -0700374 : StreamOut(std::move(context), offloadInfo),
Mikhail Naganov459b7332023-08-03 10:26:21 -0700375 StreamSwitcher(&mContextInstance, sourceMetadata) {}
Shraddha Basantwani2e460342023-07-26 16:12:21 +0000376
377StreamSwitcher::DeviceSwitchBehavior StreamOutRemoteSubmix::switchCurrentStream(
378 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) {
379 // This implementation effectively postpones stream creation until
380 // receiving the first call to 'setConnectedDevices' with a non-empty list.
381 if (isStubStream()) {
382 if (devices.size() == 1) {
383 auto deviceDesc = devices.front().type;
384 if (deviceDesc.type ==
385 ::aidl::android::media::audio::common::AudioDeviceType::OUT_SUBMIX) {
386 return DeviceSwitchBehavior::CREATE_NEW_STREAM;
387 }
388 LOG(ERROR) << __func__ << ": Device type " << toString(deviceDesc.type)
389 << " not supported";
390 } else {
391 LOG(ERROR) << __func__ << ": Only single device supported.";
392 }
393 return DeviceSwitchBehavior::UNSUPPORTED_DEVICES;
394 }
395 return DeviceSwitchBehavior::USE_CURRENT_STREAM;
396}
397
398std::unique_ptr<StreamCommonInterfaceEx> StreamOutRemoteSubmix::createNewStream(
399 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices,
400 StreamContext* context, const Metadata& metadata) {
401 return std::unique_ptr<StreamCommonInterfaceEx>(
402 new InnerStreamWrapper<StreamRemoteSubmix>(context, metadata, devices.front().address));
403}
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530404
405} // namespace aidl::android::hardware::audio::core