From aebf77b5955f9681a701e725de66b27e67e9af90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=AF=E6=AD=8C?= Date: Wed, 17 Jul 2024 22:26:04 +0800 Subject: [PATCH] modify audiomanager --- src/gui/core/audiomanager.cc | 32 +++++++++++++++++++++++++++++++- src/gui/core/audiomanager.h | 9 +++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/gui/core/audiomanager.cc b/src/gui/core/audiomanager.cc index 69ef3f48..dabc9971 100644 --- a/src/gui/core/audiomanager.cc +++ b/src/gui/core/audiomanager.cc @@ -1,8 +1,38 @@ #include +#include +//#include namespace cdroid{ -void AudioManager::playSoundEffect(int effectType){ +/*static int rtAudioCallback(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, + double streamTime, RtAudioStreamStatus status, void *userData){ + return 0; +}*/ + +AudioManager::AudioManager(){ + mContext = nullptr; +} +AudioManager::AudioManager(Context*ctx):AudioManager(){ + setContext(ctx); +} + +void AudioManager::setContext(Context* context){ + mSoundEffects.put(SoundEffectConstants::CLICK,"click"); + mSoundEffects.put(SoundEffectConstants::NAVIGATION_LEFT,"navigation_left"); + mSoundEffects.put(SoundEffectConstants::NAVIGATION_UP,"navigation_up"); + mSoundEffects.put(SoundEffectConstants::NAVIGATION_RIGHT,"navigation_right"); + mSoundEffects.put(SoundEffectConstants::NAVIGATION_DOWN,"navigation_down"); + mSoundEffects.put(SoundEffectConstants::NAVIGATION_REPEAT_LEFT,"navigation_repeat_left"); + mSoundEffects.put(SoundEffectConstants::NAVIGATION_REPEAT_UP,"navigation_repeat_up"); + mSoundEffects.put(SoundEffectConstants::NAVIGATION_REPEAT_RIGHT,"navigation_repeat_right"); + mSoundEffects.put(SoundEffectConstants::NAVIGATION_REPEAT_DOWN,"navigation_repeat_down"); + for(int i=SoundEffectConstants::CLICK;i<=SoundEffectConstants::NAVIGATION_REPEAT_DOWN+1;i++) + playSoundEffect(i); +} + +void AudioManager::playSoundEffect(int effectType){ + const std::string res = mSoundEffects.get(effectType,""); + LOGD("%d=%s",effectType,res.c_str()); } void AudioManager::playSoundEffect(int effectType, float volume){ diff --git a/src/gui/core/audiomanager.h b/src/gui/core/audiomanager.h index 619849f8..1b503ac6 100644 --- a/src/gui/core/audiomanager.h +++ b/src/gui/core/audiomanager.h @@ -1,8 +1,17 @@ #ifndef __AUDIO_MANAGER_H__ #define __AUDIO_MANAGER_H__ +#include namespace cdroid{ +class Context; class AudioManager{ +private: + Context*mContext; + SparseArraymSoundEffects; +private: + void setContext(Context* context); public: + AudioManager(); + AudioManager(Context*); void playSoundEffect(int effectType); void playSoundEffect(int effectType, float volume); };