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