diff options
author | Jay Shrauner <shrauner@google.com> | 2014-02-26 10:08:37 -0800 |
---|---|---|
committer | Jay Shrauner <shrauner@google.com> | 2014-03-06 16:58:27 +0000 |
commit | ce2b95ae200332495b348be07f77fe60b6c23dcc (patch) | |
tree | 08e2e3db703c977325d4d0fb15d01831a888b5eb /variablespeed/jni/variablespeed.cc | |
parent | e49544de8cf5224d0fd2af944b1431c92f7b83f9 (diff) | |
download | android_frameworks_ex-ce2b95ae200332495b348be07f77fe60b6c23dcc.tar.gz android_frameworks_ex-ce2b95ae200332495b348be07f77fe60b6c23dcc.tar.bz2 android_frameworks_ex-ce2b95ae200332495b348be07f77fe60b6c23dcc.zip |
Fix AudioEngine to allow re-initialization - DO NOT MERGE
Add AudioEngine::CompareAndSetEngine and change
VariableSpeed::initializeEngine to use this method so it only initializes
a new engine once rather than asserting on subsequent calls.
Change AudioEngine::DeleteEngine so it ignores repeated calls instead of
asserting. Add VariableSpeed::isReadyToPlay so callers can detect when
the audio library has been properly initialized.
Bug:11511992
Change-Id: I4517cb2ab4c186da43dffc7dbc2a9ad49000059f
(cherry picked from commit 8502b724a9fdc104e7b4a3aba1641e101b4c7be9)
Diffstat (limited to 'variablespeed/jni/variablespeed.cc')
-rw-r--r-- | variablespeed/jni/variablespeed.cc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/variablespeed/jni/variablespeed.cc b/variablespeed/jni/variablespeed.cc index 73ac609..4bdbbcc 100644 --- a/variablespeed/jni/variablespeed.cc +++ b/variablespeed/jni/variablespeed.cc @@ -129,14 +129,21 @@ void AudioEngine::SetEngine(AudioEngine* engine) { audioEngine_ = engine; } +bool AudioEngine::CompareAndSetEngine(AudioEngine* expect, AudioEngine* update) { + android::Mutex::Autolock autoLock(publishEngineLock_); + if (audioEngine_ == expect) { + DeleteEngine(); + audioEngine_ = update; + return true; + } + return false; +} + void AudioEngine::DeleteEngine() { - if (audioEngine_ == NULL) { - LOGE("you haven't initialized the audio engine"); - CHECK(false); - return; + if (audioEngine_ != NULL) { + delete audioEngine_; + audioEngine_ = NULL; } - delete audioEngine_; - audioEngine_ = NULL; } // **************************************************************************** |