Android: fix two race conditions in the media player.

start() could be called before the media player was marked as prepared.
When changing media, setMediaPath() could be called before the media
player was reset.

Task-number: QTBUG-34558
Change-Id: I886fd5f5008f76dcbc88c57d7b16a439b394d4a7
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
Yoann Lopes
2013-11-04 19:14:22 +01:00
committed by The Qt Project
parent fb199a5045
commit 2412c298d4
2 changed files with 2 additions and 3 deletions

View File

@@ -159,7 +159,6 @@ public class QtAndroidMediaPlayer extends MediaPlayer
public void onCompletion(final MediaPlayer mp) public void onCompletion(final MediaPlayer mp)
{ {
onMediaPlayerInfoNative(MEDIA_PLAYER_FINISHED, 0, mID); onMediaPlayerInfoNative(MEDIA_PLAYER_FINISHED, 0, mID);
reset();
} }
} }
@@ -191,9 +190,9 @@ public class QtAndroidMediaPlayer extends MediaPlayer
@Override @Override
public void onPrepared(final MediaPlayer mp) public void onPrepared(final MediaPlayer mp)
{ {
mPreparing = false;
onMediaPlayerInfoNative(MEDIA_PLAYER_READY, 0, mID); onMediaPlayerInfoNative(MEDIA_PLAYER_READY, 0, mID);
onMediaPlayerInfoNative(MEDIA_PLAYER_DURATION, getDuration(), mID); onMediaPlayerInfoNative(MEDIA_PLAYER_DURATION, getDuration(), mID);
mPreparing = false;
} }
} }

View File

@@ -344,7 +344,7 @@ void QAndroidMediaPlayerControl::onMediaPlayerInfo(qint32 what, qint32 extra)
Q_EMIT positionChanged(extra); Q_EMIT positionChanged(extra);
break; break;
case JMediaPlayer::MEDIA_PLAYER_FINISHED: case JMediaPlayer::MEDIA_PLAYER_FINISHED:
setState(QMediaPlayer::StoppedState); stop();
setMediaStatus(QMediaPlayer::EndOfMedia); setMediaStatus(QMediaPlayer::EndOfMedia);
break; break;
} }