diff options
author | Lajos Molnar <lajos@google.com> | 2015-05-01 01:34:53 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-05-01 01:34:53 +0000 |
commit | f0afeb2373142eee860b79f76d283c505b638190 (patch) | |
tree | c86edfbf8a53cd7dfc3cd4579a8f33094ffa981f /media/java | |
parent | da954c6b92d542004ca14c73613be365b4a5cc47 (diff) | |
parent | 0486d03dc0c843f31852afc2812c934f10aeb21e (diff) | |
download | frameworks_base-f0afeb2373142eee860b79f76d283c505b638190.zip frameworks_base-f0afeb2373142eee860b79f76d283c505b638190.tar.gz frameworks_base-f0afeb2373142eee860b79f76d283c505b638190.tar.bz2 |
am 0486d03d: am 607dab36: am 05ebffe6: media: Hook up MediaPlayer and MediaSync to new settings
* commit '0486d03dc0c843f31852afc2812c934f10aeb21e':
media: Hook up MediaPlayer and MediaSync to new settings
Diffstat (limited to 'media/java')
-rw-r--r-- | media/java/android/media/MediaSync.java | 60 |
1 files changed, 18 insertions, 42 deletions
diff --git a/media/java/android/media/MediaSync.java b/media/java/android/media/MediaSync.java index dc6760d..ecc87e7 100644 --- a/media/java/android/media/MediaSync.java +++ b/media/java/android/media/MediaSync.java @@ -199,6 +199,7 @@ final public class MediaSync { private final Object mAudioLock = new Object(); private AudioTrack mAudioTrack = null; private List<AudioBuffer> mAudioBuffers = new LinkedList<AudioBuffer>(); + // this is only used for paused/running decisions, so it is not affected by clock drift private float mPlaybackRate = 0.0f; private long mNativeContext; @@ -459,36 +460,11 @@ final public class MediaSync { * @throws IllegalArgumentException if the settings are not supported. */ public void setPlaybackSettings(@NonNull PlaybackSettings settings) { - float rate; - try { - rate = settings.getSpeed(); - - // rate is specified - if (mAudioTrack != null) { - try { - if (rate == 0.0) { - mAudioTrack.pause(); - } else { - mAudioTrack.setPlaybackSettings(settings); - mAudioTrack.play(); - } - } catch (IllegalStateException e) { - throw e; - } - } - - synchronized(mAudioLock) { - mPlaybackRate = rate; - } - if (mPlaybackRate != 0.0 && mAudioThread != null) { - postRenderAudio(0); - } - native_setPlaybackRate(mPlaybackRate); - } catch (IllegalStateException e) { - // rate is not specified; still, propagate settings to audio track - if (mAudioTrack != null) { - mAudioTrack.setPlaybackSettings(settings); - } + synchronized(mAudioLock) { + mPlaybackRate = native_setPlaybackSettings(settings);; + } + if (mPlaybackRate != 0.0 && mAudioThread != null) { + postRenderAudio(0); } } @@ -501,18 +477,9 @@ final public class MediaSync { * been initialized. */ @NonNull - public PlaybackSettings getPlaybackSettings() { - if (mAudioTrack != null) { - return mAudioTrack.getPlaybackSettings(); - } else { - PlaybackSettings settings = new PlaybackSettings(); - settings.allowDefaults(); - settings.setSpeed(mPlaybackRate); - return settings; - } - } + public native PlaybackSettings getPlaybackSettings(); - private native final void native_setPlaybackRate(float rate); + private native float native_setPlaybackSettings(@NonNull PlaybackSettings settings); /** * Sets A/V sync mode. @@ -523,7 +490,16 @@ final public class MediaSync { * initialized. * @throws IllegalArgumentException if settings are not supported. */ - public native void setSyncSettings(@NonNull SyncSettings settings); + public void setSyncSettings(@NonNull SyncSettings settings) { + synchronized(mAudioLock) { + mPlaybackRate = native_setSyncSettings(settings);; + } + if (mPlaybackRate != 0.0 && mAudioThread != null) { + postRenderAudio(0); + } + } + + private native float native_setSyncSettings(@NonNull SyncSettings settings); /** * Gets the A/V sync mode. |