Merge "SoundPool: Clean up attribute pointer" into tm-dev

This commit is contained in:
Andy Hung
2022-03-29 23:57:26 +00:00
committed by Android (Google) Code Review
6 changed files with 9 additions and 8 deletions

View File

@@ -85,12 +85,13 @@ bool checkLoop(int32_t *loop)
} // namespace } // namespace
SoundPool::SoundPool( 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) : mStreamManager(maxStreams, kStreamManagerThreads, attributes, opPackageName)
{ {
ALOGV("%s(maxStreams=%d, attr={ content_type=%d, usage=%d, flags=0x%x, tags=%s })", ALOGV("%s(maxStreams=%d, attr={ content_type=%d, usage=%d, flags=0x%x, tags=%s })",
__func__, maxStreams, __func__, maxStreams,
attributes->content_type, attributes->usage, attributes->flags, attributes->tags); attributes.content_type, attributes.usage, attributes.flags, attributes.tags);
} }
SoundPool::~SoundPool() SoundPool::~SoundPool()

View File

@@ -31,7 +31,7 @@ namespace android {
*/ */
class SoundPool { class SoundPool {
public: public:
SoundPool(int32_t maxStreams, const audio_attributes_t* attributes, SoundPool(int32_t maxStreams, const audio_attributes_t& attributes,
const std::string& opPackageName = {}); const std::string& opPackageName = {});
~SoundPool(); ~SoundPool();

View File

@@ -106,10 +106,10 @@ int32_t StreamMap::getNextIdForStream(Stream* stream) const {
#pragma clang diagnostic ignored "-Wthread-safety-analysis" #pragma clang diagnostic ignored "-Wthread-safety-analysis"
StreamManager::StreamManager( 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) std::string opPackageName)
: StreamMap(streams) : StreamMap(streams)
, mAttributes(*attributes) , mAttributes(attributes)
, mOpPackageName(std::move(opPackageName)) , mOpPackageName(std::move(opPackageName))
, mLockStreamManagerStop(streams == 1 || kForceLockStreamManagerStop) , mLockStreamManagerStop(streams == 1 || kForceLockStreamManagerStop)
{ {

View File

@@ -387,7 +387,7 @@ class StreamManager : public StreamMap {
public: public:
// Note: the SoundPool pointer is only used for stream initialization. // Note: the SoundPool pointer is only used for stream initialization.
// It is not stored in StreamManager. // 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); std::string opPackageName);
~StreamManager(); ~StreamManager();

View File

@@ -520,7 +520,7 @@ android_media_SoundPool_native_setup(JNIEnv *env, jobject thiz,
(audio_flags_mask_t) env->GetIntField(jaa, javaAudioAttrFields.fieldFlags); (audio_flags_mask_t) env->GetIntField(jaa, javaAudioAttrFields.fieldFlags);
ScopedUtfChars opPackageNameStr(env, opPackageName); ScopedUtfChars opPackageNameStr(env, opPackageName);
auto soundPool = std::make_shared<SoundPool>( auto soundPool = std::make_shared<SoundPool>(
maxChannels, &audioAttributes, opPackageNameStr.c_str()); maxChannels, audioAttributes, opPackageNameStr.c_str());
soundPool->setCallback(android_media_callback, nullptr /* user */); soundPool->setCallback(android_media_callback, nullptr /* user */);
// register with SoundPoolManager. // register with SoundPoolManager.

View File

@@ -274,7 +274,7 @@ int main(int argc, char *argv[])
.content_type = AUDIO_CONTENT_TYPE_MUSIC, .content_type = AUDIO_CONTENT_TYPE_MUSIC,
.usage = AUDIO_USAGE_MEDIA, .usage = AUDIO_USAGE_MEDIA,
}; };
auto soundPool = std::make_unique<SoundPool>(maxStreams, &aa); auto soundPool = std::make_unique<SoundPool>(maxStreams, aa);
gCallbackManager.setSoundPool(soundPool.get()); gCallbackManager.setSoundPool(soundPool.get());
soundPool->setCallback(StaticCallbackManager, &gCallbackManager); soundPool->setCallback(StaticCallbackManager, &gCallbackManager);