diff options
author | Marco Nelissen <marcone@google.com> | 2014-02-28 10:00:21 -0800 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2014-02-28 10:54:07 -0800 |
commit | 4d462fbd20c7e4b214f1d9b9396a623f4e4b6f38 (patch) | |
tree | d1f9a206866cb92de2c77b2fc550ce6b130be09e /media/libstagefright/AwesomePlayer.cpp | |
parent | 19a9fef6d2970a615f4f33025f9141e44b7c9f34 (diff) | |
download | frameworks_av-4d462fbd20c7e4b214f1d9b9396a623f4e4b6f38.zip frameworks_av-4d462fbd20c7e4b214f1d9b9396a623f4e4b6f38.tar.gz frameworks_av-4d462fbd20c7e4b214f1d9b9396a623f4e4b6f38.tar.bz2 |
Fix race condition in AwesomePlayer
This fixes a race condition that could cause two threads to attempt to
connect to a server at the same time, resulting in multiple requests
and/or aborted connections. In some cases, it could cause other operations
on MediaPlayer to block until network access was complete.
b/13187722
Change-Id: Ibf78acff15dbfbf6c443a4c60623e8eac967d955
Diffstat (limited to 'media/libstagefright/AwesomePlayer.cpp')
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index e83ec62..4bad14b 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -2217,6 +2217,10 @@ status_t AwesomePlayer::finishSetDataSource_l() { mLock.unlock(); status_t err = mConnectingDataSource->connect(mUri, &mUriHeaders); + // force connection at this point, to avoid a race condition between getMIMEType and the + // caching datasource constructed below, which could result in multiple requests to the + // server, and/or failed connections. + String8 contentType = mConnectingDataSource->getMIMEType(); mLock.lock(); if (err != OK) { @@ -2247,8 +2251,6 @@ status_t AwesomePlayer::finishSetDataSource_l() { mConnectingDataSource.clear(); - String8 contentType = dataSource->getMIMEType(); - if (strncasecmp(contentType.string(), "audio/", 6)) { // We're not doing this for streams that appear to be audio-only // streams to ensure that even low bandwidth streams start |