blob: 2376ed9371abb804e84aab252e6432704f65ac17 [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
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053046::android::status_t StreamRemoteSubmix::init() {
Mikhail Naganov3b732892023-12-20 16:05:01 -080047 mCurrentRoute = SubmixRoute::findOrCreateRoute(mDeviceAddress, mStreamConfig);
48 if (mCurrentRoute == nullptr) {
49 return ::android::NO_INIT;
Mikhail Naganov06085452023-11-27 17:28:51 -080050 }
51 if (!mCurrentRoute->isStreamConfigValid(mIsInput, mStreamConfig)) {
52 LOG(ERROR) << __func__ << ": invalid stream config";
53 return ::android::NO_INIT;
54 }
55 sp<MonoPipe> sink = mCurrentRoute->getSink();
56 if (sink == nullptr) {
57 LOG(ERROR) << __func__ << ": nullptr sink when opening stream";
58 return ::android::NO_INIT;
59 }
Mikhail Naganov7b234d42023-12-05 11:28:56 -080060 if ((!mIsInput || mCurrentRoute->isStreamInOpen()) && sink->isShutdown()) {
61 LOG(DEBUG) << __func__ << ": Shut down sink when opening stream";
Mikhail Naganov06085452023-11-27 17:28:51 -080062 if (::android::OK != mCurrentRoute->resetPipe()) {
63 LOG(ERROR) << __func__ << ": reset pipe failed";
64 return ::android::NO_INIT;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053065 }
66 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053067 mCurrentRoute->openStream(mIsInput);
Mikhail Naganov49712b52023-06-27 16:39:33 -070068 return ::android::OK;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053069}
70
71::android::status_t StreamRemoteSubmix::drain(StreamDescriptor::DrainMode) {
72 usleep(1000);
73 return ::android::OK;
74}
75
76::android::status_t StreamRemoteSubmix::flush() {
77 usleep(1000);
78 return ::android::OK;
79}
80
81::android::status_t StreamRemoteSubmix::pause() {
82 usleep(1000);
83 return ::android::OK;
84}
85
Mikhail Naganov49712b52023-06-27 16:39:33 -070086::android::status_t StreamRemoteSubmix::standby() {
87 mCurrentRoute->standby(mIsInput);
88 return ::android::OK;
89}
90
91::android::status_t StreamRemoteSubmix::start() {
92 mCurrentRoute->exitStandby(mIsInput);
Mikhail Naganov06085452023-11-27 17:28:51 -080093 mStartTimeNs = ::android::uptimeNanos();
94 mFramesSinceStart = 0;
Mikhail Naganov49712b52023-06-27 16:39:33 -070095 return ::android::OK;
96}
97
Shraddha Basantwani6bb69632023-04-25 15:26:38 +053098ndk::ScopedAStatus StreamRemoteSubmix::prepareToClose() {
99 if (!mIsInput) {
Mikhail Naganov3b732892023-12-20 16:05:01 -0800100 std::shared_ptr<SubmixRoute> route = SubmixRoute::findRoute(mDeviceAddress);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530101 if (route != nullptr) {
102 sp<MonoPipe> sink = route->getSink();
103 if (sink == nullptr) {
104 ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
105 }
106 LOG(DEBUG) << __func__ << ": shutting down MonoPipe sink";
107
108 sink->shutdown(true);
Mikhail Naganov2ebe3902023-11-07 16:43:26 -0800109 // The client already considers this stream as closed, release the output end.
110 route->closeStream(mIsInput);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530111 } else {
112 LOG(DEBUG) << __func__ << ": stream already closed.";
113 ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
114 }
115 }
116 return ndk::ScopedAStatus::ok();
117}
118
119// Remove references to the specified input and output streams. When the device no longer
120// references input and output streams destroy the associated pipe.
121void StreamRemoteSubmix::shutdown() {
122 mCurrentRoute->closeStream(mIsInput);
123 // If all stream instances are closed, we can remove route information for this port.
124 if (!mCurrentRoute->hasAtleastOneStreamOpen()) {
125 mCurrentRoute->releasePipe();
126 LOG(DEBUG) << __func__ << ": pipe destroyed";
Mikhail Naganov3b732892023-12-20 16:05:01 -0800127 SubmixRoute::removeRoute(mDeviceAddress);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530128 }
Mikhail Naganov49712b52023-06-27 16:39:33 -0700129 mCurrentRoute.reset();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530130}
131
132::android::status_t StreamRemoteSubmix::transfer(void* buffer, size_t frameCount,
133 size_t* actualFrameCount, int32_t* latencyMs) {
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700134 *latencyMs = getDelayInUsForFrameCount(getStreamPipeSizeInFrames()) / 1000;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530135 LOG(VERBOSE) << __func__ << ": Latency " << *latencyMs << "ms";
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000136 mCurrentRoute->exitStandby(mIsInput);
Mikhail Naganov06085452023-11-27 17:28:51 -0800137 RETURN_STATUS_IF_ERROR(mIsInput ? inRead(buffer, frameCount, actualFrameCount)
138 : outWrite(buffer, frameCount, actualFrameCount));
Mikhail Naganov55e0afa2024-03-05 17:42:20 -0800139 mFramesSinceStart += *actualFrameCount;
140 if (!mIsInput) return ::android::OK;
141 // Only input streams need to block, for output this is implemented by MonoPipe.
Mikhail Naganov06085452023-11-27 17:28:51 -0800142 const long bufferDurationUs =
143 (*actualFrameCount) * MICROS_PER_SECOND / mContext.getSampleRate();
Mikhail Naganov878afae2024-01-03 11:22:42 -0800144 const auto totalDurationUs = (::android::uptimeNanos() - mStartTimeNs) / NANOS_PER_MICROSECOND;
Mikhail Naganov06085452023-11-27 17:28:51 -0800145 const long totalOffsetUs =
146 mFramesSinceStart * MICROS_PER_SECOND / mContext.getSampleRate() - totalDurationUs;
147 LOG(VERBOSE) << __func__ << ": totalOffsetUs " << totalOffsetUs;
148 if (totalOffsetUs > 0) {
149 const long sleepTimeUs = std::min(totalOffsetUs, bufferDurationUs);
150 LOG(VERBOSE) << __func__ << ": sleeping for " << sleepTimeUs << " us";
151 usleep(sleepTimeUs);
152 }
153 return ::android::OK;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530154}
155
Mikhail Naganov459b7332023-08-03 10:26:21 -0700156::android::status_t StreamRemoteSubmix::refinePosition(StreamDescriptor::Position* position) {
Mikhail Naganov704aec42023-07-13 11:08:29 -0700157 sp<MonoPipeReader> source = mCurrentRoute->getSource();
158 if (source == nullptr) {
159 return ::android::NO_INIT;
160 }
161 const ssize_t framesInPipe = source->availableToRead();
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000162 if (framesInPipe <= 0) {
163 // No need to update the position frames
164 return ::android::OK;
Mikhail Naganov704aec42023-07-13 11:08:29 -0700165 }
166 if (mIsInput) {
167 position->frames += framesInPipe;
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000168 } else if (position->frames >= framesInPipe) {
169 position->frames -= framesInPipe;
Mikhail Naganov704aec42023-07-13 11:08:29 -0700170 }
171 return ::android::OK;
172}
173
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700174long StreamRemoteSubmix::getDelayInUsForFrameCount(size_t frameCount) {
175 return frameCount * MICROS_PER_SECOND / mStreamConfig.sampleRate;
176}
177
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530178// Calculate the maximum size of the pipe buffer in frames for the specified stream.
179size_t StreamRemoteSubmix::getStreamPipeSizeInFrames() {
Mikhail Naganov3b732892023-12-20 16:05:01 -0800180 auto pipeConfig = mCurrentRoute->getPipeConfig();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530181 const size_t maxFrameSize = std::max(mStreamConfig.frameSize, pipeConfig.frameSize);
182 return (pipeConfig.frameCount * pipeConfig.frameSize) / maxFrameSize;
183}
184
185::android::status_t StreamRemoteSubmix::outWrite(void* buffer, size_t frameCount,
186 size_t* actualFrameCount) {
187 sp<MonoPipe> sink = mCurrentRoute->getSink();
188 if (sink != nullptr) {
189 if (sink->isShutdown()) {
190 sink.clear();
Mikhail Naganov06085452023-11-27 17:28:51 -0800191 LOG(DEBUG) << __func__ << ": pipe shutdown, ignoring the write";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530192 *actualFrameCount = frameCount;
193 return ::android::OK;
194 }
195 } else {
196 LOG(FATAL) << __func__ << ": without a pipe!";
197 return ::android::UNKNOWN_ERROR;
198 }
199
Mikhail Naganov06085452023-11-27 17:28:51 -0800200 LOG(VERBOSE) << __func__ << ": " << mDeviceAddress.toString() << ", " << frameCount
201 << " frames";
202
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700203 const bool shouldBlockWrite = mCurrentRoute->shouldBlockWrite();
204 size_t availableToWrite = sink->availableToWrite();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530205 // NOTE: sink has been checked above and sink and source life cycles are synchronized
206 sp<MonoPipeReader> source = mCurrentRoute->getSource();
207 // If the write to the sink should be blocked, flush enough frames from the pipe to make space
208 // to write the most recent data.
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700209 if (!shouldBlockWrite && availableToWrite < frameCount) {
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530210 static uint8_t flushBuffer[64];
211 const size_t flushBufferSizeFrames = sizeof(flushBuffer) / mStreamConfig.frameSize;
212 size_t framesToFlushFromSource = frameCount - availableToWrite;
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700213 LOG(DEBUG) << __func__ << ": flushing " << framesToFlushFromSource
214 << " frames from the pipe to avoid blocking";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530215 while (framesToFlushFromSource) {
216 const size_t flushSize = std::min(framesToFlushFromSource, flushBufferSizeFrames);
217 framesToFlushFromSource -= flushSize;
218 // read does not block
219 source->read(flushBuffer, flushSize);
220 }
221 }
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700222 availableToWrite = sink->availableToWrite();
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530223
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700224 if (!shouldBlockWrite && frameCount > availableToWrite) {
Mikhail Naganov06085452023-11-27 17:28:51 -0800225 LOG(WARNING) << __func__ << ": writing " << availableToWrite << " vs. requested "
226 << frameCount;
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700227 // Truncate the request to avoid blocking.
228 frameCount = availableToWrite;
229 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530230 ssize_t writtenFrames = sink->write(buffer, frameCount);
231 if (writtenFrames < 0) {
232 if (writtenFrames == (ssize_t)::android::NEGOTIATE) {
233 LOG(ERROR) << __func__ << ": write to pipe returned NEGOTIATE";
234 sink.clear();
235 *actualFrameCount = 0;
236 return ::android::UNKNOWN_ERROR;
237 } else {
238 // write() returned UNDERRUN or WOULD_BLOCK, retry
239 LOG(ERROR) << __func__ << ": write to pipe returned unexpected " << writtenFrames;
240 writtenFrames = sink->write(buffer, frameCount);
241 }
242 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530243
244 if (writtenFrames < 0) {
245 LOG(ERROR) << __func__ << ": failed writing to pipe with " << writtenFrames;
246 *actualFrameCount = 0;
247 return ::android::UNKNOWN_ERROR;
248 }
Mikhail Naganov06085452023-11-27 17:28:51 -0800249 if (writtenFrames > 0 && frameCount > (size_t)writtenFrames) {
250 LOG(WARNING) << __func__ << ": wrote " << writtenFrames << " vs. requested " << frameCount;
251 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530252 *actualFrameCount = writtenFrames;
253 return ::android::OK;
254}
255
256::android::status_t StreamRemoteSubmix::inRead(void* buffer, size_t frameCount,
257 size_t* actualFrameCount) {
Mikhail Naganov06085452023-11-27 17:28:51 -0800258 // in any case, it is emulated that data for the entire buffer was available
259 memset(buffer, 0, mStreamConfig.frameSize * frameCount);
260 *actualFrameCount = frameCount;
261
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530262 // about to read from audio source
263 sp<MonoPipeReader> source = mCurrentRoute->getSource();
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000264 if (source == nullptr) {
Mikhail Naganov06085452023-11-27 17:28:51 -0800265 if (++mReadErrorCount < kMaxReadErrorLogs) {
Shraddha Basantwani95f92322023-08-22 15:07:16 +0000266 LOG(ERROR) << __func__
267 << ": no audio pipe yet we're trying to read! (not all errors will be "
268 "logged)";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530269 }
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530270 return ::android::OK;
271 }
Mikhail Naganov9eb33142024-01-09 14:06:49 -0800272 mReadErrorCount = 0;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530273
Mikhail Naganov06085452023-11-27 17:28:51 -0800274 LOG(VERBOSE) << __func__ << ": " << mDeviceAddress.toString() << ", " << frameCount
275 << " frames";
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530276 // read the data from the pipe
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530277 char* buff = (char*)buffer;
Mikhail Naganov06085452023-11-27 17:28:51 -0800278 size_t actuallyRead = 0;
279 long remainingFrames = frameCount;
Mikhail Naganov55e0afa2024-03-05 17:42:20 -0800280 const int64_t deadlineTimeNs =
281 ::android::uptimeNanos() +
282 getDelayInUsForFrameCount(frameCount) * NANOS_PER_MICROSECOND / 2;
Mikhail Naganov06085452023-11-27 17:28:51 -0800283 while (remainingFrames > 0) {
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530284 ssize_t framesRead = source->read(buff, remainingFrames);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530285 LOG(VERBOSE) << __func__ << ": frames read " << framesRead;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530286 if (framesRead > 0) {
287 remainingFrames -= framesRead;
288 buff += framesRead * mStreamConfig.frameSize;
Mikhail Naganov06085452023-11-27 17:28:51 -0800289 LOG(VERBOSE) << __func__ << ": got " << framesRead
Mikhail Naganov2aab7662023-10-24 13:56:07 -0700290 << " frames, remaining =" << remainingFrames;
Mikhail Naganov06085452023-11-27 17:28:51 -0800291 actuallyRead += framesRead;
292 }
293 if (::android::uptimeNanos() >= deadlineTimeNs) break;
294 if (framesRead <= 0) {
295 LOG(VERBOSE) << __func__ << ": read returned " << framesRead
296 << ", read failure, sleeping for " << kReadAttemptSleepUs << " us";
297 usleep(kReadAttemptSleepUs);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530298 }
299 }
Mikhail Naganov06085452023-11-27 17:28:51 -0800300 if (actuallyRead < frameCount) {
Mikhail Naganov9eb33142024-01-09 14:06:49 -0800301 if (++mReadFailureCount < kMaxReadFailureAttempts) {
302 LOG(WARNING) << __func__ << ": read " << actuallyRead << " vs. requested " << frameCount
303 << " (not all errors will be logged)";
304 }
305 } else {
306 mReadFailureCount = 0;
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530307 }
Mikhail Naganov06085452023-11-27 17:28:51 -0800308 mCurrentRoute->updateReadCounterFrames(*actualFrameCount);
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530309 return ::android::OK;
310}
311
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -0700312StreamInRemoteSubmix::StreamInRemoteSubmix(StreamContext&& context,
313 const SinkMetadata& sinkMetadata,
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530314 const std::vector<MicrophoneInfo>& microphones)
Mikhail Naganov459b7332023-08-03 10:26:21 -0700315 : StreamIn(std::move(context), microphones), StreamSwitcher(&mContextInstance, sinkMetadata) {}
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530316
317ndk::ScopedAStatus StreamInRemoteSubmix::getActiveMicrophones(
318 std::vector<MicrophoneDynamicInfo>* _aidl_return) {
319 LOG(DEBUG) << __func__ << ": not supported";
320 *_aidl_return = std::vector<MicrophoneDynamicInfo>();
321 return ndk::ScopedAStatus::ok();
322}
323
Shraddha Basantwani2e460342023-07-26 16:12:21 +0000324StreamSwitcher::DeviceSwitchBehavior StreamInRemoteSubmix::switchCurrentStream(
325 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) {
326 // This implementation effectively postpones stream creation until
327 // receiving the first call to 'setConnectedDevices' with a non-empty list.
328 if (isStubStream()) {
329 if (devices.size() == 1) {
330 auto deviceDesc = devices.front().type;
331 if (deviceDesc.type ==
332 ::aidl::android::media::audio::common::AudioDeviceType::IN_SUBMIX) {
333 return DeviceSwitchBehavior::CREATE_NEW_STREAM;
334 }
335 LOG(ERROR) << __func__ << ": Device type " << toString(deviceDesc.type)
336 << " not supported";
337 } else {
338 LOG(ERROR) << __func__ << ": Only single device supported.";
339 }
340 return DeviceSwitchBehavior::UNSUPPORTED_DEVICES;
341 }
342 return DeviceSwitchBehavior::USE_CURRENT_STREAM;
343}
344
345std::unique_ptr<StreamCommonInterfaceEx> StreamInRemoteSubmix::createNewStream(
346 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices,
347 StreamContext* context, const Metadata& metadata) {
348 return std::unique_ptr<StreamCommonInterfaceEx>(
349 new InnerStreamWrapper<StreamRemoteSubmix>(context, metadata, devices.front().address));
350}
351
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -0700352StreamOutRemoteSubmix::StreamOutRemoteSubmix(StreamContext&& context,
353 const SourceMetadata& sourceMetadata,
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530354 const std::optional<AudioOffloadInfo>& offloadInfo)
Mikhail Naganov6ddefdb2023-07-19 17:30:06 -0700355 : StreamOut(std::move(context), offloadInfo),
Mikhail Naganov459b7332023-08-03 10:26:21 -0700356 StreamSwitcher(&mContextInstance, sourceMetadata) {}
Shraddha Basantwani2e460342023-07-26 16:12:21 +0000357
358StreamSwitcher::DeviceSwitchBehavior StreamOutRemoteSubmix::switchCurrentStream(
359 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) {
360 // This implementation effectively postpones stream creation until
361 // receiving the first call to 'setConnectedDevices' with a non-empty list.
362 if (isStubStream()) {
363 if (devices.size() == 1) {
364 auto deviceDesc = devices.front().type;
365 if (deviceDesc.type ==
366 ::aidl::android::media::audio::common::AudioDeviceType::OUT_SUBMIX) {
367 return DeviceSwitchBehavior::CREATE_NEW_STREAM;
368 }
369 LOG(ERROR) << __func__ << ": Device type " << toString(deviceDesc.type)
370 << " not supported";
371 } else {
372 LOG(ERROR) << __func__ << ": Only single device supported.";
373 }
374 return DeviceSwitchBehavior::UNSUPPORTED_DEVICES;
375 }
376 return DeviceSwitchBehavior::USE_CURRENT_STREAM;
377}
378
379std::unique_ptr<StreamCommonInterfaceEx> StreamOutRemoteSubmix::createNewStream(
380 const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices,
381 StreamContext* context, const Metadata& metadata) {
382 return std::unique_ptr<StreamCommonInterfaceEx>(
383 new InnerStreamWrapper<StreamRemoteSubmix>(context, metadata, devices.front().address));
384}
Shraddha Basantwani6bb69632023-04-25 15:26:38 +0530385
386} // namespace aidl::android::hardware::audio::core