blob: d238aa42b30dd799ba03ab64eb02eed25cf9976d [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 }
Mikhail Naganov7b234d42023-12-05 11:28:56 -080076 if ((!mIsInput || mCurrentRoute->isStreamInOpen()) && sink->isShutdown()) {
77 LOG(DEBUG) << __func__ << ": Shut down sink when opening stream";
Mikhail Naganov06085452023-11-27 17:28:51 -080078 if (::android::OK != mCurrentRoute->resetPipe()) {
79 LOG(ERROR) << __func__ << ": reset pipe failed";
80 return ::android::NO_INIT;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053081 }
82 }
83
84 mCurrentRoute->openStream(mIsInput);
Mikhail Naganov49712b52023-06-27 16:39:33 -070085 return ::android::OK;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053086}
87
88::android::status_t StreamRemoteSubmix::drain(StreamDescriptor::DrainMode) {
89 usleep(1000);
90 return ::android::OK;
91}
92
93::android::status_t StreamRemoteSubmix::flush() {
94 usleep(1000);
95 return ::android::OK;
96}
97
98::android::status_t StreamRemoteSubmix::pause() {
99 usleep(1000);
100 return ::android::OK;
101}
102
Mikhail Naganov49712b52023-06-27 16:39:33 -0700103::android::status_t StreamRemoteSubmix::standby() {
104 mCurrentRoute->standby(mIsInput);
105 return ::android::OK;
106}
107
108::android::status_t StreamRemoteSubmix::start() {
109 mCurrentRoute->exitStandby(mIsInput);
Mikhail Naganov06085452023-11-27 17:28:51 -0800110 mStartTimeNs = ::android::uptimeNanos();
111 mFramesSinceStart = 0;
Mikhail Naganov49712b52023-06-27 16:39:33 -0700112 return ::android::OK;
113}
114
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530115ndk::ScopedAStatus StreamRemoteSubmix::prepareToClose() {
116 if (!mIsInput) {
117 std::shared_ptr<SubmixRoute> route = nullptr;
118 {
119 std::lock_guard guard(sSubmixRoutesLock);
Shraddha Basantwani2e460342023-07-26 16:12:21 +0000120 auto routeItr = sSubmixRoutes.find(mDeviceAddress);
121 if (routeItr != sSubmixRoutes.end()) {
122 route = routeItr->second;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530123 }
124 }
125 if (route != nullptr) {
126 sp<MonoPipe> sink = route->getSink();
127 if (sink == nullptr) {
128 ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
129 }
130 LOG(DEBUG) << __func__ << ": shutting down MonoPipe sink";
131
132 sink->shutdown(true);
Mikhail Naganov2ebe3902023-11-07 16:43:26 -0800133 // The client already considers this stream as closed, release the output end.
134 route->closeStream(mIsInput);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530135 } else {
136 LOG(DEBUG) << __func__ << ": stream already closed.";
137 ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
138 }
139 }
140 return ndk::ScopedAStatus::ok();
141}
142
143// Remove references to the specified input and output streams. When the device no longer
144// references input and output streams destroy the associated pipe.
145void StreamRemoteSubmix::shutdown() {
146 mCurrentRoute->closeStream(mIsInput);
147 // If all stream instances are closed, we can remove route information for this port.
148 if (!mCurrentRoute->hasAtleastOneStreamOpen()) {
149 mCurrentRoute->releasePipe();
150 LOG(DEBUG) << __func__ << ": pipe destroyed";
151
152 std::lock_guard guard(sSubmixRoutesLock);
Shraddha Basantwani2e460342023-07-26 16:12:21 +0000153 sSubmixRoutes.erase(mDeviceAddress);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530154 }
Mikhail Naganov49712b52023-06-27 16:39:33 -0700155 mCurrentRoute.reset();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530156}
157
158::android::status_t StreamRemoteSubmix::transfer(void* buffer, size_t frameCount,
159 size_t* actualFrameCount, int32_t* latencyMs) {
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700160 *latencyMs = getDelayInUsForFrameCount(getStreamPipeSizeInFrames()) / 1000;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530161 LOG(VERBOSE) << __func__ << ": Latency " << *latencyMs << "ms";
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000162 mCurrentRoute->exitStandby(mIsInput);
Mikhail Naganov06085452023-11-27 17:28:51 -0800163 RETURN_STATUS_IF_ERROR(mIsInput ? inRead(buffer, frameCount, actualFrameCount)
164 : outWrite(buffer, frameCount, actualFrameCount));
165 const long bufferDurationUs =
166 (*actualFrameCount) * MICROS_PER_SECOND / mContext.getSampleRate();
167 const long totalDurationUs = (::android::uptimeNanos() - mStartTimeNs) / NANOS_PER_MICROSECOND;
168 mFramesSinceStart += *actualFrameCount;
169 const long totalOffsetUs =
170 mFramesSinceStart * MICROS_PER_SECOND / mContext.getSampleRate() - totalDurationUs;
171 LOG(VERBOSE) << __func__ << ": totalOffsetUs " << totalOffsetUs;
172 if (totalOffsetUs > 0) {
173 const long sleepTimeUs = std::min(totalOffsetUs, bufferDurationUs);
174 LOG(VERBOSE) << __func__ << ": sleeping for " << sleepTimeUs << " us";
175 usleep(sleepTimeUs);
176 }
177 return ::android::OK;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530178}
179
Mikhail Naganov459b7332023-08-03 10:26:21 -0700180::android::status_t StreamRemoteSubmix::refinePosition(StreamDescriptor::Position* position) {
Mikhail Naganov704aec42023-07-13 11:08:29 -0700181 sp<MonoPipeReader> source = mCurrentRoute->getSource();
182 if (source == nullptr) {
183 return ::android::NO_INIT;
184 }
185 const ssize_t framesInPipe = source->availableToRead();
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000186 if (framesInPipe <= 0) {
187 // No need to update the position frames
188 return ::android::OK;
Mikhail Naganov704aec42023-07-13 11:08:29 -0700189 }
190 if (mIsInput) {
191 position->frames += framesInPipe;
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000192 } else if (position->frames >= framesInPipe) {
193 position->frames -= framesInPipe;
Mikhail Naganov704aec42023-07-13 11:08:29 -0700194 }
195 return ::android::OK;
196}
197
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700198long StreamRemoteSubmix::getDelayInUsForFrameCount(size_t frameCount) {
199 return frameCount * MICROS_PER_SECOND / mStreamConfig.sampleRate;
200}
201
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530202// Calculate the maximum size of the pipe buffer in frames for the specified stream.
203size_t StreamRemoteSubmix::getStreamPipeSizeInFrames() {
204 auto pipeConfig = mCurrentRoute->mPipeConfig;
205 const size_t maxFrameSize = std::max(mStreamConfig.frameSize, pipeConfig.frameSize);
206 return (pipeConfig.frameCount * pipeConfig.frameSize) / maxFrameSize;
207}
208
209::android::status_t StreamRemoteSubmix::outWrite(void* buffer, size_t frameCount,
210 size_t* actualFrameCount) {
211 sp<MonoPipe> sink = mCurrentRoute->getSink();
212 if (sink != nullptr) {
213 if (sink->isShutdown()) {
214 sink.clear();
Mikhail Naganov06085452023-11-27 17:28:51 -0800215 LOG(DEBUG) << __func__ << ": pipe shutdown, ignoring the write";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530216 *actualFrameCount = frameCount;
217 return ::android::OK;
218 }
219 } else {
220 LOG(FATAL) << __func__ << ": without a pipe!";
221 return ::android::UNKNOWN_ERROR;
222 }
223
Mikhail Naganov06085452023-11-27 17:28:51 -0800224 LOG(VERBOSE) << __func__ << ": " << mDeviceAddress.toString() << ", " << frameCount
225 << " frames";
226
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700227 const bool shouldBlockWrite = mCurrentRoute->shouldBlockWrite();
228 size_t availableToWrite = sink->availableToWrite();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530229 // NOTE: sink has been checked above and sink and source life cycles are synchronized
230 sp<MonoPipeReader> source = mCurrentRoute->getSource();
231 // If the write to the sink should be blocked, flush enough frames from the pipe to make space
232 // to write the most recent data.
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700233 if (!shouldBlockWrite && availableToWrite < frameCount) {
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530234 static uint8_t flushBuffer[64];
235 const size_t flushBufferSizeFrames = sizeof(flushBuffer) / mStreamConfig.frameSize;
236 size_t framesToFlushFromSource = frameCount - availableToWrite;
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700237 LOG(DEBUG) << __func__ << ": flushing " << framesToFlushFromSource
238 << " frames from the pipe to avoid blocking";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530239 while (framesToFlushFromSource) {
240 const size_t flushSize = std::min(framesToFlushFromSource, flushBufferSizeFrames);
241 framesToFlushFromSource -= flushSize;
242 // read does not block
243 source->read(flushBuffer, flushSize);
244 }
245 }
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700246 availableToWrite = sink->availableToWrite();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530247
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700248 if (!shouldBlockWrite && frameCount > availableToWrite) {
Mikhail Naganov06085452023-11-27 17:28:51 -0800249 LOG(WARNING) << __func__ << ": writing " << availableToWrite << " vs. requested "
250 << frameCount;
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700251 // Truncate the request to avoid blocking.
252 frameCount = availableToWrite;
253 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530254 ssize_t writtenFrames = sink->write(buffer, frameCount);
255 if (writtenFrames < 0) {
256 if (writtenFrames == (ssize_t)::android::NEGOTIATE) {
257 LOG(ERROR) << __func__ << ": write to pipe returned NEGOTIATE";
258 sink.clear();
259 *actualFrameCount = 0;
260 return ::android::UNKNOWN_ERROR;
261 } else {
262 // write() returned UNDERRUN or WOULD_BLOCK, retry
263 LOG(ERROR) << __func__ << ": write to pipe returned unexpected " << writtenFrames;
264 writtenFrames = sink->write(buffer, frameCount);
265 }
266 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530267
268 if (writtenFrames < 0) {
269 LOG(ERROR) << __func__ << ": failed writing to pipe with " << writtenFrames;
270 *actualFrameCount = 0;
271 return ::android::UNKNOWN_ERROR;
272 }
Mikhail Naganov06085452023-11-27 17:28:51 -0800273 if (writtenFrames > 0 && frameCount > (size_t)writtenFrames) {
274 LOG(WARNING) << __func__ << ": wrote " << writtenFrames << " vs. requested " << frameCount;
275 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530276 *actualFrameCount = writtenFrames;
277 return ::android::OK;
278}
279
280::android::status_t StreamRemoteSubmix::inRead(void* buffer, size_t frameCount,
281 size_t* actualFrameCount) {
Mikhail Naganov06085452023-11-27 17:28:51 -0800282 // in any case, it is emulated that data for the entire buffer was available
283 memset(buffer, 0, mStreamConfig.frameSize * frameCount);
284 *actualFrameCount = frameCount;
285
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530286 // about to read from audio source
287 sp<MonoPipeReader> source = mCurrentRoute->getSource();
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000288 if (source == nullptr) {
Mikhail Naganov06085452023-11-27 17:28:51 -0800289 if (++mReadErrorCount < kMaxReadErrorLogs) {
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000290 LOG(ERROR) << __func__
291 << ": no audio pipe yet we're trying to read! (not all errors will be "
292 "logged)";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530293 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530294 return ::android::OK;
295 }
296
Mikhail Naganov06085452023-11-27 17:28:51 -0800297 LOG(VERBOSE) << __func__ << ": " << mDeviceAddress.toString() << ", " << frameCount
298 << " frames";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530299 // read the data from the pipe
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530300 char* buff = (char*)buffer;
Mikhail Naganov06085452023-11-27 17:28:51 -0800301 size_t actuallyRead = 0;
302 long remainingFrames = frameCount;
303 const long deadlineTimeNs = ::android::uptimeNanos() +
304 getDelayInUsForFrameCount(frameCount) * NANOS_PER_MICROSECOND;
305 while (remainingFrames > 0) {
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530306 ssize_t framesRead = source->read(buff, remainingFrames);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530307 LOG(VERBOSE) << __func__ << ": frames read " << framesRead;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530308 if (framesRead > 0) {
309 remainingFrames -= framesRead;
310 buff += framesRead * mStreamConfig.frameSize;
Mikhail Naganov06085452023-11-27 17:28:51 -0800311 LOG(VERBOSE) << __func__ << ": got " << framesRead
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700312 << " frames, remaining =" << remainingFrames;
Mikhail Naganov06085452023-11-27 17:28:51 -0800313 actuallyRead += framesRead;
314 }
315 if (::android::uptimeNanos() >= deadlineTimeNs) break;
316 if (framesRead <= 0) {
317 LOG(VERBOSE) << __func__ << ": read returned " << framesRead
318 << ", read failure, sleeping for " << kReadAttemptSleepUs << " us";
319 usleep(kReadAttemptSleepUs);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530320 }
321 }
Mikhail Naganov06085452023-11-27 17:28:51 -0800322 if (actuallyRead < frameCount) {
323 LOG(WARNING) << __func__ << ": read " << actuallyRead << " vs. requested " << frameCount;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530324 }
Mikhail Naganov06085452023-11-27 17:28:51 -0800325 mCurrentRoute->updateReadCounterFrames(*actualFrameCount);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530326 return ::android::OK;
327}
328
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -0700329StreamInRemoteSubmix::StreamInRemoteSubmix(StreamContext&& context,
330 const SinkMetadata& sinkMetadata,
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530331 const std::vector<MicrophoneInfo>& microphones)
Mikhail Naganov459b7332023-08-03 10:26:21 -0700332 : StreamIn(std::move(context), microphones), StreamSwitcher(&mContextInstance, sinkMetadata) {}
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530333
334ndk::ScopedAStatus StreamInRemoteSubmix::getActiveMicrophones(
335 std::vector<MicrophoneDynamicInfo>* _aidl_return) {
336 LOG(DEBUG) << __func__ << ": not supported";
337 *_aidl_return = std::vector<MicrophoneDynamicInfo>();
338 return ndk::ScopedAStatus::ok();
339}
340
Shraddha Basantwani2e460342023-07-26 16:12:21 +0000341StreamSwitcher::DeviceSwitchBehavior StreamInRemoteSubmix::switchCurrentStream(
342 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) {
343 // This implementation effectively postpones stream creation until
344 // receiving the first call to 'setConnectedDevices' with a non-empty list.
345 if (isStubStream()) {
346 if (devices.size() == 1) {
347 auto deviceDesc = devices.front().type;
348 if (deviceDesc.type ==
349 ::aidl::android::media::audio::common::AudioDeviceType::IN_SUBMIX) {
350 return DeviceSwitchBehavior::CREATE_NEW_STREAM;
351 }
352 LOG(ERROR) << __func__ << ": Device type " << toString(deviceDesc.type)
353 << " not supported";
354 } else {
355 LOG(ERROR) << __func__ << ": Only single device supported.";
356 }
357 return DeviceSwitchBehavior::UNSUPPORTED_DEVICES;
358 }
359 return DeviceSwitchBehavior::USE_CURRENT_STREAM;
360}
361
362std::unique_ptr<StreamCommonInterfaceEx> StreamInRemoteSubmix::createNewStream(
363 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices,
364 StreamContext* context, const Metadata& metadata) {
365 return std::unique_ptr<StreamCommonInterfaceEx>(
366 new InnerStreamWrapper<StreamRemoteSubmix>(context, metadata, devices.front().address));
367}
368
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -0700369StreamOutRemoteSubmix::StreamOutRemoteSubmix(StreamContext&& context,
370 const SourceMetadata& sourceMetadata,
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530371 const std::optional<AudioOffloadInfo>& offloadInfo)
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -0700372 : StreamOut(std::move(context), offloadInfo),
Mikhail Naganov459b7332023-08-03 10:26:21 -0700373 StreamSwitcher(&mContextInstance, sourceMetadata) {}
Shraddha Basantwani2e460342023-07-26 16:12:21 +0000374
375StreamSwitcher::DeviceSwitchBehavior StreamOutRemoteSubmix::switchCurrentStream(
376 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) {
377 // This implementation effectively postpones stream creation until
378 // receiving the first call to 'setConnectedDevices' with a non-empty list.
379 if (isStubStream()) {
380 if (devices.size() == 1) {
381 auto deviceDesc = devices.front().type;
382 if (deviceDesc.type ==
383 ::aidl::android::media::audio::common::AudioDeviceType::OUT_SUBMIX) {
384 return DeviceSwitchBehavior::CREATE_NEW_STREAM;
385 }
386 LOG(ERROR) << __func__ << ": Device type " << toString(deviceDesc.type)
387 << " not supported";
388 } else {
389 LOG(ERROR) << __func__ << ": Only single device supported.";
390 }
391 return DeviceSwitchBehavior::UNSUPPORTED_DEVICES;
392 }
393 return DeviceSwitchBehavior::USE_CURRENT_STREAM;
394}
395
396std::unique_ptr<StreamCommonInterfaceEx> StreamOutRemoteSubmix::createNewStream(
397 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices,
398 StreamContext* context, const Metadata& metadata) {
399 return std::unique_ptr<StreamCommonInterfaceEx>(
400 new InnerStreamWrapper<StreamRemoteSubmix>(context, metadata, devices.front().address));
401}
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530402
403} // namespace aidl::android::hardware::audio::core