SoundPool: Clean up attribute pointer
Test: atest SoundPoolAacTest Test: atest SoundPoolHapticTest Test: atest SoundPoolMidiTest Test: atest SoundPoolOggTest Test: atest AudioManagerTest#testSoundEffects Test: soundpool_stress Bug: 223815163 Change-Id: Idb2dafb9ad53dc7ffa0005425ea630fa7b7e5102
This commit is contained in:
@@ -85,12 +85,13 @@ bool checkLoop(int32_t *loop)
|
||||
} // namespace
|
||||
|
||||
SoundPool::SoundPool(
|
||||
int32_t maxStreams, const audio_attributes_t* attributes, const std::string& opPackageName)
|
||||
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,
|
||||
attributes->content_type, attributes->usage, attributes->flags, attributes->tags);
|
||||
attributes.content_type, attributes.usage, attributes.flags, attributes.tags);
|
||||
}
|
||||
|
||||
SoundPool::~SoundPool()
|
||||
|
||||
@@ -31,7 +31,7 @@ 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();
|
||||
|
||||
|
||||
@@ -106,10 +106,10 @@ 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)
|
||||
, mAttributes(attributes)
|
||||
, mOpPackageName(std::move(opPackageName))
|
||||
, mLockStreamManagerStop(streams == 1 || kForceLockStreamManagerStop)
|
||||
{
|
||||
|
||||
@@ -387,7 +387,7 @@ class StreamManager : public StreamMap {
|
||||
public:
|
||||
// Note: the SoundPool pointer is only used for stream initialization.
|
||||
// It is not stored in StreamManager.
|
||||
StreamManager(int32_t streams, size_t threads, const audio_attributes_t* attributes,
|
||||
StreamManager(int32_t streams, size_t threads, const audio_attributes_t& attributes,
|
||||
std::string opPackageName);
|
||||
~StreamManager();
|
||||
|
||||
|
||||
@@ -520,7 +520,7 @@ android_media_SoundPool_native_setup(JNIEnv *env, jobject thiz,
|
||||
(audio_flags_mask_t) env->GetIntField(jaa, javaAudioAttrFields.fieldFlags);
|
||||
ScopedUtfChars opPackageNameStr(env, opPackageName);
|
||||
auto soundPool = std::make_shared<SoundPool>(
|
||||
maxChannels, &audioAttributes, opPackageNameStr.c_str());
|
||||
maxChannels, audioAttributes, opPackageNameStr.c_str());
|
||||
soundPool->setCallback(android_media_callback, nullptr /* user */);
|
||||
|
||||
// register with SoundPoolManager.
|
||||
|
||||
@@ -274,7 +274,7 @@ int main(int argc, char *argv[])
|
||||
.content_type = AUDIO_CONTENT_TYPE_MUSIC,
|
||||
.usage = AUDIO_USAGE_MEDIA,
|
||||
};
|
||||
auto soundPool = std::make_unique<SoundPool>(maxStreams, &aa);
|
||||
auto soundPool = std::make_unique<SoundPool>(maxStreams, aa);
|
||||
|
||||
gCallbackManager.setSoundPool(soundPool.get());
|
||||
soundPool->setCallback(StaticCallbackManager, &gCallbackManager);
|
||||
|
||||
Reference in New Issue
Block a user