Loading media/java/android/media/SoundPool.java +3 −2 Original line number Diff line number Diff line Loading @@ -149,7 +149,8 @@ public class SoundPool extends PlayerBase { super(attributes, AudioPlaybackConfiguration.PLAYER_TYPE_JAM_SOUNDPOOL); // do native setup if (native_setup(new WeakReference<SoundPool>(this), maxStreams, attributes) != 0) { if (native_setup(new WeakReference<SoundPool>(this), maxStreams, attributes, getCurrentOpPackageName()) != 0) { throw new RuntimeException("Native setup failed"); } mAttributes = attributes; Loading Loading @@ -501,7 +502,7 @@ public class SoundPool extends PlayerBase { private native final int _load(FileDescriptor fd, long offset, long length, int priority); private native final int native_setup(Object weakRef, int maxStreams, Object/*AudioAttributes*/ attributes); @NonNull Object/*AudioAttributes*/ attributes, @NonNull String opPackageName); private native final int _play(int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate); Loading media/jni/soundpool/SoundPool.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -84,8 +84,9 @@ bool checkLoop(int32_t *loop) } // namespace SoundPool::SoundPool(int32_t maxStreams, const audio_attributes_t* attributes) : mStreamManager(maxStreams, kStreamManagerThreads, attributes) SoundPool::SoundPool( int32_t maxStreams, const audio_attributes_t* attributes, const std::string& opPackageName) : mStreamManager(maxStreams, kStreamManagerThreads, attributes, opPackageName) { ALOGV("%s(maxStreams=%d, attr={ content_type=%d, usage=%d, flags=0x%x, tags=%s })", __func__, maxStreams, Loading media/jni/soundpool/SoundPool.h +4 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include "SoundManager.h" #include "StreamManager.h" #include <string> namespace android { /** Loading @@ -29,7 +31,8 @@ namespace android { */ class SoundPool { public: SoundPool(int32_t maxStreams, const audio_attributes_t* attributes); SoundPool(int32_t maxStreams, const audio_attributes_t* attributes, const std::string& opPackageName = {}); ~SoundPool(); // SoundPool Java API support Loading media/jni/soundpool/Stream.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -332,7 +332,9 @@ void Stream::play_l(const std::shared_ptr<Sound>& sound, int32_t nextStreamID, 0 /*default notification frames*/, AUDIO_SESSION_ALLOCATE, AudioTrack::TRANSFER_DEFAULT, nullptr /*offloadInfo*/, -1 /*uid*/, -1 /*pid*/, mStreamManager->getAttributes()); mStreamManager->getAttributes(), false /*doNotReconnect*/, 1.0f /*maxRequiredSpeed*/, mStreamManager->getOpPackageName()); // Set caller name so it can be logged in destructor. // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_SOUNDPOOL newTrack->setCallerName("soundpool"); Loading media/jni/soundpool/StreamManager.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -98,9 +98,11 @@ int32_t StreamMap::getNextIdForStream(Stream* stream) const { #pragma clang diagnostic ignored "-Wthread-safety-analysis" StreamManager::StreamManager( int32_t streams, size_t threads, const audio_attributes_t* attributes) int32_t streams, size_t threads, const audio_attributes_t* attributes, std::string opPackageName) : StreamMap(streams) , mAttributes(*attributes) , mOpPackageName(std::move(opPackageName)) { ALOGV("%s(%d, %zu, ...)", __func__, streams, threads); forEach([this](Stream *stream) { Loading Loading
media/java/android/media/SoundPool.java +3 −2 Original line number Diff line number Diff line Loading @@ -149,7 +149,8 @@ public class SoundPool extends PlayerBase { super(attributes, AudioPlaybackConfiguration.PLAYER_TYPE_JAM_SOUNDPOOL); // do native setup if (native_setup(new WeakReference<SoundPool>(this), maxStreams, attributes) != 0) { if (native_setup(new WeakReference<SoundPool>(this), maxStreams, attributes, getCurrentOpPackageName()) != 0) { throw new RuntimeException("Native setup failed"); } mAttributes = attributes; Loading Loading @@ -501,7 +502,7 @@ public class SoundPool extends PlayerBase { private native final int _load(FileDescriptor fd, long offset, long length, int priority); private native final int native_setup(Object weakRef, int maxStreams, Object/*AudioAttributes*/ attributes); @NonNull Object/*AudioAttributes*/ attributes, @NonNull String opPackageName); private native final int _play(int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate); Loading
media/jni/soundpool/SoundPool.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -84,8 +84,9 @@ bool checkLoop(int32_t *loop) } // namespace SoundPool::SoundPool(int32_t maxStreams, const audio_attributes_t* attributes) : mStreamManager(maxStreams, kStreamManagerThreads, attributes) SoundPool::SoundPool( int32_t maxStreams, const audio_attributes_t* attributes, const std::string& opPackageName) : mStreamManager(maxStreams, kStreamManagerThreads, attributes, opPackageName) { ALOGV("%s(maxStreams=%d, attr={ content_type=%d, usage=%d, flags=0x%x, tags=%s })", __func__, maxStreams, Loading
media/jni/soundpool/SoundPool.h +4 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include "SoundManager.h" #include "StreamManager.h" #include <string> namespace android { /** Loading @@ -29,7 +31,8 @@ namespace android { */ class SoundPool { public: SoundPool(int32_t maxStreams, const audio_attributes_t* attributes); SoundPool(int32_t maxStreams, const audio_attributes_t* attributes, const std::string& opPackageName = {}); ~SoundPool(); // SoundPool Java API support Loading
media/jni/soundpool/Stream.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -332,7 +332,9 @@ void Stream::play_l(const std::shared_ptr<Sound>& sound, int32_t nextStreamID, 0 /*default notification frames*/, AUDIO_SESSION_ALLOCATE, AudioTrack::TRANSFER_DEFAULT, nullptr /*offloadInfo*/, -1 /*uid*/, -1 /*pid*/, mStreamManager->getAttributes()); mStreamManager->getAttributes(), false /*doNotReconnect*/, 1.0f /*maxRequiredSpeed*/, mStreamManager->getOpPackageName()); // Set caller name so it can be logged in destructor. // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_SOUNDPOOL newTrack->setCallerName("soundpool"); Loading
media/jni/soundpool/StreamManager.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -98,9 +98,11 @@ int32_t StreamMap::getNextIdForStream(Stream* stream) const { #pragma clang diagnostic ignored "-Wthread-safety-analysis" StreamManager::StreamManager( int32_t streams, size_t threads, const audio_attributes_t* attributes) int32_t streams, size_t threads, const audio_attributes_t* attributes, std::string opPackageName) : StreamMap(streams) , mAttributes(*attributes) , mOpPackageName(std::move(opPackageName)) { ALOGV("%s(%d, %zu, ...)", __func__, streams, threads); forEach([this](Stream *stream) { Loading