Loading media/libaaudio/src/client/AudioStreamInternalPlay.h +0 −3 Original line number Diff line number Diff line Loading @@ -50,9 +50,6 @@ public: return AAUDIO_DIRECTION_OUTPUT; } // Only register client side streams. bool needsSystemRegistration() override { return !mInService; } protected: aaudio_result_t requestPauseInternal(); Loading media/libaaudio/src/core/AAudioAudio.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -219,7 +219,7 @@ AAUDIO_API aaudio_result_t AAudioStreamBuilder_openStream(AAudioStreamBuilder* ALOGD("AAudioStreamBuilder_openStream() returns %d = %s for (%p) ----------------", result, AAudio_convertResultToText(result), audioStream); if (result == AAUDIO_OK) { audioStream->systemRegister(); audioStream->registerPlayerBase(); *streamPtr = (AAudioStream*) audioStream; } else { *streamPtr = nullptr; Loading @@ -243,7 +243,7 @@ AAUDIO_API aaudio_result_t AAudioStream_close(AAudioStream* stream) ALOGD("AAudioStream_close(%p)", stream); if (audioStream != nullptr) { audioStream->close(); audioStream->systemUnRegister(); audioStream->unregisterPlayerBase(); delete audioStream; return AAUDIO_OK; } Loading media/libaaudio/src/core/AudioStream.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ AudioStream::~AudioStream() { || getState() == AAUDIO_STREAM_STATE_DISCONNECTED), "aaudio stream still in use, state = %s", AAudio_convertStreamStateToText(getState())); mPlayerBase->clearParentReference(); // remove reference to this AudioStream } static const char *AudioStream_convertSharingModeToShortText(aaudio_sharing_mode_t sharingMode) { Loading Loading @@ -197,3 +199,38 @@ aaudio_result_t AudioStream::joinThread(void** returnArg, int64_t timeoutNanosec return err ? AAudioConvert_androidToAAudioResult(-errno) : mThreadRegistrationResult; } #if AAUDIO_USE_VOLUME_SHAPER android::media::VolumeShaper::Status AudioStream::applyVolumeShaper( const android::media::VolumeShaper::Configuration& configuration __unused, const android::media::VolumeShaper::Operation& operation __unused) { ALOGW("applyVolumeShaper() is not supported"); return android::media::VolumeShaper::Status::ok(); } #endif AudioStream::MyPlayerBase::MyPlayerBase(AudioStream *parent) : mParent(parent) { } AudioStream::MyPlayerBase::~MyPlayerBase() { ALOGV("MyPlayerBase::~MyPlayerBase(%p) deleted", this); } void AudioStream::MyPlayerBase::registerWithAudioManager() { if (!mRegistered) { init(android::PLAYER_TYPE_AAUDIO, AUDIO_USAGE_MEDIA); mRegistered = true; } } void AudioStream::MyPlayerBase::unregisterWithAudioManager() { if (mRegistered) { baseDestroy(); mRegistered = false; } } void AudioStream::MyPlayerBase::destroy() { unregisterWithAudioManager(); } media/libaaudio/src/core/AudioStream.h +45 −35 Original line number Diff line number Diff line Loading @@ -256,29 +256,29 @@ public: virtual android::status_t doSetVolume() { return android::NO_ERROR; } #if AAUDIO_USE_VOLUME_SHAPER virtual android::binder::Status applyVolumeShaper( virtual ::android::binder::Status applyVolumeShaper( const ::android::media::VolumeShaper::Configuration& configuration __unused, const ::android::media::VolumeShaper::Operation& operation __unused) { ALOGW("applyVolumeShaper() is not supported"); return android::binder::Status::ok(); } const ::android::media::VolumeShaper::Operation& operation __unused); #endif // Should this object be registered with the AudioManager? virtual bool needsSystemRegistration() { return false; } // Register this stream's PlayerBase with the AudioManager void systemRegister() { if (needsSystemRegistration()) { /** * Register this stream's PlayerBase with the AudioManager if needed. * Only register output streams. * This should only be called for client streams and not for streams * that run in the service. */ void registerPlayerBase() { if (getDirection() == AAUDIO_DIRECTION_OUTPUT) { mPlayerBase->registerWithAudioManager(); } } // UnRegister this stream's PlayerBase with the AudioManager void systemUnRegister() { if (needsSystemRegistration()) { mPlayerBase->destroy(); } /** * Unregister this stream's PlayerBase with the AudioManager. * This will only unregister if already registered. */ void unregisterPlayerBase() { mPlayerBase->unregisterWithAudioManager(); } // Pass start request through PlayerBase for tracking. Loading Loading @@ -308,43 +308,53 @@ protected: // ------ AudioManager ------- class MyPlayerBase : public android::PlayerBase { public: MyPlayerBase(AudioStream *parent) : mParent(parent) {} virtual ~MyPlayerBase() {} explicit MyPlayerBase(AudioStream *parent); void registerWithAudioManager() { init(android::PLAYER_TYPE_AAUDIO, AUDIO_USAGE_MEDIA); } virtual ~MyPlayerBase(); void destroy() override { // FIXME what else should this do? close()? disconnect()? baseDestroy(); } /** * Register for volume changes and remote control. */ void registerWithAudioManager(); virtual android::status_t playerStart() { /** * UnRegister. */ void unregisterWithAudioManager(); /** * Just calls unregisterWithAudioManager(). */ void destroy() override; void clearParentReference() { mParent = nullptr; } android::status_t playerStart() override { // mParent should NOT be null. So go ahead and crash if it is. mResult = mParent->requestStart(); return AAudioConvert_aaudioToAndroidStatus(mResult); } virtual android::status_t playerPause() { android::status_t playerPause() override { mResult = mParent->requestPause(); return AAudioConvert_aaudioToAndroidStatus(mResult); } virtual android::status_t playerStop() { android::status_t playerStop() override { mResult = mParent->requestStop(); return AAudioConvert_aaudioToAndroidStatus(mResult); } virtual android::status_t playerSetVolume() { android::status_t playerSetVolume() override { // No pan and only left volume is taken into account from IPLayer interface mParent->setDuckAndMuteVolume(mVolumeMultiplierL /* * mPanMultiplierL */); return android::NO_ERROR; } #if AAUDIO_USE_VOLUME_SHAPER android::binder::Status applyVolumeShaper( const android::media::VolumeShaper::Configuration& configuration, const android::media::VolumeShaper::Operation& operation) { ::android::binder::Status applyVolumeShaper( const ::android::media::VolumeShaper::Configuration& configuration, const ::android::media::VolumeShaper::Operation& operation) { return mParent->applyVolumeShaper(configuration, operation); } #endif Loading @@ -353,12 +363,12 @@ protected: return mResult; } private: AudioStream *mParent; aaudio_result_t mResult = AAUDIO_OK; bool mRegistered = false; }; /** * This should not be called after the open() call. */ Loading media/libaaudio/src/legacy/AudioStreamTrack.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -478,6 +478,9 @@ status_t AudioStreamTrack::doSetVolume() { } #if AAUDIO_USE_VOLUME_SHAPER using namespace android::media::VolumeShaper; binder::Status AudioStreamTrack::applyVolumeShaper( const VolumeShaper::Configuration& configuration, const VolumeShaper::Operation& operation) { Loading @@ -487,7 +490,7 @@ binder::Status AudioStreamTrack::applyVolumeShaper( if (mAudioTrack.get() != nullptr) { ALOGD("applyVolumeShaper() from IPlayer"); VolumeShaper::Status status = mAudioTrack->applyVolumeShaper(spConfiguration, spOperation); binder::Status status = mAudioTrack->applyVolumeShaper(spConfiguration, spOperation); if (status < 0) { // a non-negative value is the volume shaper id. ALOGE("applyVolumeShaper() failed with status %d", status); } Loading Loading
media/libaaudio/src/client/AudioStreamInternalPlay.h +0 −3 Original line number Diff line number Diff line Loading @@ -50,9 +50,6 @@ public: return AAUDIO_DIRECTION_OUTPUT; } // Only register client side streams. bool needsSystemRegistration() override { return !mInService; } protected: aaudio_result_t requestPauseInternal(); Loading
media/libaaudio/src/core/AAudioAudio.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -219,7 +219,7 @@ AAUDIO_API aaudio_result_t AAudioStreamBuilder_openStream(AAudioStreamBuilder* ALOGD("AAudioStreamBuilder_openStream() returns %d = %s for (%p) ----------------", result, AAudio_convertResultToText(result), audioStream); if (result == AAUDIO_OK) { audioStream->systemRegister(); audioStream->registerPlayerBase(); *streamPtr = (AAudioStream*) audioStream; } else { *streamPtr = nullptr; Loading @@ -243,7 +243,7 @@ AAUDIO_API aaudio_result_t AAudioStream_close(AAudioStream* stream) ALOGD("AAudioStream_close(%p)", stream); if (audioStream != nullptr) { audioStream->close(); audioStream->systemUnRegister(); audioStream->unregisterPlayerBase(); delete audioStream; return AAUDIO_OK; } Loading
media/libaaudio/src/core/AudioStream.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ AudioStream::~AudioStream() { || getState() == AAUDIO_STREAM_STATE_DISCONNECTED), "aaudio stream still in use, state = %s", AAudio_convertStreamStateToText(getState())); mPlayerBase->clearParentReference(); // remove reference to this AudioStream } static const char *AudioStream_convertSharingModeToShortText(aaudio_sharing_mode_t sharingMode) { Loading Loading @@ -197,3 +199,38 @@ aaudio_result_t AudioStream::joinThread(void** returnArg, int64_t timeoutNanosec return err ? AAudioConvert_androidToAAudioResult(-errno) : mThreadRegistrationResult; } #if AAUDIO_USE_VOLUME_SHAPER android::media::VolumeShaper::Status AudioStream::applyVolumeShaper( const android::media::VolumeShaper::Configuration& configuration __unused, const android::media::VolumeShaper::Operation& operation __unused) { ALOGW("applyVolumeShaper() is not supported"); return android::media::VolumeShaper::Status::ok(); } #endif AudioStream::MyPlayerBase::MyPlayerBase(AudioStream *parent) : mParent(parent) { } AudioStream::MyPlayerBase::~MyPlayerBase() { ALOGV("MyPlayerBase::~MyPlayerBase(%p) deleted", this); } void AudioStream::MyPlayerBase::registerWithAudioManager() { if (!mRegistered) { init(android::PLAYER_TYPE_AAUDIO, AUDIO_USAGE_MEDIA); mRegistered = true; } } void AudioStream::MyPlayerBase::unregisterWithAudioManager() { if (mRegistered) { baseDestroy(); mRegistered = false; } } void AudioStream::MyPlayerBase::destroy() { unregisterWithAudioManager(); }
media/libaaudio/src/core/AudioStream.h +45 −35 Original line number Diff line number Diff line Loading @@ -256,29 +256,29 @@ public: virtual android::status_t doSetVolume() { return android::NO_ERROR; } #if AAUDIO_USE_VOLUME_SHAPER virtual android::binder::Status applyVolumeShaper( virtual ::android::binder::Status applyVolumeShaper( const ::android::media::VolumeShaper::Configuration& configuration __unused, const ::android::media::VolumeShaper::Operation& operation __unused) { ALOGW("applyVolumeShaper() is not supported"); return android::binder::Status::ok(); } const ::android::media::VolumeShaper::Operation& operation __unused); #endif // Should this object be registered with the AudioManager? virtual bool needsSystemRegistration() { return false; } // Register this stream's PlayerBase with the AudioManager void systemRegister() { if (needsSystemRegistration()) { /** * Register this stream's PlayerBase with the AudioManager if needed. * Only register output streams. * This should only be called for client streams and not for streams * that run in the service. */ void registerPlayerBase() { if (getDirection() == AAUDIO_DIRECTION_OUTPUT) { mPlayerBase->registerWithAudioManager(); } } // UnRegister this stream's PlayerBase with the AudioManager void systemUnRegister() { if (needsSystemRegistration()) { mPlayerBase->destroy(); } /** * Unregister this stream's PlayerBase with the AudioManager. * This will only unregister if already registered. */ void unregisterPlayerBase() { mPlayerBase->unregisterWithAudioManager(); } // Pass start request through PlayerBase for tracking. Loading Loading @@ -308,43 +308,53 @@ protected: // ------ AudioManager ------- class MyPlayerBase : public android::PlayerBase { public: MyPlayerBase(AudioStream *parent) : mParent(parent) {} virtual ~MyPlayerBase() {} explicit MyPlayerBase(AudioStream *parent); void registerWithAudioManager() { init(android::PLAYER_TYPE_AAUDIO, AUDIO_USAGE_MEDIA); } virtual ~MyPlayerBase(); void destroy() override { // FIXME what else should this do? close()? disconnect()? baseDestroy(); } /** * Register for volume changes and remote control. */ void registerWithAudioManager(); virtual android::status_t playerStart() { /** * UnRegister. */ void unregisterWithAudioManager(); /** * Just calls unregisterWithAudioManager(). */ void destroy() override; void clearParentReference() { mParent = nullptr; } android::status_t playerStart() override { // mParent should NOT be null. So go ahead and crash if it is. mResult = mParent->requestStart(); return AAudioConvert_aaudioToAndroidStatus(mResult); } virtual android::status_t playerPause() { android::status_t playerPause() override { mResult = mParent->requestPause(); return AAudioConvert_aaudioToAndroidStatus(mResult); } virtual android::status_t playerStop() { android::status_t playerStop() override { mResult = mParent->requestStop(); return AAudioConvert_aaudioToAndroidStatus(mResult); } virtual android::status_t playerSetVolume() { android::status_t playerSetVolume() override { // No pan and only left volume is taken into account from IPLayer interface mParent->setDuckAndMuteVolume(mVolumeMultiplierL /* * mPanMultiplierL */); return android::NO_ERROR; } #if AAUDIO_USE_VOLUME_SHAPER android::binder::Status applyVolumeShaper( const android::media::VolumeShaper::Configuration& configuration, const android::media::VolumeShaper::Operation& operation) { ::android::binder::Status applyVolumeShaper( const ::android::media::VolumeShaper::Configuration& configuration, const ::android::media::VolumeShaper::Operation& operation) { return mParent->applyVolumeShaper(configuration, operation); } #endif Loading @@ -353,12 +363,12 @@ protected: return mResult; } private: AudioStream *mParent; aaudio_result_t mResult = AAUDIO_OK; bool mRegistered = false; }; /** * This should not be called after the open() call. */ Loading
media/libaaudio/src/legacy/AudioStreamTrack.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -478,6 +478,9 @@ status_t AudioStreamTrack::doSetVolume() { } #if AAUDIO_USE_VOLUME_SHAPER using namespace android::media::VolumeShaper; binder::Status AudioStreamTrack::applyVolumeShaper( const VolumeShaper::Configuration& configuration, const VolumeShaper::Operation& operation) { Loading @@ -487,7 +490,7 @@ binder::Status AudioStreamTrack::applyVolumeShaper( if (mAudioTrack.get() != nullptr) { ALOGD("applyVolumeShaper() from IPlayer"); VolumeShaper::Status status = mAudioTrack->applyVolumeShaper(spConfiguration, spOperation); binder::Status status = mAudioTrack->applyVolumeShaper(spConfiguration, spOperation); if (status < 0) { // a non-negative value is the volume shaper id. ALOGE("applyVolumeShaper() failed with status %d", status); } Loading