• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 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 
17 #define LOG_TAG "AudioStreamTrack"
18 //#define LOG_NDEBUG 0
19 #include <utils/Log.h>
20 
21 #include <stdint.h>
22 #include <media/AudioTrack.h>
23 
24 #include <aaudio/AAudio.h>
25 #include <system/audio.h>
26 
27 #include "core/AudioGlobal.h"
28 #include "legacy/AudioStreamLegacy.h"
29 #include "legacy/AudioStreamTrack.h"
30 #include "utility/AudioClock.h"
31 #include "utility/FixedBlockReader.h"
32 
33 using namespace android;
34 using namespace aaudio;
35 
36 using android::content::AttributionSourceState;
37 
38 // Arbitrary and somewhat generous number of bursts.
39 #define DEFAULT_BURSTS_PER_BUFFER_CAPACITY     8
40 
41 /*
42  * Create a stream that uses the AudioTrack.
43  */
AudioStreamTrack()44 AudioStreamTrack::AudioStreamTrack()
45     : AudioStreamLegacy()
46     , mFixedBlockReader(*this)
47 {
48 }
49 
~AudioStreamTrack()50 AudioStreamTrack::~AudioStreamTrack()
51 {
52     const aaudio_stream_state_t state = getState();
53     bool bad = !(state == AAUDIO_STREAM_STATE_UNINITIALIZED || state == AAUDIO_STREAM_STATE_CLOSED);
54     ALOGE_IF(bad, "stream not closed, in state %d", state);
55 }
56 
open(const AudioStreamBuilder & builder)57 aaudio_result_t AudioStreamTrack::open(const AudioStreamBuilder& builder)
58 {
59     aaudio_result_t result = AAUDIO_OK;
60 
61     result = AudioStream::open(builder);
62     if (result != OK) {
63         return result;
64     }
65 
66     const aaudio_session_id_t requestedSessionId = builder.getSessionId();
67     const audio_session_t sessionId = AAudioConvert_aaudioToAndroidSessionId(requestedSessionId);
68 
69     audio_channel_mask_t channelMask =
70             AAudio_getChannelMaskForOpen(getChannelMask(), getSamplesPerFrame(), false /*isInput*/);
71 
72     audio_output_flags_t flags;
73     aaudio_performance_mode_t perfMode = getPerformanceMode();
74     switch(perfMode) {
75         case AAUDIO_PERFORMANCE_MODE_LOW_LATENCY:
76             // Bypass the normal mixer and go straight to the FAST mixer.
77             // If the app asks for a sessionId then it means they want to use effects.
78             // So don't use RAW flag.
79             flags = (audio_output_flags_t) ((requestedSessionId == AAUDIO_SESSION_ID_NONE)
80                     ? (AUDIO_OUTPUT_FLAG_FAST | AUDIO_OUTPUT_FLAG_RAW)
81                     : (AUDIO_OUTPUT_FLAG_FAST));
82             break;
83 
84         case AAUDIO_PERFORMANCE_MODE_POWER_SAVING:
85             // This uses a mixer that wakes up less often than the FAST mixer.
86             flags = AUDIO_OUTPUT_FLAG_DEEP_BUFFER;
87             break;
88 
89         case AAUDIO_PERFORMANCE_MODE_NONE:
90         default:
91             // No flags. Use a normal mixer in front of the FAST mixer.
92             flags = AUDIO_OUTPUT_FLAG_NONE;
93             break;
94     }
95 
96     size_t frameCount = (size_t)builder.getBufferCapacity();
97 
98     // To avoid glitching, let AudioFlinger pick the optimal burst size.
99     int32_t notificationFrames = 0;
100 
101     const audio_format_t format = (getFormat() == AUDIO_FORMAT_DEFAULT)
102             ? AUDIO_FORMAT_PCM_FLOAT
103             : getFormat();
104 
105     // Setup the callback if there is one.
106     wp<AudioTrack::IAudioTrackCallback> callback;
107     // Note that TRANSFER_SYNC does not allow FAST track
108     AudioTrack::transfer_type streamTransferType = AudioTrack::transfer_type::TRANSFER_SYNC;
109     if (builder.getDataCallbackProc() != nullptr) {
110         streamTransferType = AudioTrack::transfer_type::TRANSFER_CALLBACK;
111         callback = wp<AudioTrack::IAudioTrackCallback>::fromExisting(this);
112 
113         // If the total buffer size is unspecified then base the size on the burst size.
114         if (frameCount == 0
115                 && ((flags & AUDIO_OUTPUT_FLAG_FAST) != 0)) {
116             // Take advantage of a special trick that allows us to create a buffer
117             // that is some multiple of the burst size.
118             notificationFrames = 0 - DEFAULT_BURSTS_PER_BUFFER_CAPACITY;
119         }
120     }
121     mCallbackBufferSize = builder.getFramesPerDataCallback();
122 
123     ALOGD("open(), request notificationFrames = %d, frameCount = %u",
124           notificationFrames, (uint)frameCount);
125 
126     // Don't call mAudioTrack->setDeviceId() because it will be overwritten by set()!
127     audio_port_handle_t selectedDeviceId = (getDeviceId() == AAUDIO_UNSPECIFIED)
128                                            ? AUDIO_PORT_HANDLE_NONE
129                                            : getDeviceId();
130 
131     const audio_content_type_t contentType =
132             AAudioConvert_contentTypeToInternal(builder.getContentType());
133     const audio_usage_t usage =
134             AAudioConvert_usageToInternal(builder.getUsage());
135     const audio_flags_mask_t attributesFlags =
136         AAudioConvert_allowCapturePolicyToAudioFlagsMask(builder.getAllowedCapturePolicy(),
137                                                          builder.getSpatializationBehavior(),
138                                                          builder.isContentSpatialized());
139 
140     const audio_attributes_t attributes = {
141             .content_type = contentType,
142             .usage = usage,
143             .source = AUDIO_SOURCE_DEFAULT, // only used for recording
144             .flags = attributesFlags,
145             .tags = ""
146     };
147 
148     mAudioTrack = new AudioTrack();
149     // TODO b/182392769: use attribution source util
150     mAudioTrack->set(
151             AUDIO_STREAM_DEFAULT,  // ignored because we pass attributes below
152             getSampleRate(),
153             format,
154             channelMask,
155             frameCount,
156             flags,
157             callback,
158             notificationFrames,
159             nullptr,       // DEFAULT sharedBuffer*/,
160             false,   // DEFAULT threadCanCallJava
161             sessionId,
162             streamTransferType,
163             nullptr,    // DEFAULT audio_offload_info_t
164             AttributionSourceState(), // DEFAULT uid and pid
165             &attributes,
166             // WARNING - If doNotReconnect set true then audio stops after plugging and unplugging
167             // headphones a few times.
168             false,   // DEFAULT doNotReconnect,
169             1.0f,    // DEFAULT maxRequiredSpeed
170             selectedDeviceId
171     );
172 
173     // Set it here so it can be logged by the destructor if the open failed.
174     mAudioTrack->setCallerName(kCallerName);
175 
176     // Did we get a valid track?
177     status_t status = mAudioTrack->initCheck();
178     if (status != NO_ERROR) {
179         safeReleaseClose();
180         ALOGE("open(), initCheck() returned %d", status);
181         return AAudioConvert_androidToAAudioResult(status);
182     }
183 
184     mMetricsId = std::string(AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK)
185             + std::to_string(mAudioTrack->getPortId());
186     android::mediametrics::LogItem(mMetricsId)
187             .set(AMEDIAMETRICS_PROP_PERFORMANCEMODE,
188                  AudioGlobal_convertPerformanceModeToText(builder.getPerformanceMode()))
189             .set(AMEDIAMETRICS_PROP_SHARINGMODE,
190                  AudioGlobal_convertSharingModeToText(builder.getSharingMode()))
191             .set(AMEDIAMETRICS_PROP_ENCODINGCLIENT, toString(getFormat()).c_str()).record();
192 
193     doSetVolume();
194 
195     // Get the actual values from the AudioTrack.
196     setChannelMask(AAudioConvert_androidToAAudioChannelMask(
197         mAudioTrack->channelMask(), false /*isInput*/,
198         AAudio_isChannelIndexMask(getChannelMask())));
199     setFormat(mAudioTrack->format());
200     setDeviceFormat(mAudioTrack->format());
201     setSampleRate(mAudioTrack->getSampleRate());
202     setBufferCapacity(getBufferCapacityFromDevice());
203     setFramesPerBurst(getFramesPerBurstFromDevice());
204 
205     // We may need to pass the data through a block size adapter to guarantee constant size.
206     if (mCallbackBufferSize != AAUDIO_UNSPECIFIED) {
207         // This may need to change if we add format conversion before
208         // the block size adaptation.
209         mBlockAdapterBytesPerFrame = getBytesPerFrame();
210         int callbackSizeBytes = mBlockAdapterBytesPerFrame * mCallbackBufferSize;
211         mFixedBlockReader.open(callbackSizeBytes);
212         mBlockAdapter = &mFixedBlockReader;
213     } else {
214         mBlockAdapter = nullptr;
215     }
216 
217     setDeviceId(mAudioTrack->getRoutedDeviceId());
218 
219     aaudio_session_id_t actualSessionId =
220             (requestedSessionId == AAUDIO_SESSION_ID_NONE)
221             ? AAUDIO_SESSION_ID_NONE
222             : (aaudio_session_id_t) mAudioTrack->getSessionId();
223     setSessionId(actualSessionId);
224 
225     mAudioTrack->addAudioDeviceCallback(this);
226 
227     // Update performance mode based on the actual stream flags.
228     // For example, if the sample rate is not allowed then you won't get a FAST track.
229     audio_output_flags_t actualFlags = mAudioTrack->getFlags();
230     aaudio_performance_mode_t actualPerformanceMode = AAUDIO_PERFORMANCE_MODE_NONE;
231     // We may not get the RAW flag. But as long as we get the FAST flag we can call it LOW_LATENCY.
232     if ((actualFlags & AUDIO_OUTPUT_FLAG_FAST) != 0) {
233         actualPerformanceMode = AAUDIO_PERFORMANCE_MODE_LOW_LATENCY;
234     } else if ((actualFlags & AUDIO_OUTPUT_FLAG_DEEP_BUFFER) != 0) {
235         actualPerformanceMode = AAUDIO_PERFORMANCE_MODE_POWER_SAVING;
236     }
237     setPerformanceMode(actualPerformanceMode);
238 
239     setSharingMode(AAUDIO_SHARING_MODE_SHARED); // EXCLUSIVE mode not supported in legacy
240 
241     // Log if we did not get what we asked for.
242     ALOGD_IF(actualFlags != flags,
243              "open() flags changed from 0x%08X to 0x%08X",
244              flags, actualFlags);
245     ALOGD_IF(actualPerformanceMode != perfMode,
246              "open() perfMode changed from %d to %d",
247              perfMode, actualPerformanceMode);
248 
249     if (getState() != AAUDIO_STREAM_STATE_UNINITIALIZED) {
250         ALOGE("%s - Open canceled since state = %d", __func__, getState());
251         if (getState() == AAUDIO_STREAM_STATE_DISCONNECTED)
252         {
253             ALOGE("%s - Opening while state is disconnected", __func__);
254             safeReleaseClose();
255             return AAUDIO_ERROR_DISCONNECTED;
256         }
257         safeReleaseClose();
258         return AAUDIO_ERROR_INVALID_STATE;
259     }
260 
261     setState(AAUDIO_STREAM_STATE_OPEN);
262     return AAUDIO_OK;
263 }
264 
release_l()265 aaudio_result_t AudioStreamTrack::release_l() {
266     if (getState() != AAUDIO_STREAM_STATE_CLOSING) {
267         status_t err = mAudioTrack->removeAudioDeviceCallback(this);
268         ALOGE_IF(err, "%s() removeAudioDeviceCallback returned %d", __func__, err);
269         logReleaseBufferState();
270         // Data callbacks may still be running!
271         return AudioStream::release_l();
272     } else {
273         return AAUDIO_OK; // already released
274     }
275 }
276 
close_l()277 void AudioStreamTrack::close_l() {
278     // The callbacks are normally joined in the AudioTrack destructor.
279     // But if another object has a reference to the AudioTrack then
280     // it will not get deleted here.
281     // So we should join callbacks explicitly before returning.
282     // Unlock around the join to avoid deadlocks if the callback tries to lock.
283     // This can happen if the callback returns AAUDIO_CALLBACK_RESULT_STOP
284     mStreamLock.unlock();
285     mAudioTrack->stopAndJoinCallbacks();
286     mStreamLock.lock();
287     mAudioTrack.clear();
288     // Do not close mFixedBlockReader. It has a unique_ptr to its buffer
289     // so it will clean up by itself.
290     AudioStream::close_l();
291 }
292 
293 
onNewIAudioTrack()294 void AudioStreamTrack::onNewIAudioTrack() {
295     // Stream got rerouted so we disconnect.
296     // request stream disconnect if the restored AudioTrack has properties not matching
297     // what was requested initially
298     if (mAudioTrack->channelCount() != getSamplesPerFrame()
299           || mAudioTrack->format() != getFormat()
300           || mAudioTrack->getSampleRate() != getSampleRate()
301           || mAudioTrack->getRoutedDeviceId() != getDeviceId()
302           || getBufferCapacityFromDevice() != getBufferCapacity()
303           || getFramesPerBurstFromDevice() != getFramesPerBurst()) {
304         AudioStreamLegacy::onNewIAudioTrack();
305     }
306 }
307 
requestStart_l()308 aaudio_result_t AudioStreamTrack::requestStart_l() {
309     if (mAudioTrack.get() == nullptr) {
310         ALOGE("requestStart() no AudioTrack");
311         return AAUDIO_ERROR_INVALID_STATE;
312     }
313     // Get current position so we can detect when the track is playing.
314     status_t err = mAudioTrack->getPosition(&mPositionWhenStarting);
315     if (err != OK) {
316         return AAudioConvert_androidToAAudioResult(err);
317     }
318 
319     // Enable callback before starting AudioTrack to avoid shutting
320     // down because of a race condition.
321     mCallbackEnabled.store(true);
322     aaudio_stream_state_t originalState = getState();
323     // Set before starting the callback so that we are in the correct state
324     // before updateStateMachine() can be called by the callback.
325     setState(AAUDIO_STREAM_STATE_STARTING);
326     err = mAudioTrack->start();
327     if (err != OK) {
328         mCallbackEnabled.store(false);
329         setState(originalState);
330         return AAudioConvert_androidToAAudioResult(err);
331     }
332     return AAUDIO_OK;
333 }
334 
requestPause_l()335 aaudio_result_t AudioStreamTrack::requestPause_l() {
336     if (mAudioTrack.get() == nullptr) {
337         ALOGE("%s() no AudioTrack", __func__);
338         return AAUDIO_ERROR_INVALID_STATE;
339     }
340 
341     setState(AAUDIO_STREAM_STATE_PAUSING);
342     mAudioTrack->pause();
343     mCallbackEnabled.store(false);
344     status_t err = mAudioTrack->getPosition(&mPositionWhenPausing);
345     if (err != OK) {
346         return AAudioConvert_androidToAAudioResult(err);
347     }
348     return checkForDisconnectRequest(false);
349 }
350 
requestFlush_l()351 aaudio_result_t AudioStreamTrack::requestFlush_l() {
352     if (mAudioTrack.get() == nullptr) {
353         ALOGE("%s() no AudioTrack", __func__);
354         return AAUDIO_ERROR_INVALID_STATE;
355     }
356 
357     setState(AAUDIO_STREAM_STATE_FLUSHING);
358     incrementFramesRead(getFramesWritten() - getFramesRead());
359     mAudioTrack->flush();
360     mFramesRead.reset32(); // service reads frames, service position reset on flush
361     mTimestampPosition.reset32();
362     return AAUDIO_OK;
363 }
364 
requestStop_l()365 aaudio_result_t AudioStreamTrack::requestStop_l() {
366     if (mAudioTrack.get() == nullptr) {
367         ALOGE("%s() no AudioTrack", __func__);
368         return AAUDIO_ERROR_INVALID_STATE;
369     }
370 
371     setState(AAUDIO_STREAM_STATE_STOPPING);
372     mFramesRead.catchUpTo(getFramesWritten());
373     mTimestampPosition.catchUpTo(getFramesWritten());
374     mFramesRead.reset32(); // service reads frames, service position reset on stop
375     mTimestampPosition.reset32();
376     mAudioTrack->stop();
377     mCallbackEnabled.store(false);
378     return checkForDisconnectRequest(false);;
379 }
380 
updateStateMachine()381 aaudio_result_t AudioStreamTrack::updateStateMachine()
382 {
383     status_t err;
384     aaudio_wrapping_frames_t position;
385     switch (getState()) {
386     // TODO add better state visibility to AudioTrack
387     case AAUDIO_STREAM_STATE_STARTING:
388         if (mAudioTrack->hasStarted()) {
389             setState(AAUDIO_STREAM_STATE_STARTED);
390         }
391         break;
392     case AAUDIO_STREAM_STATE_PAUSING:
393         if (mAudioTrack->stopped()) {
394             err = mAudioTrack->getPosition(&position);
395             if (err != OK) {
396                 return AAudioConvert_androidToAAudioResult(err);
397             } else if (position == mPositionWhenPausing) {
398                 // Has stream really stopped advancing?
399                 setState(AAUDIO_STREAM_STATE_PAUSED);
400             }
401             mPositionWhenPausing = position;
402         }
403         break;
404     case AAUDIO_STREAM_STATE_FLUSHING:
405         {
406             err = mAudioTrack->getPosition(&position);
407             if (err != OK) {
408                 return AAudioConvert_androidToAAudioResult(err);
409             } else if (position == 0) {
410                 // TODO Advance frames read to match written.
411                 setState(AAUDIO_STREAM_STATE_FLUSHED);
412             }
413         }
414         break;
415     case AAUDIO_STREAM_STATE_STOPPING:
416         if (mAudioTrack->stopped()) {
417             setState(AAUDIO_STREAM_STATE_STOPPED);
418         }
419         break;
420     default:
421         break;
422     }
423     return AAUDIO_OK;
424 }
425 
write(const void * buffer,int32_t numFrames,int64_t timeoutNanoseconds)426 aaudio_result_t AudioStreamTrack::write(const void *buffer,
427                                       int32_t numFrames,
428                                       int64_t timeoutNanoseconds)
429 {
430     int32_t bytesPerFrame = getBytesPerFrame();
431     int32_t numBytes;
432     aaudio_result_t result = AAudioConvert_framesToBytes(numFrames, bytesPerFrame, &numBytes);
433     if (result != AAUDIO_OK) {
434         return result;
435     }
436 
437     if (getState() == AAUDIO_STREAM_STATE_DISCONNECTED) {
438         return AAUDIO_ERROR_DISCONNECTED;
439     }
440 
441     // TODO add timeout to AudioTrack
442     bool blocking = timeoutNanoseconds > 0;
443     ssize_t bytesWritten = mAudioTrack->write(buffer, numBytes, blocking);
444     if (bytesWritten == WOULD_BLOCK) {
445         return 0;
446     } else if (bytesWritten < 0) {
447         ALOGE("invalid write, returned %d", (int)bytesWritten);
448         // in this context, a DEAD_OBJECT is more likely to be a disconnect notification due to
449         // AudioTrack invalidation
450         if (bytesWritten == DEAD_OBJECT) {
451             setState(AAUDIO_STREAM_STATE_DISCONNECTED);
452             return AAUDIO_ERROR_DISCONNECTED;
453         }
454         return AAudioConvert_androidToAAudioResult(bytesWritten);
455     }
456     int32_t framesWritten = (int32_t)(bytesWritten / bytesPerFrame);
457     incrementFramesWritten(framesWritten);
458 
459     result = updateStateMachine();
460     if (result != AAUDIO_OK) {
461         return result;
462     }
463 
464     return framesWritten;
465 }
466 
setBufferSize(int32_t requestedFrames)467 aaudio_result_t AudioStreamTrack::setBufferSize(int32_t requestedFrames)
468 {
469     // Do not ask for less than one burst.
470     if (requestedFrames < getFramesPerBurst()) {
471         requestedFrames = getFramesPerBurst();
472     }
473     ssize_t result = mAudioTrack->setBufferSizeInFrames(requestedFrames);
474     if (result < 0) {
475         return AAudioConvert_androidToAAudioResult(result);
476     } else {
477         return result;
478     }
479 }
480 
getBufferSize() const481 int32_t AudioStreamTrack::getBufferSize() const
482 {
483     return static_cast<int32_t>(mAudioTrack->getBufferSizeInFrames());
484 }
485 
getBufferCapacityFromDevice() const486 int32_t AudioStreamTrack::getBufferCapacityFromDevice() const
487 {
488     return static_cast<int32_t>(mAudioTrack->frameCount());
489 }
490 
getXRunCount() const491 int32_t AudioStreamTrack::getXRunCount() const
492 {
493     return static_cast<int32_t>(mAudioTrack->getUnderrunCount());
494 }
495 
getFramesPerBurstFromDevice() const496 int32_t AudioStreamTrack::getFramesPerBurstFromDevice() const {
497     return static_cast<int32_t>(mAudioTrack->getNotificationPeriodInFrames());
498 }
499 
getFramesRead()500 int64_t AudioStreamTrack::getFramesRead() {
501     aaudio_wrapping_frames_t position;
502     status_t result;
503     switch (getState()) {
504     case AAUDIO_STREAM_STATE_STARTING:
505     case AAUDIO_STREAM_STATE_STARTED:
506     case AAUDIO_STREAM_STATE_STOPPING:
507     case AAUDIO_STREAM_STATE_PAUSING:
508     case AAUDIO_STREAM_STATE_PAUSED:
509         result = mAudioTrack->getPosition(&position);
510         if (result == OK) {
511             mFramesRead.update32((int32_t)position);
512         }
513         break;
514     default:
515         break;
516     }
517     return AudioStreamLegacy::getFramesRead();
518 }
519 
getTimestamp(clockid_t clockId,int64_t * framePosition,int64_t * timeNanoseconds)520 aaudio_result_t AudioStreamTrack::getTimestamp(clockid_t clockId,
521                                      int64_t *framePosition,
522                                      int64_t *timeNanoseconds) {
523     ExtendedTimestamp extendedTimestamp;
524     status_t status = mAudioTrack->getTimestamp(&extendedTimestamp);
525     if (status == WOULD_BLOCK) {
526         return AAUDIO_ERROR_INVALID_STATE;
527     } if (status != NO_ERROR) {
528         return AAudioConvert_androidToAAudioResult(status);
529     }
530     int64_t position = 0;
531     int64_t nanoseconds = 0;
532     aaudio_result_t result = getBestTimestamp(clockId, &position,
533                                               &nanoseconds, &extendedTimestamp);
534     if (result == AAUDIO_OK) {
535         if (position < getFramesWritten()) {
536             *framePosition = position;
537             *timeNanoseconds = nanoseconds;
538             return result;
539         } else {
540             return AAUDIO_ERROR_INVALID_STATE; // TODO review, documented but not consistent
541         }
542     }
543     return result;
544 }
545 
doSetVolume()546 status_t AudioStreamTrack::doSetVolume() {
547     status_t status = NO_INIT;
548     if (mAudioTrack.get() != nullptr) {
549         float volume = getDuckAndMuteVolume();
550         mAudioTrack->setVolume(volume, volume);
551         status = NO_ERROR;
552     }
553     return status;
554 }
555 
556 #if AAUDIO_USE_VOLUME_SHAPER
557 
558 using namespace android::media::VolumeShaper;
559 
applyVolumeShaper(const VolumeShaper::Configuration & configuration,const VolumeShaper::Operation & operation)560 binder::Status AudioStreamTrack::applyVolumeShaper(
561         const VolumeShaper::Configuration& configuration,
562         const VolumeShaper::Operation& operation) {
563 
564     sp<VolumeShaper::Configuration> spConfiguration = new VolumeShaper::Configuration(configuration);
565     sp<VolumeShaper::Operation> spOperation = new VolumeShaper::Operation(operation);
566 
567     if (mAudioTrack.get() != nullptr) {
568         ALOGD("applyVolumeShaper() from IPlayer");
569         binder::Status status = mAudioTrack->applyVolumeShaper(spConfiguration, spOperation);
570         if (status < 0) { // a non-negative value is the volume shaper id.
571             ALOGE("applyVolumeShaper() failed with status %d", status);
572         }
573         return aidl_utils::binderStatusFromStatusT(status);
574     } else {
575         ALOGD("applyVolumeShaper()"
576                       " no AudioTrack for volume control from IPlayer");
577         return binder::Status::ok();
578     }
579 }
580 #endif
581