blob: d9b87666d4c980e79f08f27124757758e5ea081f [file] [log] [blame]
Phil Burk2355edb2016-12-26 13:54:02 -08001/*
2 * Copyright (C) 2016 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
Eric Laurentcb4dae22017-07-01 19:39:32 -070017#define LOG_TAG "AAudioServiceStreamBase"
Phil Burk2355edb2016-12-26 13:54:02 -080018//#define LOG_NDEBUG 0
19#include <utils/Log.h>
20
Phil Burka5222e22017-07-28 13:31:14 -070021#include <iomanip>
22#include <iostream>
Phil Burkc0c70e32017-02-09 13:18:38 -080023#include <mutex>
Phil Burk2355edb2016-12-26 13:54:02 -080024
Phil Burkc0c70e32017-02-09 13:18:38 -080025#include "binding/IAAudioService.h"
26#include "binding/AAudioServiceMessage.h"
27#include "utility/AudioClock.h"
28
Phil Burk39f02dd2017-08-04 09:13:31 -070029#include "AAudioEndpointManager.h"
30#include "AAudioService.h"
31#include "AAudioServiceEndpoint.h"
Phil Burkc0c70e32017-02-09 13:18:38 -080032#include "AAudioServiceStreamBase.h"
33#include "TimestampScheduler.h"
34
35using namespace android; // TODO just import names needed
36using namespace aaudio; // TODO just import names needed
Phil Burk2355edb2016-12-26 13:54:02 -080037
38/**
Phil Burkc0c70e32017-02-09 13:18:38 -080039 * Base class for streams in the service.
40 * @return
Phil Burk2355edb2016-12-26 13:54:02 -080041 */
42
Phil Burk39f02dd2017-08-04 09:13:31 -070043AAudioServiceStreamBase::AAudioServiceStreamBase(AAudioService &audioService)
Phil Burk2355edb2016-12-26 13:54:02 -080044 : mUpMessageQueue(nullptr)
Phil Burkbcc36742017-08-31 17:24:51 -070045 , mTimestampThread()
Phil Burk39f02dd2017-08-04 09:13:31 -070046 , mAtomicTimestamp()
47 , mAudioService(audioService) {
Eric Laurentcb4dae22017-07-01 19:39:32 -070048 mMmapClient.clientUid = -1;
49 mMmapClient.clientPid = -1;
50 mMmapClient.packageName = String16("");
Phil Burk2355edb2016-12-26 13:54:02 -080051}
52
Phil Burk5ed503c2017-02-01 09:38:15 -080053AAudioServiceStreamBase::~AAudioServiceStreamBase() {
Phil Burk98d6d922017-07-06 11:52:45 -070054 ALOGD("AAudioServiceStreamBase::~AAudioServiceStreamBase() destroying %p", this);
Phil Burk5a26e662017-07-07 12:44:48 -070055 // If the stream is deleted when OPEN or in use then audio resources will leak.
56 // This would indicate an internal error. So we want to find this ASAP.
Phil Burkbcc36742017-08-31 17:24:51 -070057 LOG_ALWAYS_FATAL_IF(!(getState() == AAUDIO_STREAM_STATE_CLOSED
58 || getState() == AAUDIO_STREAM_STATE_UNINITIALIZED
59 || getState() == AAUDIO_STREAM_STATE_DISCONNECTED),
60 "service stream still open, state = %d", getState());
Phil Burk2355edb2016-12-26 13:54:02 -080061}
62
Phil Burka5222e22017-07-28 13:31:14 -070063std::string AAudioServiceStreamBase::dumpHeader() {
64 return std::string(" T Handle UId Run State Format Burst Chan Capacity");
65}
66
Phil Burk4501b352017-06-29 18:12:36 -070067std::string AAudioServiceStreamBase::dump() const {
68 std::stringstream result;
69
Phil Burka5222e22017-07-28 13:31:14 -070070 result << " 0x" << std::setfill('0') << std::setw(8) << std::hex << mHandle
71 << std::dec << std::setfill(' ') ;
72 result << std::setw(6) << mMmapClient.clientUid;
73 result << std::setw(4) << (isRunning() ? "yes" : " no");
Phil Burkbcc36742017-08-31 17:24:51 -070074 result << std::setw(6) << getState();
Phil Burk39f02dd2017-08-04 09:13:31 -070075 result << std::setw(7) << getFormat();
Phil Burka5222e22017-07-28 13:31:14 -070076 result << std::setw(6) << mFramesPerBurst;
Phil Burk39f02dd2017-08-04 09:13:31 -070077 result << std::setw(5) << getSamplesPerFrame();
78 result << std::setw(9) << getBufferCapacity();
Phil Burk4501b352017-06-29 18:12:36 -070079
80 return result.str();
81}
82
Phil Burkc0c70e32017-02-09 13:18:38 -080083aaudio_result_t AAudioServiceStreamBase::open(const aaudio::AAudioStreamRequest &request,
Phil Burk39f02dd2017-08-04 09:13:31 -070084 aaudio_sharing_mode_t sharingMode) {
85 AAudioEndpointManager &mEndpointManager = AAudioEndpointManager::getInstance();
86 aaudio_result_t result = AAUDIO_OK;
Eric Laurentcb4dae22017-07-01 19:39:32 -070087
88 mMmapClient.clientUid = request.getUserId();
89 mMmapClient.clientPid = request.getProcessId();
Phil Burk39f02dd2017-08-04 09:13:31 -070090 mMmapClient.packageName.setTo(String16("")); // TODO What should we do here?
Eric Laurentcb4dae22017-07-01 19:39:32 -070091
Phil Burk39f02dd2017-08-04 09:13:31 -070092 // Limit scope of lock to avoid recursive lock in close().
93 {
94 std::lock_guard<std::mutex> lock(mUpMessageQueueLock);
95 if (mUpMessageQueue != nullptr) {
96 ALOGE("AAudioServiceStreamBase::open() called twice");
97 return AAUDIO_ERROR_INVALID_STATE;
98 }
99
Phil Burkc0c70e32017-02-09 13:18:38 -0800100 mUpMessageQueue = new SharedRingBuffer();
Phil Burk39f02dd2017-08-04 09:13:31 -0700101 result = mUpMessageQueue->allocate(sizeof(AAudioServiceMessage),
102 QUEUE_UP_CAPACITY_COMMANDS);
103 if (result != AAUDIO_OK) {
104 goto error;
105 }
106
Phil Burk92c3e262018-05-01 13:03:52 -0700107 // This is not protected by a lock because the stream cannot be
108 // referenced until the service returns a handle to the client.
109 // So only one thread can open a stream.
Phil Burk39f02dd2017-08-04 09:13:31 -0700110 mServiceEndpoint = mEndpointManager.openEndpoint(mAudioService,
111 request,
112 sharingMode);
113 if (mServiceEndpoint == nullptr) {
114 ALOGE("AAudioServiceStreamBase::open() openEndpoint() failed");
115 result = AAUDIO_ERROR_UNAVAILABLE;
116 goto error;
117 }
Phil Burk92c3e262018-05-01 13:03:52 -0700118 // Save a weak pointer that we will use to access the endpoint.
119 mServiceEndpointWeak = mServiceEndpoint;
120
Phil Burk39f02dd2017-08-04 09:13:31 -0700121 mFramesPerBurst = mServiceEndpoint->getFramesPerBurst();
122 copyFrom(*mServiceEndpoint);
Phil Burkc0c70e32017-02-09 13:18:38 -0800123 }
Phil Burk39f02dd2017-08-04 09:13:31 -0700124 return result;
125
126error:
127 close();
128 return result;
Phil Burkc0c70e32017-02-09 13:18:38 -0800129}
Phil Burkdec33ab2017-01-17 14:48:16 -0800130
Phil Burkc0c70e32017-02-09 13:18:38 -0800131aaudio_result_t AAudioServiceStreamBase::close() {
Phil Burk39f02dd2017-08-04 09:13:31 -0700132 aaudio_result_t result = AAUDIO_OK;
Phil Burkbcc36742017-08-31 17:24:51 -0700133 if (getState() == AAUDIO_STREAM_STATE_CLOSED) {
Phil Burk39f02dd2017-08-04 09:13:31 -0700134 return AAUDIO_OK;
135 }
136
137 stop();
138
Phil Burk92c3e262018-05-01 13:03:52 -0700139 sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote();
140 if (endpoint == nullptr) {
Phil Burk39f02dd2017-08-04 09:13:31 -0700141 result = AAUDIO_ERROR_INVALID_STATE;
142 } else {
Phil Burk92c3e262018-05-01 13:03:52 -0700143 endpoint->unregisterStream(this);
144 AAudioEndpointManager &endpointManager = AAudioEndpointManager::getInstance();
145 endpointManager.closeEndpoint(endpoint);
146
147 // AAudioService::closeStream() prevents two threads from closing at the same time.
148 mServiceEndpoint.clear(); // endpoint will hold the pointer until this method returns.
Phil Burk39f02dd2017-08-04 09:13:31 -0700149 }
150
Phil Burk92c3e262018-05-01 13:03:52 -0700151
Phil Burk39f02dd2017-08-04 09:13:31 -0700152 {
153 std::lock_guard<std::mutex> lock(mUpMessageQueueLock);
Phil Burk98d6d922017-07-06 11:52:45 -0700154 stopTimestampThread();
Phil Burk98d6d922017-07-06 11:52:45 -0700155 delete mUpMessageQueue;
156 mUpMessageQueue = nullptr;
Phil Burk98d6d922017-07-06 11:52:45 -0700157 }
Phil Burk39f02dd2017-08-04 09:13:31 -0700158
Phil Burkbcc36742017-08-31 17:24:51 -0700159 setState(AAUDIO_STREAM_STATE_CLOSED);
Phil Burk39f02dd2017-08-04 09:13:31 -0700160 return result;
Phil Burkc0c70e32017-02-09 13:18:38 -0800161}
162
Phil Burkbcc36742017-08-31 17:24:51 -0700163aaudio_result_t AAudioServiceStreamBase::startDevice() {
164 mClientHandle = AUDIO_PORT_HANDLE_NONE;
Phil Burk92c3e262018-05-01 13:03:52 -0700165 sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote();
166 if (endpoint == nullptr) {
167 ALOGE("%s() has no endpoint", __func__);
168 return AAUDIO_ERROR_INVALID_STATE;
169 }
170 return endpoint->startStream(this, &mClientHandle);
Phil Burkbcc36742017-08-31 17:24:51 -0700171}
172
Phil Burk39f02dd2017-08-04 09:13:31 -0700173/**
174 * Start the flow of audio data.
175 *
176 * An AAUDIO_SERVICE_EVENT_STARTED will be sent to the client when complete.
177 */
Phil Burkc0c70e32017-02-09 13:18:38 -0800178aaudio_result_t AAudioServiceStreamBase::start() {
Phil Burkbcc36742017-08-31 17:24:51 -0700179 aaudio_result_t result = AAUDIO_OK;
Phil Burk92c3e262018-05-01 13:03:52 -0700180
Eric Laurentcb4dae22017-07-01 19:39:32 -0700181 if (isRunning()) {
182 return AAUDIO_OK;
183 }
Phil Burk39f02dd2017-08-04 09:13:31 -0700184
Phil Burkbcc36742017-08-31 17:24:51 -0700185 // Start with fresh presentation timestamps.
186 mAtomicTimestamp.clear();
187
Phil Burk39f02dd2017-08-04 09:13:31 -0700188 mClientHandle = AUDIO_PORT_HANDLE_NONE;
Phil Burkbcc36742017-08-31 17:24:51 -0700189 result = startDevice();
190 if (result != AAUDIO_OK) goto error;
191
192 // This should happen at the end of the start.
193 sendServiceEvent(AAUDIO_SERVICE_EVENT_STARTED);
194 setState(AAUDIO_STREAM_STATE_STARTED);
195 mThreadEnabled.store(true);
196 result = mTimestampThread.start(this);
197 if (result != AAUDIO_OK) goto error;
198
199 return result;
200
201error:
202 disconnect();
Phil Burk39f02dd2017-08-04 09:13:31 -0700203 return result;
Phil Burkc0c70e32017-02-09 13:18:38 -0800204}
205
206aaudio_result_t AAudioServiceStreamBase::pause() {
Phil Burk11e8d332017-05-24 09:59:02 -0700207 aaudio_result_t result = AAUDIO_OK;
Eric Laurentcb4dae22017-07-01 19:39:32 -0700208 if (!isRunning()) {
209 return result;
Phil Burkc0c70e32017-02-09 13:18:38 -0800210 }
Phil Burk999e1102017-10-26 12:11:47 -0700211
212 // Send it now because the timestamp gets rounded up when stopStream() is called below.
213 // Also we don't need the timestamps while we are shutting down.
214 sendCurrentTimestamp();
215
216 result = stopTimestampThread();
217 if (result != AAUDIO_OK) {
218 disconnect();
219 return result;
220 }
221
Phil Burk92c3e262018-05-01 13:03:52 -0700222 sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote();
223 if (endpoint == nullptr) {
224 ALOGE("%s() has no endpoint", __func__);
225 return AAUDIO_ERROR_INVALID_STATE;
226 }
227 result = endpoint->stopStream(this, mClientHandle);
Phil Burk39f02dd2017-08-04 09:13:31 -0700228 if (result != AAUDIO_OK) {
229 ALOGE("AAudioServiceStreamShared::pause() mServiceEndpoint returned %d", result);
230 disconnect(); // TODO should we return or pause Base first?
231 }
232
Eric Laurentcb4dae22017-07-01 19:39:32 -0700233 sendServiceEvent(AAUDIO_SERVICE_EVENT_PAUSED);
Phil Burkbcc36742017-08-31 17:24:51 -0700234 setState(AAUDIO_STREAM_STATE_PAUSED);
Phil Burkc0c70e32017-02-09 13:18:38 -0800235 return result;
236}
237
Phil Burk71f35bb2017-04-13 16:05:07 -0700238aaudio_result_t AAudioServiceStreamBase::stop() {
Phil Burk11e8d332017-05-24 09:59:02 -0700239 aaudio_result_t result = AAUDIO_OK;
Eric Laurentcb4dae22017-07-01 19:39:32 -0700240 if (!isRunning()) {
241 return result;
Phil Burk71f35bb2017-04-13 16:05:07 -0700242 }
Phil Burk39f02dd2017-08-04 09:13:31 -0700243
Phil Burk999e1102017-10-26 12:11:47 -0700244 // Send it now because the timestamp gets rounded up when stopStream() is called below.
245 // Also we don't need the timestamps while we are shutting down.
Eric Laurentcb4dae22017-07-01 19:39:32 -0700246 sendCurrentTimestamp(); // warning - this calls a virtual function
247 result = stopTimestampThread();
248 if (result != AAUDIO_OK) {
249 disconnect();
250 return result;
251 }
Phil Burk39f02dd2017-08-04 09:13:31 -0700252
Phil Burk92c3e262018-05-01 13:03:52 -0700253 sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote();
254 if (endpoint == nullptr) {
255 ALOGE("%s() has no endpoint", __func__);
256 return AAUDIO_ERROR_INVALID_STATE;
257 }
Phil Burk39f02dd2017-08-04 09:13:31 -0700258 // TODO wait for data to be played out
Phil Burk92c3e262018-05-01 13:03:52 -0700259 result = endpoint->stopStream(this, mClientHandle);
Phil Burk39f02dd2017-08-04 09:13:31 -0700260 if (result != AAUDIO_OK) {
261 ALOGE("AAudioServiceStreamShared::stop() mServiceEndpoint returned %d", result);
262 disconnect();
263 // TODO what to do with result here?
264 }
265
Eric Laurentcb4dae22017-07-01 19:39:32 -0700266 sendServiceEvent(AAUDIO_SERVICE_EVENT_STOPPED);
Phil Burkbcc36742017-08-31 17:24:51 -0700267 setState(AAUDIO_STREAM_STATE_STOPPED);
Phil Burk71f35bb2017-04-13 16:05:07 -0700268 return result;
269}
270
Phil Burk98d6d922017-07-06 11:52:45 -0700271aaudio_result_t AAudioServiceStreamBase::stopTimestampThread() {
272 aaudio_result_t result = AAUDIO_OK;
273 // clear flag that tells thread to loop
274 if (mThreadEnabled.exchange(false)) {
Phil Burkbcc36742017-08-31 17:24:51 -0700275 result = mTimestampThread.stop();
Phil Burk98d6d922017-07-06 11:52:45 -0700276 }
277 return result;
278}
279
Phil Burk71f35bb2017-04-13 16:05:07 -0700280aaudio_result_t AAudioServiceStreamBase::flush() {
Phil Burkbcc36742017-08-31 17:24:51 -0700281 if (getState() != AAUDIO_STREAM_STATE_PAUSED) {
Phil Burk39f02dd2017-08-04 09:13:31 -0700282 ALOGE("AAudioServiceStreamBase::flush() stream not paused, state = %s",
283 AAudio_convertStreamStateToText(mState));
284 return AAUDIO_ERROR_INVALID_STATE;
285 }
286 // Data will get flushed when the client receives the FLUSHED event.
Phil Burk71f35bb2017-04-13 16:05:07 -0700287 sendServiceEvent(AAUDIO_SERVICE_EVENT_FLUSHED);
Phil Burkbcc36742017-08-31 17:24:51 -0700288 setState(AAUDIO_STREAM_STATE_FLUSHED);
Phil Burk71f35bb2017-04-13 16:05:07 -0700289 return AAUDIO_OK;
290}
291
Phil Burkcf5f6d22017-05-26 12:35:07 -0700292// implement Runnable, periodically send timestamps to client
Phil Burkc0c70e32017-02-09 13:18:38 -0800293void AAudioServiceStreamBase::run() {
Phil Burk71f35bb2017-04-13 16:05:07 -0700294 ALOGD("AAudioServiceStreamBase::run() entering ----------------");
Phil Burkc0c70e32017-02-09 13:18:38 -0800295 TimestampScheduler timestampScheduler;
Phil Burk39f02dd2017-08-04 09:13:31 -0700296 timestampScheduler.setBurstPeriod(mFramesPerBurst, getSampleRate());
Phil Burkc0c70e32017-02-09 13:18:38 -0800297 timestampScheduler.start(AudioClock::getNanoseconds());
298 int64_t nextTime = timestampScheduler.nextAbsoluteTime();
299 while(mThreadEnabled.load()) {
300 if (AudioClock::getNanoseconds() >= nextTime) {
301 aaudio_result_t result = sendCurrentTimestamp();
302 if (result != AAUDIO_OK) {
303 break;
304 }
305 nextTime = timestampScheduler.nextAbsoluteTime();
306 } else {
307 // Sleep until it is time to send the next timestamp.
Phil Burk98d6d922017-07-06 11:52:45 -0700308 // TODO Wait for a signal with a timeout so that we can stop more quickly.
Phil Burkc0c70e32017-02-09 13:18:38 -0800309 AudioClock::sleepUntilNanoTime(nextTime);
310 }
311 }
Phil Burk71f35bb2017-04-13 16:05:07 -0700312 ALOGD("AAudioServiceStreamBase::run() exiting ----------------");
Phil Burkc0c70e32017-02-09 13:18:38 -0800313}
314
Phil Burk5ef003b2017-06-30 11:43:37 -0700315void AAudioServiceStreamBase::disconnect() {
Phil Burkbcc36742017-08-31 17:24:51 -0700316 if (getState() != AAUDIO_STREAM_STATE_DISCONNECTED) {
Phil Burk5ef003b2017-06-30 11:43:37 -0700317 sendServiceEvent(AAUDIO_SERVICE_EVENT_DISCONNECTED);
Phil Burkbcc36742017-08-31 17:24:51 -0700318 setState(AAUDIO_STREAM_STATE_DISCONNECTED);
Phil Burk5ef003b2017-06-30 11:43:37 -0700319 }
Phil Burkc0c70e32017-02-09 13:18:38 -0800320}
321
322aaudio_result_t AAudioServiceStreamBase::sendServiceEvent(aaudio_service_event_t event,
323 double dataDouble,
324 int64_t dataLong) {
Phil Burk5ed503c2017-02-01 09:38:15 -0800325 AAudioServiceMessage command;
326 command.what = AAudioServiceMessage::code::EVENT;
Phil Burk2355edb2016-12-26 13:54:02 -0800327 command.event.event = event;
Phil Burkc0c70e32017-02-09 13:18:38 -0800328 command.event.dataDouble = dataDouble;
329 command.event.dataLong = dataLong;
330 return writeUpMessageQueue(&command);
331}
332
333aaudio_result_t AAudioServiceStreamBase::writeUpMessageQueue(AAudioServiceMessage *command) {
Phil Burk39f02dd2017-08-04 09:13:31 -0700334 std::lock_guard<std::mutex> lock(mUpMessageQueueLock);
Phil Burk71f35bb2017-04-13 16:05:07 -0700335 if (mUpMessageQueue == nullptr) {
336 ALOGE("writeUpMessageQueue(): mUpMessageQueue null! - stream not open");
337 return AAUDIO_ERROR_NULL;
338 }
Phil Burkc0c70e32017-02-09 13:18:38 -0800339 int32_t count = mUpMessageQueue->getFifoBuffer()->write(command, 1);
340 if (count != 1) {
341 ALOGE("writeUpMessageQueue(): Queue full. Did client die?");
342 return AAUDIO_ERROR_WOULD_BLOCK;
343 } else {
344 return AAUDIO_OK;
345 }
346}
347
348aaudio_result_t AAudioServiceStreamBase::sendCurrentTimestamp() {
349 AAudioServiceMessage command;
Phil Burk97350f92017-07-21 15:59:44 -0700350 // Send a timestamp for the clock model.
Phil Burkc0c70e32017-02-09 13:18:38 -0800351 aaudio_result_t result = getFreeRunningPosition(&command.timestamp.position,
352 &command.timestamp.timestamp);
353 if (result == AAUDIO_OK) {
Phil Burkbcc36742017-08-31 17:24:51 -0700354 ALOGV("sendCurrentTimestamp() SERVICE %8lld at %lld",
355 (long long) command.timestamp.position,
356 (long long) command.timestamp.timestamp);
Phil Burk97350f92017-07-21 15:59:44 -0700357 command.what = AAudioServiceMessage::code::TIMESTAMP_SERVICE;
Phil Burkc0c70e32017-02-09 13:18:38 -0800358 result = writeUpMessageQueue(&command);
Phil Burk97350f92017-07-21 15:59:44 -0700359
360 if (result == AAUDIO_OK) {
361 // Send a hardware timestamp for presentation time.
362 result = getHardwareTimestamp(&command.timestamp.position,
363 &command.timestamp.timestamp);
364 if (result == AAUDIO_OK) {
Phil Burkbcc36742017-08-31 17:24:51 -0700365 ALOGV("sendCurrentTimestamp() HARDWARE %8lld at %lld",
366 (long long) command.timestamp.position,
367 (long long) command.timestamp.timestamp);
Phil Burk97350f92017-07-21 15:59:44 -0700368 command.what = AAudioServiceMessage::code::TIMESTAMP_HARDWARE;
369 result = writeUpMessageQueue(&command);
370 }
371 }
372 }
373
Phil Burkbcc36742017-08-31 17:24:51 -0700374 if (result == AAUDIO_ERROR_UNAVAILABLE) { // TODO review best error code
Phil Burk940083c2017-07-17 17:00:02 -0700375 result = AAUDIO_OK; // just not available yet, try again later
Phil Burkc0c70e32017-02-09 13:18:38 -0800376 }
377 return result;
Phil Burk2355edb2016-12-26 13:54:02 -0800378}
379
Phil Burkc0c70e32017-02-09 13:18:38 -0800380/**
381 * Get an immutable description of the in-memory queues
382 * used to communicate with the underlying HAL or Service.
383 */
384aaudio_result_t AAudioServiceStreamBase::getDescription(AudioEndpointParcelable &parcelable) {
Phil Burk523b3042017-09-13 13:03:08 -0700385 {
386 std::lock_guard<std::mutex> lock(mUpMessageQueueLock);
387 if (mUpMessageQueue == nullptr) {
388 ALOGE("getDescription(): mUpMessageQueue null! - stream not open");
389 return AAUDIO_ERROR_NULL;
390 }
391 // Gather information on the message queue.
392 mUpMessageQueue->fillParcelable(parcelable,
393 parcelable.mUpMessageQueueParcelable);
394 }
395 return getAudioDataDescription(parcelable);
Phil Burk11e8d332017-05-24 09:59:02 -0700396}
Phil Burk39f02dd2017-08-04 09:13:31 -0700397
398void AAudioServiceStreamBase::onVolumeChanged(float volume) {
399 sendServiceEvent(AAUDIO_SERVICE_EVENT_VOLUME, volume);
400}