summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/AudioPlayer.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-03-01 14:27:00 -0800
committerAndreas Huber <andih@google.com>2010-03-01 14:58:39 -0800
commit25155ff8ccf7898d08ab62fae46297e046a571f0 (patch)
tree9d4a1b6885f20d138b5dd1c557d51d26da74c169 /media/libstagefright/AudioPlayer.cpp
parente3d91046072908f5613a21652b6da9b44043f1d5 (diff)
downloadframeworks_av-25155ff8ccf7898d08ab62fae46297e046a571f0.zip
frameworks_av-25155ff8ccf7898d08ab62fae46297e046a571f0.tar.gz
frameworks_av-25155ff8ccf7898d08ab62fae46297e046a571f0.tar.bz2
Ensure that the audio codec instance is actually going away before we attempt to instantiate another one, otherwise we might end up with the software codec even though the hardware codec would have been available shortly.
Diffstat (limited to 'media/libstagefright/AudioPlayer.cpp')
-rw-r--r--media/libstagefright/AudioPlayer.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index 57f58be..5e6e0da 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -18,6 +18,7 @@
#define LOG_TAG "AudioPlayer"
#include <utils/Log.h>
+#include <binder/IPCThreadState.h>
#include <media/AudioTrack.h>
#include <media/stagefright/AudioPlayer.h>
#include <media/stagefright/MediaDebug.h>
@@ -164,6 +165,16 @@ void AudioPlayer::stop() {
mSource->stop();
+ // The following hack is necessary to ensure that the OMX
+ // component is completely released by the time we may try
+ // to instantiate it again.
+ wp<MediaSource> tmp = mSource;
+ mSource.clear();
+ while (tmp.promote() != NULL) {
+ usleep(1000);
+ }
+ IPCThreadState::self()->flushCommands();
+
mNumFramesPlayed = 0;
mPositionTimeMediaUs = -1;
mPositionTimeRealUs = -1;