Loading media/java/android/media/SoundPool.java +2 −2 Original line number Diff line number Diff line Loading @@ -311,7 +311,7 @@ public class SoundPool extends PlayerBase { int priority, int loop, float rate) { // FIXME: b/174876164 implement device id for soundpool baseStart(0); return _play(soundID, leftVolume, rightVolume, priority, loop, rate); return _play(soundID, leftVolume, rightVolume, priority, loop, rate, getPlayerIId()); } /** Loading Loading @@ -512,7 +512,7 @@ public class SoundPool extends PlayerBase { @NonNull Object/*AudioAttributes*/ attributes, @NonNull String opPackageName); private native final int _play(int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate); int priority, int loop, float rate, int playerIId); private native final void _setVolume(int streamID, float leftVolume, float rightVolume); Loading media/jni/soundpool/SoundPool.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ bool SoundPool::unload(int32_t soundID) } int32_t SoundPool::play(int32_t soundID, float leftVolume, float rightVolume, int32_t priority, int32_t loop, float rate) int32_t priority, int32_t loop, float rate, int32_t playerIId) { ALOGV("%s(soundID=%d, leftVolume=%f, rightVolume=%f, priority=%d, loop=%d, rate=%f)", __func__, soundID, leftVolume, rightVolume, priority, loop, rate); Loading @@ -136,8 +136,9 @@ int32_t SoundPool::play(int32_t soundID, float leftVolume, float rightVolume, } const int32_t streamID = mStreamManager.queueForPlay( sound, soundID, leftVolume, rightVolume, priority, loop, rate); sound, soundID, leftVolume, rightVolume, priority, loop, rate, playerIId); ALOGV("%s returned %d", __func__, streamID); return streamID; } Loading media/jni/soundpool/SoundPool.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: int32_t load(int fd, int64_t offset, int64_t length, int32_t priority); bool unload(int32_t soundID); int32_t play(int32_t soundID, float leftVolume, float rightVolume, int32_t priority, int32_t loop, float rate); int32_t loop, float rate, int32_t playerIId = PLAYER_PIID_INVALID); void pause(int32_t streamID); void autoPause(); void resume(int32_t streamID); Loading media/jni/soundpool/Stream.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -229,7 +229,7 @@ Stream* Stream::getPairStream() const return mStreamManager->getPairStream(this); } Stream* Stream::playPairStream(std::vector<std::any>& garbage) { Stream* Stream::playPairStream(std::vector<std::any>& garbage, int32_t playerIId) { Stream* pairStream = getPairStream(); LOG_ALWAYS_FATAL_IF(pairStream == nullptr, "No pair stream!"); { Loading Loading @@ -260,7 +260,7 @@ Stream* Stream::playPairStream(std::vector<std::any>& garbage) { const int pairState = pairStream->mState; pairStream->play_l(pairStream->mSound, pairStream->mStreamID, pairStream->mLeftVolume, pairStream->mRightVolume, pairStream->mPriority, pairStream->mLoop, pairStream->mRate, garbage); pairStream->mLoop, pairStream->mRate, garbage, playerIId); if (pairStream->mState == IDLE) { return nullptr; // AudioTrack error } Loading @@ -274,12 +274,12 @@ Stream* Stream::playPairStream(std::vector<std::any>& garbage) { void Stream::play_l(const std::shared_ptr<Sound>& sound, int32_t nextStreamID, float leftVolume, float rightVolume, int32_t priority, int32_t loop, float rate, std::vector<std::any>& garbage) std::vector<std::any>& garbage, int32_t playerIId) { ALOGV("%s(%p)(soundID=%d, streamID=%d, leftVolume=%f, rightVolume=%f," " priority=%d, loop=%d, rate=%f)", " priority=%d, loop=%d, rate=%f, playerIId=%d)", __func__, this, sound->getSoundID(), nextStreamID, leftVolume, rightVolume, priority, loop, rate); priority, loop, rate, playerIId); // initialize track const audio_stream_type_t streamType = Loading Loading @@ -340,6 +340,10 @@ void Stream::play_l(const std::shared_ptr<Sound>& sound, int32_t nextStreamID, // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_SOUNDPOOL mAudioTrack->setCallerName("soundpool"); if (playerIId != PLAYER_PIID_INVALID) { mAudioTrack->setPlayerIId(playerIId); } if (status_t status = mAudioTrack->initCheck(); status != NO_ERROR) { ALOGE("%s: error %d creating AudioTrack", __func__, status); Loading Loading @@ -379,6 +383,7 @@ int Stream::getCorrespondingStreamID() { std::lock_guard lock(mLock); return static_cast<int>(mAudioTrack ? mStreamID : getPairStream()->mStreamID); } size_t Stream::StreamCallback::onMoreData(const AudioTrack::Buffer&) { ALOGW("%s streamID %d Unexpected EVENT_MORE_DATA for static track", __func__, mStream->getCorrespondingStreamID()); Loading media/jni/soundpool/Stream.h +3 −2 Original line number Diff line number Diff line Loading @@ -93,7 +93,8 @@ public: // returns the pair stream if successful, nullptr otherwise. // garbage is used to release tracks and data outside of any lock. Stream* playPairStream(std::vector<std::any>& garbage); Stream* playPairStream(std::vector<std::any>& garbage, int32_t playerIId = PLAYER_PIID_INVALID); // These parameters are explicitly checked in the SoundPool class // so never deviate from the Java API specified values. Loading Loading @@ -157,7 +158,7 @@ private: // garbage is used to release tracks and data outside of any lock. void play_l(const std::shared_ptr<Sound>& sound, int streamID, float leftVolume, float rightVolume, int priority, int loop, float rate, std::vector<std::any>& garbage) REQUIRES(mLock); std::vector<std::any>& garbage, int playerIId) REQUIRES(mLock); void stop_l() REQUIRES(mLock); void setVolume_l(float leftVolume, float rightVolume) REQUIRES(mLock); Loading Loading
media/java/android/media/SoundPool.java +2 −2 Original line number Diff line number Diff line Loading @@ -311,7 +311,7 @@ public class SoundPool extends PlayerBase { int priority, int loop, float rate) { // FIXME: b/174876164 implement device id for soundpool baseStart(0); return _play(soundID, leftVolume, rightVolume, priority, loop, rate); return _play(soundID, leftVolume, rightVolume, priority, loop, rate, getPlayerIId()); } /** Loading Loading @@ -512,7 +512,7 @@ public class SoundPool extends PlayerBase { @NonNull Object/*AudioAttributes*/ attributes, @NonNull String opPackageName); private native final int _play(int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate); int priority, int loop, float rate, int playerIId); private native final void _setVolume(int streamID, float leftVolume, float rightVolume); Loading
media/jni/soundpool/SoundPool.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ bool SoundPool::unload(int32_t soundID) } int32_t SoundPool::play(int32_t soundID, float leftVolume, float rightVolume, int32_t priority, int32_t loop, float rate) int32_t priority, int32_t loop, float rate, int32_t playerIId) { ALOGV("%s(soundID=%d, leftVolume=%f, rightVolume=%f, priority=%d, loop=%d, rate=%f)", __func__, soundID, leftVolume, rightVolume, priority, loop, rate); Loading @@ -136,8 +136,9 @@ int32_t SoundPool::play(int32_t soundID, float leftVolume, float rightVolume, } const int32_t streamID = mStreamManager.queueForPlay( sound, soundID, leftVolume, rightVolume, priority, loop, rate); sound, soundID, leftVolume, rightVolume, priority, loop, rate, playerIId); ALOGV("%s returned %d", __func__, streamID); return streamID; } Loading
media/jni/soundpool/SoundPool.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: int32_t load(int fd, int64_t offset, int64_t length, int32_t priority); bool unload(int32_t soundID); int32_t play(int32_t soundID, float leftVolume, float rightVolume, int32_t priority, int32_t loop, float rate); int32_t loop, float rate, int32_t playerIId = PLAYER_PIID_INVALID); void pause(int32_t streamID); void autoPause(); void resume(int32_t streamID); Loading
media/jni/soundpool/Stream.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -229,7 +229,7 @@ Stream* Stream::getPairStream() const return mStreamManager->getPairStream(this); } Stream* Stream::playPairStream(std::vector<std::any>& garbage) { Stream* Stream::playPairStream(std::vector<std::any>& garbage, int32_t playerIId) { Stream* pairStream = getPairStream(); LOG_ALWAYS_FATAL_IF(pairStream == nullptr, "No pair stream!"); { Loading Loading @@ -260,7 +260,7 @@ Stream* Stream::playPairStream(std::vector<std::any>& garbage) { const int pairState = pairStream->mState; pairStream->play_l(pairStream->mSound, pairStream->mStreamID, pairStream->mLeftVolume, pairStream->mRightVolume, pairStream->mPriority, pairStream->mLoop, pairStream->mRate, garbage); pairStream->mLoop, pairStream->mRate, garbage, playerIId); if (pairStream->mState == IDLE) { return nullptr; // AudioTrack error } Loading @@ -274,12 +274,12 @@ Stream* Stream::playPairStream(std::vector<std::any>& garbage) { void Stream::play_l(const std::shared_ptr<Sound>& sound, int32_t nextStreamID, float leftVolume, float rightVolume, int32_t priority, int32_t loop, float rate, std::vector<std::any>& garbage) std::vector<std::any>& garbage, int32_t playerIId) { ALOGV("%s(%p)(soundID=%d, streamID=%d, leftVolume=%f, rightVolume=%f," " priority=%d, loop=%d, rate=%f)", " priority=%d, loop=%d, rate=%f, playerIId=%d)", __func__, this, sound->getSoundID(), nextStreamID, leftVolume, rightVolume, priority, loop, rate); priority, loop, rate, playerIId); // initialize track const audio_stream_type_t streamType = Loading Loading @@ -340,6 +340,10 @@ void Stream::play_l(const std::shared_ptr<Sound>& sound, int32_t nextStreamID, // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_SOUNDPOOL mAudioTrack->setCallerName("soundpool"); if (playerIId != PLAYER_PIID_INVALID) { mAudioTrack->setPlayerIId(playerIId); } if (status_t status = mAudioTrack->initCheck(); status != NO_ERROR) { ALOGE("%s: error %d creating AudioTrack", __func__, status); Loading Loading @@ -379,6 +383,7 @@ int Stream::getCorrespondingStreamID() { std::lock_guard lock(mLock); return static_cast<int>(mAudioTrack ? mStreamID : getPairStream()->mStreamID); } size_t Stream::StreamCallback::onMoreData(const AudioTrack::Buffer&) { ALOGW("%s streamID %d Unexpected EVENT_MORE_DATA for static track", __func__, mStream->getCorrespondingStreamID()); Loading
media/jni/soundpool/Stream.h +3 −2 Original line number Diff line number Diff line Loading @@ -93,7 +93,8 @@ public: // returns the pair stream if successful, nullptr otherwise. // garbage is used to release tracks and data outside of any lock. Stream* playPairStream(std::vector<std::any>& garbage); Stream* playPairStream(std::vector<std::any>& garbage, int32_t playerIId = PLAYER_PIID_INVALID); // These parameters are explicitly checked in the SoundPool class // so never deviate from the Java API specified values. Loading Loading @@ -157,7 +158,7 @@ private: // garbage is used to release tracks and data outside of any lock. void play_l(const std::shared_ptr<Sound>& sound, int streamID, float leftVolume, float rightVolume, int priority, int loop, float rate, std::vector<std::any>& garbage) REQUIRES(mLock); std::vector<std::any>& garbage, int playerIId) REQUIRES(mLock); void stop_l() REQUIRES(mLock); void setVolume_l(float leftVolume, float rightVolume) REQUIRES(mLock); Loading