summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorWei Jia <wjia@google.com>2015-05-08 23:23:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-08 23:23:47 +0000
commitea4eb326cfc4a8221be5fdab9639d468c632aee2 (patch)
tree16f12b6b243d167a84210a9839fcc7b7cd0bf049 /media
parent4f434a04708e7a254afe2e0d362f715229dc15d1 (diff)
parent2d61e2b97c92ac2de80ebb3782b728ae5cdf5306 (diff)
downloadframeworks_base-ea4eb326cfc4a8221be5fdab9639d468c632aee2.zip
frameworks_base-ea4eb326cfc4a8221be5fdab9639d468c632aee2.tar.gz
frameworks_base-ea4eb326cfc4a8221be5fdab9639d468c632aee2.tar.bz2
Merge "MediaSync: address API review." into mnc-dev
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioTrack.java32
-rw-r--r--media/java/android/media/MediaPlayer.java46
-rw-r--r--media/java/android/media/MediaSync.java74
-rw-r--r--media/java/android/media/PlaybackParams.java (renamed from media/java/android/media/PlaybackSettings.java)42
-rw-r--r--media/java/android/media/SyncParams.java (renamed from media/java/android/media/SyncSettings.java)46
-rw-r--r--media/jni/Android.mk2
-rw-r--r--media/jni/android_media_MediaPlayer.cpp130
-rw-r--r--media/jni/android_media_MediaSync.cpp90
-rw-r--r--media/jni/android_media_MediaSync.h8
-rw-r--r--media/jni/android_media_PlaybackParams.h (renamed from media/jni/android_media_PlaybackSettings.h)38
-rw-r--r--media/jni/android_media_SyncParams.cpp (renamed from media/jni/android_media_SyncSettings.cpp)38
-rw-r--r--media/jni/android_media_SyncParams.h (renamed from media/jni/android_media_SyncSettings.h)14
12 files changed, 277 insertions, 283 deletions
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index a66a1e5..dc37700 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -908,13 +908,13 @@ public class AudioTrack
}
/**
- * Returns the current playback settings.
- * See {@link #setPlaybackSettings(PlaybackSettings)} to set playback settings
- * @return current {@link PlaybackSettings}.
+ * Returns the current playback params.
+ * See {@link #setPlaybackParams(PlaybackParams)} to set playback params
+ * @return current {@link PlaybackParams}.
* @throws IllegalStateException if track is not initialized.
*/
- public @NonNull PlaybackSettings getPlaybackSettings() {
- return native_get_playback_settings();
+ public @NonNull PlaybackParams getPlaybackParams() {
+ return native_get_playback_params();
}
/**
@@ -1294,7 +1294,7 @@ public class AudioTrack
* playback to last twice as long, but will also result in a pitch shift down by one octave.
* The valid sample rate range is from 1 Hz to twice the value returned by
* {@link #getNativeOutputSampleRate(int)}.
- * Use {@link #setPlaybackSettings(PlaybackSettings)} for speed control.
+ * Use {@link #setPlaybackParams(PlaybackParams)} for speed control.
* @param sampleRateInHz the sample rate expressed in Hz
* @return error code or success, see {@link #SUCCESS}, {@link #ERROR_BAD_VALUE},
* {@link #ERROR_INVALID_OPERATION}
@@ -1311,24 +1311,24 @@ public class AudioTrack
/**
- * Sets the playback settings.
- * This method returns failure if it cannot apply the playback settings.
+ * Sets the playback params.
+ * This method returns failure if it cannot apply the playback params.
* One possible cause is that the parameters for speed or pitch are out of range.
* Another possible cause is that the <code>AudioTrack</code> is streaming
* (see {@link #MODE_STREAM}) and the
* buffer size is too small. For speeds greater than 1.0f, the <code>AudioTrack</code> buffer
* on configuration must be larger than the speed multiplied by the minimum size
* {@link #getMinBufferSize(int, int, int)}) to allow proper playback.
- * @param settings see {@link PlaybackSettings}. In particular,
+ * @param params see {@link PlaybackParams}. In particular,
* speed, pitch, and audio mode should be set.
- * @throws IllegalArgumentException if the settings are invalid or not accepted.
+ * @throws IllegalArgumentException if the params are invalid or not accepted.
* @throws IllegalStateException if track is not initialized.
*/
- public void setPlaybackSettings(@NonNull PlaybackSettings settings) {
- if (settings == null) {
- throw new IllegalArgumentException("settings is null");
+ public void setPlaybackParams(@NonNull PlaybackParams params) {
+ if (params == null) {
+ throw new IllegalArgumentException("params is null");
}
- native_set_playback_settings(settings);
+ native_set_playback_params(params);
}
@@ -2353,8 +2353,8 @@ public class AudioTrack
private native final int native_set_playback_rate(int sampleRateInHz);
private native final int native_get_playback_rate();
- private native final void native_set_playback_settings(@NonNull PlaybackSettings settings);
- private native final @NonNull PlaybackSettings native_get_playback_settings();
+ private native final void native_set_playback_params(@NonNull PlaybackParams params);
+ private native final @NonNull PlaybackParams native_get_playback_params();
private native final int native_set_marker_pos(int marker);
private native final int native_get_marker_pos();
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index b3c1b4d..aaafa55 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -47,12 +47,12 @@ import android.graphics.SurfaceTexture;
import android.media.AudioManager;
import android.media.MediaFormat;
import android.media.MediaTimeProvider;
-import android.media.PlaybackSettings;
+import android.media.PlaybackParams;
import android.media.SubtitleController;
import android.media.SubtitleController.Anchor;
import android.media.SubtitleData;
import android.media.SubtitleTrack.RenderingWidget;
-import android.media.SyncSettings;
+import android.media.SyncParams;
import com.android.internal.app.IAppOpsService;
@@ -481,7 +481,7 @@ import java.lang.ref.WeakReference;
* <td>{} </p></td>
* <td>This method can be called in any state and calling it does not change
* the object state. </p></td></tr>
- * <tr><td>setPlaybackSettings</p></td>
+ * <tr><td>setPlaybackParams</p></td>
* <td>any </p></td>
* <td>{} </p></td>
* <td>This method can be called in any state and calling it does not change
@@ -1408,68 +1408,68 @@ public class MediaPlayer implements SubtitleController.Listener
* @throws IllegalArgumentException if audioMode is not supported.
*/
public void setPlaybackRate(float rate, @PlaybackRateAudioMode int audioMode) {
- PlaybackSettings settings = new PlaybackSettings();
- settings.allowDefaults();
+ PlaybackParams params = new PlaybackParams();
+ params.allowDefaults();
switch (audioMode) {
case PLAYBACK_RATE_AUDIO_MODE_DEFAULT:
- settings.setSpeed(rate).setPitch(1.0f);
+ params.setSpeed(rate).setPitch(1.0f);
break;
case PLAYBACK_RATE_AUDIO_MODE_STRETCH:
- settings.setSpeed(rate).setPitch(1.0f)
- .setAudioFallbackMode(settings.AUDIO_FALLBACK_MODE_FAIL);
+ params.setSpeed(rate).setPitch(1.0f)
+ .setAudioFallbackMode(params.AUDIO_FALLBACK_MODE_FAIL);
break;
case PLAYBACK_RATE_AUDIO_MODE_RESAMPLE:
- settings.setSpeed(rate).setPitch(rate);
+ params.setSpeed(rate).setPitch(rate);
break;
default:
final String msg = "Audio playback mode " + audioMode + " is not supported";
throw new IllegalArgumentException(msg);
}
- setPlaybackSettings(settings);
+ setPlaybackParams(params);
}
/**
- * Sets playback rate using {@link PlaybackSettings}.
+ * Sets playback rate using {@link PlaybackParams}.
*
- * @param settings the playback settings.
+ * @param params the playback params.
*
* @throws IllegalStateException if the internal player engine has not been
* initialized.
- * @throws IllegalArgumentException if settings is not supported.
+ * @throws IllegalArgumentException if params is not supported.
*/
- public native void setPlaybackSettings(@NonNull PlaybackSettings settings);
+ public native void setPlaybackParams(@NonNull PlaybackParams params);
/**
- * Gets the playback settings, containing the current playback rate.
+ * Gets the playback params, containing the current playback rate.
*
- * @return the playback settings.
+ * @return the playback params.
* @throws IllegalStateException if the internal player engine has not been
* initialized.
*/
@NonNull
- public native PlaybackSettings getPlaybackSettings();
+ public native PlaybackParams getPlaybackParams();
/**
* Sets A/V sync mode.
*
- * @param settings the A/V sync settings to apply
+ * @param params the A/V sync params to apply
*
* @throws IllegalStateException if the internal player engine has not been
* initialized.
- * @throws IllegalArgumentException if settings are not supported.
+ * @throws IllegalArgumentException if params are not supported.
*/
- public native void setSyncSettings(@NonNull SyncSettings settings);
+ public native void setSyncParams(@NonNull SyncParams params);
/**
* Gets the A/V sync mode.
*
- * @return the A/V sync settings
+ * @return the A/V sync params
*
* @throws IllegalStateException if the internal player engine has not been
* initialized.
*/
@NonNull
- public native SyncSettings getSyncSettings();
+ public native SyncParams getSyncParams();
/**
* Seeks to specified time position.
@@ -1507,7 +1507,7 @@ public class MediaPlayer implements SubtitleController.Listener
return new MediaTimestamp(
getCurrentPosition() * 1000L,
System.nanoTime(),
- isPlaying() ? getPlaybackSettings().getSpeed() : 0.f);
+ isPlaying() ? getPlaybackParams().getSpeed() : 0.f);
} catch (IllegalStateException e) {
return null;
}
diff --git a/media/java/android/media/MediaSync.java b/media/java/android/media/MediaSync.java
index a5b0d39..b7ef95c 100644
--- a/media/java/android/media/MediaSync.java
+++ b/media/java/android/media/MediaSync.java
@@ -20,7 +20,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.media.AudioTrack;
-import android.media.PlaybackSettings;
+import android.media.PlaybackParams;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -62,7 +62,7 @@ import java.util.List;
* // videoDecoder.releaseOutputBuffer(videoOutputBufferIx, videoPresentationTimeNs);
* // More details are available as below.
* ...
- * sync.queueAudio(audioByteBuffer, bufferIndex, size, audioPresentationTimeUs); // non-blocking.
+ * sync.queueAudio(audioByteBuffer, bufferIndex, audioPresentationTimeUs); // non-blocking.
* // The audioByteBuffer and bufferIndex will be returned via callback.
* // More details are available as below.
* ...
@@ -112,7 +112,7 @@ import java.util.List;
* initial underrun.
* <p>
*/
-final public class MediaSync {
+public final class MediaSync {
/**
* MediaSync callback interface. Used to notify the user asynchronously
* of various MediaSync events.
@@ -170,14 +170,12 @@ final public class MediaSync {
private static class AudioBuffer {
public ByteBuffer mByteBuffer;
public int mBufferIndex;
- public int mSizeInBytes;
long mPresentationTimeUs;
public AudioBuffer(@NonNull ByteBuffer byteBuffer, int bufferIndex,
- int sizeInBytes, long presentationTimeUs) {
+ long presentationTimeUs) {
mByteBuffer = byteBuffer;
mBufferIndex = bufferIndex;
- mSizeInBytes = sizeInBytes;
mPresentationTimeUs = presentationTimeUs;
}
}
@@ -413,18 +411,18 @@ final public class MediaSync {
* @throws IllegalArgumentException if audioMode is not supported.
*/
public void setPlaybackRate(float rate, @PlaybackRateAudioMode int audioMode) {
- PlaybackSettings rateSettings = new PlaybackSettings();
- rateSettings.allowDefaults();
+ PlaybackParams rateParams = new PlaybackParams();
+ rateParams.allowDefaults();
switch (audioMode) {
case PLAYBACK_RATE_AUDIO_MODE_DEFAULT:
- rateSettings.setSpeed(rate).setPitch(1.0f);
+ rateParams.setSpeed(rate).setPitch(1.0f);
break;
case PLAYBACK_RATE_AUDIO_MODE_STRETCH:
- rateSettings.setSpeed(rate).setPitch(1.0f)
- .setAudioFallbackMode(rateSettings.AUDIO_FALLBACK_MODE_FAIL);
+ rateParams.setSpeed(rate).setPitch(1.0f)
+ .setAudioFallbackMode(rateParams.AUDIO_FALLBACK_MODE_FAIL);
break;
case PLAYBACK_RATE_AUDIO_MODE_RESAMPLE:
- rateSettings.setSpeed(rate).setPitch(rate);
+ rateParams.setSpeed(rate).setPitch(rate);
break;
default:
{
@@ -432,19 +430,19 @@ final public class MediaSync {
throw new IllegalArgumentException(msg);
}
}
- setPlaybackSettings(rateSettings);
+ setPlaybackParams(rateParams);
}
/**
- * Sets playback rate using {@link PlaybackSettings}.
+ * Sets playback rate using {@link PlaybackParams}.
* <p>
- * When using MediaSync with {@link AudioTrack}, set playback settings using this
+ * When using MediaSync with {@link AudioTrack}, set playback params using this
* call instead of calling it directly on the track, so that the sync is aware of
- * the settings change.
+ * the params change.
* <p>
* This call also works if there is no audio track.
*
- * @param settings the playback settings to use. {@link PlaybackSettings#getSpeed
+ * @param params the playback params to use. {@link PlaybackParams#getSpeed
* Speed} is the ratio between desired playback rate and normal one. 1.0 means
* normal playback speed. 0.0 means pause. Value larger than 1.0 means faster playback,
* while value between 0.0 and 1.0 for slower playback. <b>Note:</b> the normal rate
@@ -453,11 +451,11 @@ final public class MediaSync {
*
* @throws IllegalStateException if the internal sync engine or the audio track has not
* been initialized.
- * @throws IllegalArgumentException if the settings are not supported.
+ * @throws IllegalArgumentException if the params are not supported.
*/
- public void setPlaybackSettings(@NonNull PlaybackSettings settings) {
+ public void setPlaybackParams(@NonNull PlaybackParams params) {
synchronized(mAudioLock) {
- mPlaybackRate = native_setPlaybackSettings(settings);;
+ mPlaybackRate = native_setPlaybackParams(params);;
}
if (mPlaybackRate != 0.0 && mAudioThread != null) {
postRenderAudio(0);
@@ -465,7 +463,7 @@ final public class MediaSync {
}
/**
- * Gets the playback rate using {@link PlaybackSettings}.
+ * Gets the playback rate using {@link PlaybackParams}.
*
* @return the playback rate being used.
*
@@ -473,40 +471,40 @@ final public class MediaSync {
* been initialized.
*/
@NonNull
- public native PlaybackSettings getPlaybackSettings();
+ public native PlaybackParams getPlaybackParams();
- private native float native_setPlaybackSettings(@NonNull PlaybackSettings settings);
+ private native float native_setPlaybackParams(@NonNull PlaybackParams params);
/**
* Sets A/V sync mode.
*
- * @param settings the A/V sync settings to apply
+ * @param params the A/V sync params to apply
*
* @throws IllegalStateException if the internal player engine has not been
* initialized.
- * @throws IllegalArgumentException if settings are not supported.
+ * @throws IllegalArgumentException if params are not supported.
*/
- public void setSyncSettings(@NonNull SyncSettings settings) {
+ public void setSyncParams(@NonNull SyncParams params) {
synchronized(mAudioLock) {
- mPlaybackRate = native_setSyncSettings(settings);;
+ mPlaybackRate = native_setSyncParams(params);;
}
if (mPlaybackRate != 0.0 && mAudioThread != null) {
postRenderAudio(0);
}
}
- private native float native_setSyncSettings(@NonNull SyncSettings settings);
+ private native float native_setSyncParams(@NonNull SyncParams params);
/**
* Gets the A/V sync mode.
*
- * @return the A/V sync settings
+ * @return the A/V sync params
*
* @throws IllegalStateException if the internal player engine has not been
* initialized.
*/
@NonNull
- public native SyncSettings getSyncSettings();
+ public native SyncParams getSyncParams();
/**
* Flushes all buffers from the sync object.
@@ -567,23 +565,20 @@ final public class MediaSync {
* to the client via registered callback.
* @param bufferIndex the buffer index used to identify audioData. It will be returned to
* the client along with audioData. This helps applications to keep track of audioData.
- * @param sizeInBytes number of bytes to queue.
* @param presentationTimeUs the presentation timestamp in microseconds for the first frame
* in the buffer.
* @throws IllegalStateException if audio track is not set or internal configureation
* has not been done correctly.
*/
public void queueAudio(
- @NonNull ByteBuffer audioData, int bufferIndex, int sizeInBytes,
- long presentationTimeUs) {
+ @NonNull ByteBuffer audioData, int bufferIndex, long presentationTimeUs) {
if (mAudioTrack == null || mAudioThread == null) {
throw new IllegalStateException(
"AudioTrack is NOT set or audio thread is not created");
}
synchronized(mAudioLock) {
- mAudioBuffers.add(new AudioBuffer(
- audioData, bufferIndex, sizeInBytes, presentationTimeUs));
+ mAudioBuffers.add(new AudioBuffer(audioData, bufferIndex, presentationTimeUs));
}
if (mPlaybackRate != 0.0) {
@@ -605,18 +600,19 @@ final public class MediaSync {
}
AudioBuffer audioBuffer = mAudioBuffers.get(0);
+ int size = audioBuffer.mByteBuffer.remaining();
int sizeWritten = mAudioTrack.write(
audioBuffer.mByteBuffer,
- audioBuffer.mSizeInBytes,
+ size,
AudioTrack.WRITE_NON_BLOCKING);
if (sizeWritten > 0) {
if (audioBuffer.mPresentationTimeUs != -1) {
native_updateQueuedAudioData(
- audioBuffer.mSizeInBytes, audioBuffer.mPresentationTimeUs);
+ size, audioBuffer.mPresentationTimeUs);
audioBuffer.mPresentationTimeUs = -1;
}
- if (sizeWritten == audioBuffer.mSizeInBytes) {
+ if (sizeWritten == size) {
postReturnByteBuffer(audioBuffer);
mAudioBuffers.remove(0);
if (!mAudioBuffers.isEmpty()) {
@@ -624,8 +620,6 @@ final public class MediaSync {
}
return;
}
-
- audioBuffer.mSizeInBytes -= sizeWritten;
}
long pendingTimeMs = TimeUnit.MICROSECONDS.toMillis(
native_getPlayTimeForPendingAudioFrames());
diff --git a/media/java/android/media/PlaybackSettings.java b/media/java/android/media/PlaybackParams.java
index b2e1033..e41b2b6 100644
--- a/media/java/android/media/PlaybackSettings.java
+++ b/media/java/android/media/PlaybackParams.java
@@ -22,21 +22,21 @@ import java.lang.annotation.RetentionPolicy;
import android.annotation.IntDef;
/**
- * Structure for common playback settings.
+ * Structure for common playback params.
*
- * Used by {@link AudioTrack} {@link AudioTrack#getPlaybackSettings()} and
- * {@link AudioTrack#setPlaybackSettings(PlaybackSettings)}
+ * Used by {@link AudioTrack} {@link AudioTrack#getPlaybackParams()} and
+ * {@link AudioTrack#setPlaybackParams(PlaybackParams)}
* to control playback behavior.
* <p> <strong>audio fallback mode:</strong>
* select out-of-range parameter handling.
* <ul>
- * <li> {@link PlaybackSettings#AUDIO_FALLBACK_MODE_DEFAULT}:
+ * <li> {@link PlaybackParams#AUDIO_FALLBACK_MODE_DEFAULT}:
* System will determine best handling. </li>
- * <li> {@link PlaybackSettings#AUDIO_FALLBACK_MODE_MUTE}:
- * Play silence for settings normally out of range.</li>
- * <li> {@link PlaybackSettings#AUDIO_FALLBACK_MODE_FAIL}:
+ * <li> {@link PlaybackParams#AUDIO_FALLBACK_MODE_MUTE}:
+ * Play silence for params normally out of range.</li>
+ * <li> {@link PlaybackParams#AUDIO_FALLBACK_MODE_FAIL}:
* Return {@link java.lang.IllegalArgumentException} from
- * <code>AudioTrack.setPlaybackSettings(PlaybackSettings)</code>.</li>
+ * <code>AudioTrack.setPlaybackParams(PlaybackParams)</code>.</li>
* </ul>
* <p> <strong>pitch:</strong> increases or decreases the tonal frequency of the audio content.
* It is expressed as a multiplicative factor, where normal pitch is 1.0f.
@@ -52,7 +52,7 @@ import android.annotation.IntDef;
* similar to {@link AudioTrack#setPlaybackRate(int)}.</li>
* </ul>
*/
-public final class PlaybackSettings {
+public final class PlaybackParams {
/** @hide */
@IntDef(
value = {
@@ -81,14 +81,14 @@ public final class PlaybackSettings {
/** @hide */
public static final int AUDIO_STRETCH_MODE_VOICE = 1;
- // flags to indicate which settings are actually set
+ // flags to indicate which params are actually set
private static final int SET_SPEED = 1 << 0;
private static final int SET_PITCH = 1 << 1;
private static final int SET_AUDIO_FALLBACK_MODE = 1 << 2;
private static final int SET_AUDIO_STRETCH_MODE = 1 << 3;
private int mSet = 0;
- // settings
+ // params
private int mAudioFallbackMode = AUDIO_FALLBACK_MODE_DEFAULT;
private int mAudioStretchMode = AUDIO_STRETCH_MODE_DEFAULT;
private float mPitch = 1.0f;
@@ -99,9 +99,9 @@ public final class PlaybackSettings {
* Otherwise a {@link java.lang.IllegalArgumentException} exception
* is raised when getting those properties
* which have defaults but have never been set.
- * @return this <code>PlaybackSettings</code> instance.
+ * @return this <code>PlaybackParams</code> instance.
*/
- public PlaybackSettings allowDefaults() {
+ public PlaybackParams allowDefaults() {
mSet |= SET_AUDIO_FALLBACK_MODE | SET_AUDIO_STRETCH_MODE | SET_PITCH | SET_SPEED;
return this;
}
@@ -109,9 +109,9 @@ public final class PlaybackSettings {
/**
* Sets the audio fallback mode.
* @param audioFallbackMode
- * @return this <code>PlaybackSettings</code> instance.
+ * @return this <code>PlaybackParams</code> instance.
*/
- public PlaybackSettings setAudioFallbackMode(@AudioFallbackMode int audioFallbackMode) {
+ public PlaybackParams setAudioFallbackMode(@AudioFallbackMode int audioFallbackMode) {
mAudioFallbackMode = audioFallbackMode;
mSet |= SET_AUDIO_FALLBACK_MODE;
return this;
@@ -133,9 +133,9 @@ public final class PlaybackSettings {
* @hide
* Sets the audio stretch mode.
* @param audioStretchMode
- * @return this <code>PlaybackSettings</code> instance.
+ * @return this <code>PlaybackParams</code> instance.
*/
- public PlaybackSettings setAudioStretchMode(@AudioStretchMode int audioStretchMode) {
+ public PlaybackParams setAudioStretchMode(@AudioStretchMode int audioStretchMode) {
mAudioStretchMode = audioStretchMode;
mSet |= SET_AUDIO_STRETCH_MODE;
return this;
@@ -157,9 +157,9 @@ public final class PlaybackSettings {
/**
* Sets the pitch factor.
* @param pitch
- * @return this <code>PlaybackSettings</code> instance.
+ * @return this <code>PlaybackParams</code> instance.
*/
- public PlaybackSettings setPitch(float pitch) {
+ public PlaybackParams setPitch(float pitch) {
mPitch = pitch;
mSet |= SET_PITCH;
return this;
@@ -180,9 +180,9 @@ public final class PlaybackSettings {
/**
* Sets the speed factor.
* @param speed
- * @return this <code>PlaybackSettings</code> instance.
+ * @return this <code>PlaybackParams</code> instance.
*/
- public PlaybackSettings setSpeed(float speed) {
+ public PlaybackParams setSpeed(float speed) {
mSpeed = speed;
mSet |= SET_SPEED;
return this;
diff --git a/media/java/android/media/SyncSettings.java b/media/java/android/media/SyncParams.java
index 9740147..00a8dc0 100644
--- a/media/java/android/media/SyncSettings.java
+++ b/media/java/android/media/SyncParams.java
@@ -22,31 +22,31 @@ import java.lang.annotation.RetentionPolicy;
import android.annotation.IntDef;
/**
- * Structure for common A/V sync settings.
+ * Structure for common A/V sync params.
*
- * Used by {@link MediaSync} {link MediaSync#getSyncSettings()} and
- * {link MediaSync#setSyncSettings(SyncSettings)}
+ * Used by {@link MediaSync} {link MediaSync#getSyncParams()} and
+ * {link MediaSync#setSyncParams(SyncParams)}
* to control A/V sync behavior.
* <p> <strong>audio adjust mode:</strong>
* select handling of audio track when changing playback speed due to sync.
* <ul>
- * <li> {@link SyncSettings#AUDIO_ADJUST_MODE_DEFAULT}:
+ * <li> {@link SyncParams#AUDIO_ADJUST_MODE_DEFAULT}:
* System will determine best handling. </li>
- * <li> {@link SyncSettings#AUDIO_ADJUST_MODE_STRETCH}:
+ * <li> {@link SyncParams#AUDIO_ADJUST_MODE_STRETCH}:
* Change the speed of audio playback without altering its pitch.</li>
- * <li> {@link SyncSettings#AUDIO_ADJUST_MODE_RESAMPLE}:
+ * <li> {@link SyncParams#AUDIO_ADJUST_MODE_RESAMPLE}:
* Change the speed of audio playback by resampling the audio.</li>
* </ul>
* <p> <strong>sync source:</strong> select
* clock source for sync.
* <ul>
- * <li> {@link SyncSettings#SYNC_SOURCE_DEFAULT}:
+ * <li> {@link SyncParams#SYNC_SOURCE_DEFAULT}:
* System will determine best selection.</li>
- * <li> {@link SyncSettings#SYNC_SOURCE_SYSTEM_CLOCK}:
+ * <li> {@link SyncParams#SYNC_SOURCE_SYSTEM_CLOCK}:
* Use system clock for sync source.</li>
- * <li> {@link SyncSettings#SYNC_SOURCE_AUDIO}:
+ * <li> {@link SyncParams#SYNC_SOURCE_AUDIO}:
* Use audio track for sync source.</li>
- * <li> {@link SyncSettings#SYNC_SOURCE_VSYNC}:
+ * <li> {@link SyncParams#SYNC_SOURCE_VSYNC}:
* Syncronize media to vsync.</li>
* </ul>
* <p> <strong>tolerance:</strong> specifies the amount of allowed playback rate
@@ -55,7 +55,7 @@ import android.annotation.IntDef;
* <p> <strong>frameRate:</strong> initial hint for video frame rate. Used when
* sync source is vsync.
*/
-public final class SyncSettings {
+public final class SyncParams {
/** @hide */
@IntDef(
value = {
@@ -155,14 +155,14 @@ public final class SyncSettings {
*/
public static final int AUDIO_ADJUST_MODE_RESAMPLE = 2;
- // flags to indicate which settings are actually set
+ // flags to indicate which params are actually set
private static final int SET_SYNC_SOURCE = 1 << 0;
private static final int SET_AUDIO_ADJUST_MODE = 1 << 1;
private static final int SET_TOLERANCE = 1 << 2;
private static final int SET_FRAME_RATE = 1 << 3;
private int mSet = 0;
- // settings
+ // params
private int mAudioAdjustMode = AUDIO_ADJUST_MODE_STRETCH;
private int mSyncSource = SYNC_SOURCE_DEFAULT;
private float mTolerance = 0.f;
@@ -173,9 +173,9 @@ public final class SyncSettings {
* Otherwise a {@link java.lang.IllegalArgumentException} exception
* is raised when getting those properties
* which have defaults but have never been set.
- * @return this <code>SyncSettings</code> instance.
+ * @return this <code>SyncParams</code> instance.
*/
- public SyncSettings allowDefaults() {
+ public SyncParams allowDefaults() {
mSet |= SET_SYNC_SOURCE | SET_AUDIO_ADJUST_MODE | SET_TOLERANCE;
return this;
}
@@ -183,9 +183,9 @@ public final class SyncSettings {
/**
* Sets the audio adjust mode.
* @param audioAdjustMode
- * @return this <code>SyncSettings</code> instance.
+ * @return this <code>SyncParams</code> instance.
*/
- public SyncSettings setAudioAdjustMode(@AudioAdjustMode int audioAdjustMode) {
+ public SyncParams setAudioAdjustMode(@AudioAdjustMode int audioAdjustMode) {
mAudioAdjustMode = audioAdjustMode;
mSet |= SET_AUDIO_ADJUST_MODE;
return this;
@@ -206,9 +206,9 @@ public final class SyncSettings {
/**
* Sets the sync source.
* @param syncSource
- * @return this <code>SyncSettings</code> instance.
+ * @return this <code>SyncParams</code> instance.
*/
- public SyncSettings setSyncSource(@SyncSource int syncSource) {
+ public SyncParams setSyncSource(@SyncSource int syncSource) {
mSyncSource = syncSource;
mSet |= SET_SYNC_SOURCE;
return this;
@@ -231,9 +231,9 @@ public final class SyncSettings {
* @param tolerance A non-negative number representing
* the maximum deviation of the playback rate from the playback rate
* set. ({@code abs(actual_rate - set_rate) / set_rate})
- * @return this <code>SyncSettings</code> instance.
+ * @return this <code>SyncParams</code> instance.
*/
- public SyncSettings setTolerance(float tolerance) {
+ public SyncParams setTolerance(float tolerance) {
mTolerance = tolerance;
mSet |= SET_TOLERANCE;
return this;
@@ -257,9 +257,9 @@ public final class SyncSettings {
* Sets the video frame rate hint to be used. By default the frame rate is unspecified.
* @param frameRate A non-negative number used as an initial hint on
* the video frame rate to be used when using vsync as the sync source.
- * @return this <code>SyncSettings</code> instance.
+ * @return this <code>SyncParams</code> instance.
*/
- public SyncSettings setFrameRate(float frameRate) {
+ public SyncParams setFrameRate(float frameRate) {
mFrameRate = frameRate;
mSet |= SET_FRAME_RATE;
return this;
diff --git a/media/jni/Android.mk b/media/jni/Android.mk
index dbb53b4..51d0140 100644
--- a/media/jni/Android.mk
+++ b/media/jni/Android.mk
@@ -20,7 +20,7 @@ LOCAL_SRC_FILES:= \
android_media_MediaScanner.cpp \
android_media_MediaSync.cpp \
android_media_ResampleInputStream.cpp \
- android_media_SyncSettings.cpp \
+ android_media_SyncParams.cpp \
android_media_Utils.cpp \
android_mtp_MtpDatabase.cpp \
android_mtp_MtpDevice.cpp \
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp
index 5b55a61..d8041f4 100644
--- a/media/jni/android_media_MediaPlayer.cpp
+++ b/media/jni/android_media_MediaPlayer.cpp
@@ -38,8 +38,8 @@
#include "utils/KeyedVector.h"
#include "utils/String8.h"
#include "android_media_MediaDataSource.h"
-#include "android_media_PlaybackSettings.h"
-#include "android_media_SyncSettings.h"
+#include "android_media_PlaybackParams.h"
+#include "android_media_SyncParams.h"
#include "android_media_Utils.h"
#include "android_os_Parcel.h"
@@ -69,8 +69,8 @@ struct fields_t {
};
static fields_t fields;
-static PlaybackSettings::fields_t gPlaybackSettingsFields;
-static SyncSettings::fields_t gSyncSettingsFields;
+static PlaybackParams::fields_t gPlaybackParamsFields;
+static SyncParams::fields_t gSyncParamsFields;
static Mutex sLock;
@@ -428,7 +428,7 @@ android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz)
}
static void
-android_media_MediaPlayer_setPlaybackSettings(JNIEnv *env, jobject thiz, jobject settings)
+android_media_MediaPlayer_setPlaybackParams(JNIEnv *env, jobject thiz, jobject params)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL) {
@@ -436,32 +436,32 @@ android_media_MediaPlayer_setPlaybackSettings(JNIEnv *env, jobject thiz, jobject
return;
}
- PlaybackSettings pbs;
- pbs.fillFromJobject(env, gPlaybackSettingsFields, settings);
- ALOGV("setPlaybackSettings: %d:%f %d:%f %d:%u %d:%u",
- pbs.speedSet, pbs.audioRate.mSpeed,
- pbs.pitchSet, pbs.audioRate.mPitch,
- pbs.audioFallbackModeSet, pbs.audioRate.mFallbackMode,
- pbs.audioStretchModeSet, pbs.audioRate.mStretchMode);
+ PlaybackParams pbp;
+ pbp.fillFromJobject(env, gPlaybackParamsFields, params);
+ ALOGV("setPlaybackParams: %d:%f %d:%f %d:%u %d:%u",
+ pbp.speedSet, pbp.audioRate.mSpeed,
+ pbp.pitchSet, pbp.audioRate.mPitch,
+ pbp.audioFallbackModeSet, pbp.audioRate.mFallbackMode,
+ pbp.audioStretchModeSet, pbp.audioRate.mStretchMode);
AudioPlaybackRate rate;
status_t err = mp->getPlaybackSettings(&rate);
if (err == OK) {
bool updatedRate = false;
- if (pbs.speedSet) {
- rate.mSpeed = pbs.audioRate.mSpeed;
+ if (pbp.speedSet) {
+ rate.mSpeed = pbp.audioRate.mSpeed;
updatedRate = true;
}
- if (pbs.pitchSet) {
- rate.mPitch = pbs.audioRate.mPitch;
+ if (pbp.pitchSet) {
+ rate.mPitch = pbp.audioRate.mPitch;
updatedRate = true;
}
- if (pbs.audioFallbackModeSet) {
- rate.mFallbackMode = pbs.audioRate.mFallbackMode;
+ if (pbp.audioFallbackModeSet) {
+ rate.mFallbackMode = pbp.audioRate.mFallbackMode;
updatedRate = true;
}
- if (pbs.audioStretchModeSet) {
- rate.mStretchMode = pbs.audioRate.mStretchMode;
+ if (pbp.audioStretchModeSet) {
+ rate.mStretchMode = pbp.audioRate.mStretchMode;
updatedRate = true;
}
if (updatedRate) {
@@ -474,7 +474,7 @@ android_media_MediaPlayer_setPlaybackSettings(JNIEnv *env, jobject thiz, jobject
}
static jobject
-android_media_MediaPlayer_getPlaybackSettings(JNIEnv *env, jobject thiz)
+android_media_MediaPlayer_getPlaybackParams(JNIEnv *env, jobject thiz)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL) {
@@ -482,24 +482,24 @@ android_media_MediaPlayer_getPlaybackSettings(JNIEnv *env, jobject thiz)
return NULL;
}
- PlaybackSettings pbs;
- AudioPlaybackRate &audioRate = pbs.audioRate;
+ PlaybackParams pbp;
+ AudioPlaybackRate &audioRate = pbp.audioRate;
process_media_player_call(
env, thiz, mp->getPlaybackSettings(&audioRate),
"java/lang/IllegalStateException", "unexpected error");
ALOGV("getPlaybackSettings: %f %f %d %d",
audioRate.mSpeed, audioRate.mPitch, audioRate.mFallbackMode, audioRate.mStretchMode);
- pbs.speedSet = true;
- pbs.pitchSet = true;
- pbs.audioFallbackModeSet = true;
- pbs.audioStretchModeSet = true;
+ pbp.speedSet = true;
+ pbp.pitchSet = true;
+ pbp.audioFallbackModeSet = true;
+ pbp.audioStretchModeSet = true;
- return pbs.asJobject(env, gPlaybackSettingsFields);
+ return pbp.asJobject(env, gPlaybackParamsFields);
}
static void
-android_media_MediaPlayer_setSyncSettings(JNIEnv *env, jobject thiz, jobject settings)
+android_media_MediaPlayer_setSyncParams(JNIEnv *env, jobject thiz, jobject params)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL) {
@@ -507,33 +507,33 @@ android_media_MediaPlayer_setSyncSettings(JNIEnv *env, jobject thiz, jobject set
return;
}
- SyncSettings scs;
- scs.fillFromJobject(env, gSyncSettingsFields, settings);
- ALOGV("setSyncSettings: %d:%d %d:%d %d:%f %d:%f",
- scs.syncSourceSet, scs.sync.mSource,
- scs.audioAdjustModeSet, scs.sync.mAudioAdjustMode,
- scs.toleranceSet, scs.sync.mTolerance,
- scs.frameRateSet, scs.frameRate);
+ SyncParams scp;
+ scp.fillFromJobject(env, gSyncParamsFields, params);
+ ALOGV("setSyncParams: %d:%d %d:%d %d:%f %d:%f",
+ scp.syncSourceSet, scp.sync.mSource,
+ scp.audioAdjustModeSet, scp.sync.mAudioAdjustMode,
+ scp.toleranceSet, scp.sync.mTolerance,
+ scp.frameRateSet, scp.frameRate);
AVSyncSettings avsync;
float videoFrameRate;
status_t err = mp->getSyncSettings(&avsync, &videoFrameRate);
if (err == OK) {
- bool updatedSync = scs.frameRateSet;
- if (scs.syncSourceSet) {
- avsync.mSource = scs.sync.mSource;
+ bool updatedSync = scp.frameRateSet;
+ if (scp.syncSourceSet) {
+ avsync.mSource = scp.sync.mSource;
updatedSync = true;
}
- if (scs.audioAdjustModeSet) {
- avsync.mAudioAdjustMode = scs.sync.mAudioAdjustMode;
+ if (scp.audioAdjustModeSet) {
+ avsync.mAudioAdjustMode = scp.sync.mAudioAdjustMode;
updatedSync = true;
}
- if (scs.toleranceSet) {
- avsync.mTolerance = scs.sync.mTolerance;
+ if (scp.toleranceSet) {
+ avsync.mTolerance = scp.sync.mTolerance;
updatedSync = true;
}
if (updatedSync) {
- err = mp->setSyncSettings(avsync, scs.frameRateSet ? scs.frameRate : -1.f);
+ err = mp->setSyncSettings(avsync, scp.frameRateSet ? scp.frameRate : -1.f);
}
}
process_media_player_call(
@@ -542,7 +542,7 @@ android_media_MediaPlayer_setSyncSettings(JNIEnv *env, jobject thiz, jobject set
}
static jobject
-android_media_MediaPlayer_getSyncSettings(JNIEnv *env, jobject thiz)
+android_media_MediaPlayer_getSyncParams(JNIEnv *env, jobject thiz)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL) {
@@ -550,30 +550,30 @@ android_media_MediaPlayer_getSyncSettings(JNIEnv *env, jobject thiz)
return NULL;
}
- SyncSettings scs;
- scs.frameRate = -1.f;
+ SyncParams scp;
+ scp.frameRate = -1.f;
process_media_player_call(
- env, thiz, mp->getSyncSettings(&scs.sync, &scs.frameRate),
+ env, thiz, mp->getSyncSettings(&scp.sync, &scp.frameRate),
"java/lang/IllegalStateException", "unexpected error");
ALOGV("getSyncSettings: %d %d %f %f",
- scs.sync.mSource, scs.sync.mAudioAdjustMode, scs.sync.mTolerance, scs.frameRate);
+ scp.sync.mSource, scp.sync.mAudioAdjustMode, scp.sync.mTolerance, scp.frameRate);
- // sanity check settings
- if (scs.sync.mSource >= AVSYNC_SOURCE_MAX
- || scs.sync.mAudioAdjustMode >= AVSYNC_AUDIO_ADJUST_MODE_MAX
- || scs.sync.mTolerance < 0.f
- || scs.sync.mTolerance >= AVSYNC_TOLERANCE_MAX) {
+ // sanity check params
+ if (scp.sync.mSource >= AVSYNC_SOURCE_MAX
+ || scp.sync.mAudioAdjustMode >= AVSYNC_AUDIO_ADJUST_MODE_MAX
+ || scp.sync.mTolerance < 0.f
+ || scp.sync.mTolerance >= AVSYNC_TOLERANCE_MAX) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
return NULL;
}
- scs.syncSourceSet = true;
- scs.audioAdjustModeSet = true;
- scs.toleranceSet = true;
- scs.frameRateSet = scs.frameRate >= 0.f;
+ scp.syncSourceSet = true;
+ scp.audioAdjustModeSet = true;
+ scp.toleranceSet = true;
+ scp.frameRateSet = scp.frameRate >= 0.f;
- return scs.asJobject(env, gSyncSettingsFields);
+ return scp.asJobject(env, gSyncParamsFields);
}
static void
@@ -860,8 +860,8 @@ android_media_MediaPlayer_native_init(JNIEnv *env)
env->DeleteLocalRef(clazz);
- gPlaybackSettingsFields.init(env);
- gSyncSettingsFields.init(env);
+ gPlaybackParamsFields.init(env);
+ gSyncParamsFields.init(env);
}
static void
@@ -1050,10 +1050,10 @@ static JNINativeMethod gMethods[] = {
{"_stop", "()V", (void *)android_media_MediaPlayer_stop},
{"getVideoWidth", "()I", (void *)android_media_MediaPlayer_getVideoWidth},
{"getVideoHeight", "()I", (void *)android_media_MediaPlayer_getVideoHeight},
- {"setPlaybackSettings", "(Landroid/media/PlaybackSettings;)V", (void *)android_media_MediaPlayer_setPlaybackSettings},
- {"getPlaybackSettings", "()Landroid/media/PlaybackSettings;", (void *)android_media_MediaPlayer_getPlaybackSettings},
- {"setSyncSettings", "(Landroid/media/SyncSettings;)V", (void *)android_media_MediaPlayer_setSyncSettings},
- {"getSyncSettings", "()Landroid/media/SyncSettings;", (void *)android_media_MediaPlayer_getSyncSettings},
+ {"setPlaybackParams", "(Landroid/media/PlaybackParams;)V", (void *)android_media_MediaPlayer_setPlaybackParams},
+ {"getPlaybackParams", "()Landroid/media/PlaybackParams;", (void *)android_media_MediaPlayer_getPlaybackParams},
+ {"setSyncParams", "(Landroid/media/SyncParams;)V", (void *)android_media_MediaPlayer_setSyncParams},
+ {"getSyncParams", "()Landroid/media/SyncParams;", (void *)android_media_MediaPlayer_getSyncParams},
{"seekTo", "(I)V", (void *)android_media_MediaPlayer_seekTo},
{"_pause", "()V", (void *)android_media_MediaPlayer_pause},
{"isPlaying", "()Z", (void *)android_media_MediaPlayer_isPlaying},
diff --git a/media/jni/android_media_MediaSync.cpp b/media/jni/android_media_MediaSync.cpp
index 5c18901..8e0ed64 100644
--- a/media/jni/android_media_MediaSync.cpp
+++ b/media/jni/android_media_MediaSync.cpp
@@ -21,8 +21,8 @@
#include "android_media_MediaSync.h"
#include "android_media_AudioTrack.h"
-#include "android_media_PlaybackSettings.h"
-#include "android_media_SyncSettings.h"
+#include "android_media_PlaybackParams.h"
+#include "android_media_SyncParams.h"
#include "android_runtime/AndroidRuntime.h"
#include "android_runtime/android_view_Surface.h"
#include "jni.h"
@@ -49,8 +49,8 @@ struct fields_t {
};
static fields_t gFields;
-static PlaybackSettings::fields_t gPlaybackSettingsFields;
-static SyncSettings::fields_t gSyncSettingsFields;
+static PlaybackParams::fields_t gPlaybackParamsFields;
+static SyncParams::fields_t gSyncParamsFields;
////////////////////////////////////////////////////////////////////////////////
@@ -78,20 +78,20 @@ sp<const MediaClock> JMediaSync::getMediaClock() {
return mSync->getMediaClock();
}
-status_t JMediaSync::setPlaybackSettings(const AudioPlaybackRate& rate) {
+status_t JMediaSync::setPlaybackParams(const AudioPlaybackRate& rate) {
return mSync->setPlaybackSettings(rate);
}
-void JMediaSync::getPlaybackSettings(AudioPlaybackRate* rate /* nonnull */) {
+void JMediaSync::getPlaybackParams(AudioPlaybackRate* rate /* nonnull */) {
mSync->getPlaybackSettings(rate);
}
-status_t JMediaSync::setSyncSettings(const AVSyncSettings& syncSettings) {
- return mSync->setSyncSettings(syncSettings);
+status_t JMediaSync::setSyncParams(const AVSyncSettings& syncParams) {
+ return mSync->setSyncSettings(syncParams);
}
-void JMediaSync::getSyncSettings(AVSyncSettings* syncSettings /* nonnull */) {
- mSync->getSyncSettings(syncSettings);
+void JMediaSync::getSyncParams(AVSyncSettings* syncParams /* nonnull */) {
+ mSync->getSyncSettings(syncParams);
}
status_t JMediaSync::setVideoFrameRateHint(float rate) {
@@ -308,24 +308,24 @@ static jlong android_media_MediaSync_native_getPlayTimeForPendingAudioFrames(
return (jlong)playTimeUs;
}
-static jfloat android_media_MediaSync_setPlaybackSettings(
- JNIEnv *env, jobject thiz, jobject settings) {
+static jfloat android_media_MediaSync_setPlaybackParams(
+ JNIEnv *env, jobject thiz, jobject params) {
sp<JMediaSync> sync = getMediaSync(env, thiz);
if (sync == NULL) {
throwExceptionAsNecessary(env, INVALID_OPERATION);
return (jfloat)0.f;
}
- PlaybackSettings pbs;
- pbs.fillFromJobject(env, gPlaybackSettingsFields, settings);
- ALOGV("setPlaybackSettings: %d:%f %d:%f %d:%u %d:%u",
+ PlaybackParams pbs;
+ pbs.fillFromJobject(env, gPlaybackParamsFields, params);
+ ALOGV("setPlaybackParams: %d:%f %d:%f %d:%u %d:%u",
pbs.speedSet, pbs.audioRate.mSpeed,
pbs.pitchSet, pbs.audioRate.mPitch,
pbs.audioFallbackModeSet, pbs.audioRate.mFallbackMode,
pbs.audioStretchModeSet, pbs.audioRate.mStretchMode);
AudioPlaybackRate rate;
- sync->getPlaybackSettings(&rate);
+ sync->getPlaybackParams(&rate);
bool updatedRate = false;
if (pbs.speedSet) {
rate.mSpeed = pbs.audioRate.mSpeed;
@@ -344,7 +344,7 @@ static jfloat android_media_MediaSync_setPlaybackSettings(
updatedRate = true;
}
if (updatedRate) {
- status_t err = sync->setPlaybackSettings(rate);
+ status_t err = sync->setPlaybackParams(rate);
if (err != OK) {
throwExceptionAsNecessary(env, err);
return (jfloat)0.f;
@@ -359,7 +359,7 @@ static jfloat android_media_MediaSync_setPlaybackSettings(
return (jfloat)mediaClock->getPlaybackRate();
}
-static jobject android_media_MediaSync_getPlaybackSettings(
+static jobject android_media_MediaSync_getPlaybackParams(
JNIEnv *env, jobject thiz) {
sp<JMediaSync> sync = getMediaSync(env, thiz);
if (sync == NULL) {
@@ -367,10 +367,10 @@ static jobject android_media_MediaSync_getPlaybackSettings(
return NULL;
}
- PlaybackSettings pbs;
+ PlaybackParams pbs;
AudioPlaybackRate &audioRate = pbs.audioRate;
- sync->getPlaybackSettings(&audioRate);
- ALOGV("getPlaybackSettings: %f %f %d %d",
+ sync->getPlaybackParams(&audioRate);
+ ALOGV("getPlaybackParams: %f %f %d %d",
audioRate.mSpeed, audioRate.mPitch, audioRate.mFallbackMode, audioRate.mStretchMode);
pbs.speedSet = true;
@@ -378,27 +378,27 @@ static jobject android_media_MediaSync_getPlaybackSettings(
pbs.audioFallbackModeSet = true;
pbs.audioStretchModeSet = true;
- return pbs.asJobject(env, gPlaybackSettingsFields);
+ return pbs.asJobject(env, gPlaybackParamsFields);
}
-static jfloat android_media_MediaSync_setSyncSettings(
- JNIEnv *env, jobject thiz, jobject settings) {
+static jfloat android_media_MediaSync_setSyncParams(
+ JNIEnv *env, jobject thiz, jobject params) {
sp<JMediaSync> sync = getMediaSync(env, thiz);
if (sync == NULL) {
throwExceptionAsNecessary(env, INVALID_OPERATION);
return (jfloat)0.f;
}
- SyncSettings scs;
- scs.fillFromJobject(env, gSyncSettingsFields, settings);
- ALOGV("setSyncSettings: %d:%d %d:%d %d:%f %d:%f",
+ SyncParams scs;
+ scs.fillFromJobject(env, gSyncParamsFields, params);
+ ALOGV("setSyncParams: %d:%d %d:%d %d:%f %d:%f",
scs.syncSourceSet, scs.sync.mSource,
scs.audioAdjustModeSet, scs.sync.mAudioAdjustMode,
scs.toleranceSet, scs.sync.mTolerance,
scs.frameRateSet, scs.frameRate);
AVSyncSettings avsync;
- sync->getSyncSettings(&avsync);
+ sync->getSyncParams(&avsync);
bool updatedSync = false;
status_t err = OK;
if (scs.syncSourceSet) {
@@ -414,7 +414,7 @@ static jfloat android_media_MediaSync_setSyncSettings(
updatedSync = true;
}
if (updatedSync) {
- err = sync->setSyncSettings(avsync);
+ err = sync->setSyncParams(avsync);
}
if (scs.frameRateSet && err == OK) {
@@ -433,21 +433,21 @@ static jfloat android_media_MediaSync_setSyncSettings(
return (jfloat)mediaClock->getPlaybackRate();
}
-static jobject android_media_MediaSync_getSyncSettings(JNIEnv *env, jobject thiz) {
+static jobject android_media_MediaSync_getSyncParams(JNIEnv *env, jobject thiz) {
sp<JMediaSync> sync = getMediaSync(env, thiz);
if (sync == NULL) {
throwExceptionAsNecessary(env, INVALID_OPERATION);
return NULL;
}
- SyncSettings scs;
- sync->getSyncSettings(&scs.sync);
+ SyncParams scs;
+ sync->getSyncParams(&scs.sync);
scs.frameRate = sync->getVideoFrameRate();
- ALOGV("getSyncSettings: %d %d %f %f",
+ ALOGV("getSyncParams: %d %d %f %f",
scs.sync.mSource, scs.sync.mAudioAdjustMode, scs.sync.mTolerance, scs.frameRate);
- // sanity check settings
+ // sanity check params
if (scs.sync.mSource >= AVSYNC_SOURCE_MAX
|| scs.sync.mAudioAdjustMode >= AVSYNC_AUDIO_ADJUST_MODE_MAX
|| scs.sync.mTolerance < 0.f
@@ -461,7 +461,7 @@ static jobject android_media_MediaSync_getSyncSettings(JNIEnv *env, jobject thiz
scs.toleranceSet = true;
scs.frameRateSet = scs.frameRate >= 0.f;
- return scs.asJobject(env, gSyncSettingsFields);
+ return scs.asJobject(env, gSyncParamsFields);
}
static void android_media_MediaSync_native_init(JNIEnv *env) {
@@ -486,8 +486,8 @@ static void android_media_MediaSync_native_init(JNIEnv *env) {
env->GetFieldID(clazz.get(), "clockRate", "F");
CHECK(gFields.mediaTimestampClockRateID != NULL);
- gSyncSettingsFields.init(env);
- gPlaybackSettingsFields.init(env);
+ gSyncParamsFields.init(env);
+ gPlaybackParamsFields.init(env);
}
static void android_media_MediaSync_native_setup(JNIEnv *env, jobject thiz) {
@@ -530,17 +530,17 @@ static JNINativeMethod gMethods[] = {
{ "native_release", "()V", (void *)android_media_MediaSync_release },
- { "native_setPlaybackSettings", "(Landroid/media/PlaybackSettings;)F",
- (void *)android_media_MediaSync_setPlaybackSettings },
+ { "native_setPlaybackParams", "(Landroid/media/PlaybackParams;)F",
+ (void *)android_media_MediaSync_setPlaybackParams },
- { "getPlaybackSettings", "()Landroid/media/PlaybackSettings;",
- (void *)android_media_MediaSync_getPlaybackSettings },
+ { "getPlaybackParams", "()Landroid/media/PlaybackParams;",
+ (void *)android_media_MediaSync_getPlaybackParams },
- { "native_setSyncSettings", "(Landroid/media/SyncSettings;)F",
- (void *)android_media_MediaSync_setSyncSettings },
+ { "native_setSyncParams", "(Landroid/media/SyncParams;)F",
+ (void *)android_media_MediaSync_setSyncParams },
- { "getSyncSettings", "()Landroid/media/SyncSettings;",
- (void *)android_media_MediaSync_getSyncSettings },
+ { "getSyncParams", "()Landroid/media/SyncParams;",
+ (void *)android_media_MediaSync_getSyncParams },
{ "native_finalize", "()V", (void *)android_media_MediaSync_native_finalize },
};
diff --git a/media/jni/android_media_MediaSync.h b/media/jni/android_media_MediaSync.h
index 5823057..22c77c7 100644
--- a/media/jni/android_media_MediaSync.h
+++ b/media/jni/android_media_MediaSync.h
@@ -42,10 +42,10 @@ struct JMediaSync : public RefBase {
status_t getPlayTimeForPendingAudioFrames(int64_t *outTimeUs);
- status_t setPlaybackSettings(const AudioPlaybackRate& rate);
- void getPlaybackSettings(AudioPlaybackRate* rate /* nonnull */);
- status_t setSyncSettings(const AVSyncSettings& syncSettings);
- void getSyncSettings(AVSyncSettings* syncSettings /* nonnull */);
+ status_t setPlaybackParams(const AudioPlaybackRate& rate);
+ void getPlaybackParams(AudioPlaybackRate* rate /* nonnull */);
+ status_t setSyncParams(const AVSyncSettings& syncParams);
+ void getSyncParams(AVSyncSettings* syncParams /* nonnull */);
status_t setVideoFrameRateHint(float rate);
float getVideoFrameRate();
diff --git a/media/jni/android_media_PlaybackSettings.h b/media/jni/android_media_PlaybackParams.h
index 1f4f256..5bf13e9 100644
--- a/media/jni/android_media_PlaybackSettings.h
+++ b/media/jni/android_media_PlaybackParams.h
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-#ifndef _ANDROID_MEDIA_PLAYBACK_SETTINGS_H_
-#define _ANDROID_MEDIA_PLAYBACK_SETTINGS_H_
+#ifndef _ANDROID_MEDIA_PLAYBACK_PARAMS_H_
+#define _ANDROID_MEDIA_PLAYBACK_PARAMS_H_
#include <media/AudioResamplerPublic.h>
namespace android {
// This entire class is inline as it is used from both core and media
-struct PlaybackSettings {
+struct PlaybackParams {
AudioPlaybackRate audioRate;
bool speedSet;
bool pitchSet;
@@ -44,7 +44,7 @@ struct PlaybackSettings {
jint set_audio_stretch_mode;
void init(JNIEnv *env) {
- jclass lclazz = env->FindClass("android/media/PlaybackSettings");
+ jclass lclazz = env->FindClass("android/media/PlaybackParams");
if (lclazz == NULL) {
return;
}
@@ -80,14 +80,14 @@ struct PlaybackSettings {
}
};
- void fillFromJobject(JNIEnv *env, const fields_t& fields, jobject settings) {
- audioRate.mSpeed = env->GetFloatField(settings, fields.speed);
- audioRate.mPitch = env->GetFloatField(settings, fields.pitch);
+ void fillFromJobject(JNIEnv *env, const fields_t& fields, jobject params) {
+ audioRate.mSpeed = env->GetFloatField(params, fields.speed);
+ audioRate.mPitch = env->GetFloatField(params, fields.pitch);
audioRate.mFallbackMode =
- (AudioTimestretchFallbackMode)env->GetIntField(settings, fields.audio_fallback_mode);
+ (AudioTimestretchFallbackMode)env->GetIntField(params, fields.audio_fallback_mode);
audioRate.mStretchMode =
- (AudioTimestretchStretchMode)env->GetIntField(settings, fields.audio_stretch_mode);
- int set = env->GetIntField(settings, fields.set);
+ (AudioTimestretchStretchMode)env->GetIntField(params, fields.audio_stretch_mode);
+ int set = env->GetIntField(params, fields.set);
speedSet = set & fields.set_speed;
pitchSet = set & fields.set_pitch;
@@ -96,25 +96,25 @@ struct PlaybackSettings {
}
jobject asJobject(JNIEnv *env, const fields_t& fields) {
- jobject settings = env->NewObject(fields.clazz, fields.constructID);
- if (settings == NULL) {
+ jobject params = env->NewObject(fields.clazz, fields.constructID);
+ if (params == NULL) {
return NULL;
}
- env->SetFloatField(settings, fields.speed, (jfloat)audioRate.mSpeed);
- env->SetFloatField(settings, fields.pitch, (jfloat)audioRate.mPitch);
- env->SetIntField(settings, fields.audio_fallback_mode, (jint)audioRate.mFallbackMode);
- env->SetIntField(settings, fields.audio_stretch_mode, (jint)audioRate.mStretchMode);
+ env->SetFloatField(params, fields.speed, (jfloat)audioRate.mSpeed);
+ env->SetFloatField(params, fields.pitch, (jfloat)audioRate.mPitch);
+ env->SetIntField(params, fields.audio_fallback_mode, (jint)audioRate.mFallbackMode);
+ env->SetIntField(params, fields.audio_stretch_mode, (jint)audioRate.mStretchMode);
env->SetIntField(
- settings, fields.set,
+ params, fields.set,
(speedSet ? fields.set_speed : 0)
| (pitchSet ? fields.set_pitch : 0)
| (audioFallbackModeSet ? fields.set_audio_fallback_mode : 0)
| (audioStretchModeSet ? fields.set_audio_stretch_mode : 0));
- return settings;
+ return params;
}
};
} // namespace android
-#endif // _ANDROID_MEDIA_PLAYBACK_SETTINGS_H_
+#endif // _ANDROID_MEDIA_PLAYBACK_PARAMS_H_
diff --git a/media/jni/android_media_SyncSettings.cpp b/media/jni/android_media_SyncParams.cpp
index 5da35e7..d9b2f1d 100644
--- a/media/jni/android_media_SyncSettings.cpp
+++ b/media/jni/android_media_SyncParams.cpp
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-#include "android_media_SyncSettings.h"
+#include "android_media_SyncParams.h"
#include "JNIHelp.h"
namespace android {
-void SyncSettings::fields_t::init(JNIEnv *env) {
- jclass lclazz = env->FindClass("android/media/SyncSettings");
+void SyncParams::fields_t::init(JNIEnv *env) {
+ jclass lclazz = env->FindClass("android/media/SyncParams");
if (lclazz == NULL) {
return;
}
@@ -51,17 +51,17 @@ void SyncSettings::fields_t::init(JNIEnv *env) {
env->DeleteLocalRef(lclazz);
}
-void SyncSettings::fields_t::exit(JNIEnv *env) {
+void SyncParams::fields_t::exit(JNIEnv *env) {
env->DeleteGlobalRef(clazz);
clazz = NULL;
}
-void SyncSettings::fillFromJobject(JNIEnv *env, const fields_t& fields, jobject settings) {
- sync.mSource = (AVSyncSource)env->GetIntField(settings, fields.sync_source);
- sync.mAudioAdjustMode = (AVSyncAudioAdjustMode)env->GetIntField(settings, fields.audio_adjust_mode);
- sync.mTolerance = env->GetFloatField(settings, fields.tolerance);
- frameRate = env->GetFloatField(settings, fields.frame_rate);
- int set = env->GetIntField(settings, fields.set);
+void SyncParams::fillFromJobject(JNIEnv *env, const fields_t& fields, jobject params) {
+ sync.mSource = (AVSyncSource)env->GetIntField(params, fields.sync_source);
+ sync.mAudioAdjustMode = (AVSyncAudioAdjustMode)env->GetIntField(params, fields.audio_adjust_mode);
+ sync.mTolerance = env->GetFloatField(params, fields.tolerance);
+ frameRate = env->GetFloatField(params, fields.frame_rate);
+ int set = env->GetIntField(params, fields.set);
syncSourceSet = set & fields.set_sync_source;
audioAdjustModeSet = set & fields.set_audio_adjust_mode;
@@ -69,23 +69,23 @@ void SyncSettings::fillFromJobject(JNIEnv *env, const fields_t& fields, jobject
frameRateSet = set & fields.set_frame_rate;
}
-jobject SyncSettings::asJobject(JNIEnv *env, const fields_t& fields) {
- jobject settings = env->NewObject(fields.clazz, fields.constructID);
- if (settings == NULL) {
+jobject SyncParams::asJobject(JNIEnv *env, const fields_t& fields) {
+ jobject params = env->NewObject(fields.clazz, fields.constructID);
+ if (params == NULL) {
return NULL;
}
- env->SetIntField(settings, fields.sync_source, (jint)sync.mSource);
- env->SetIntField(settings, fields.audio_adjust_mode, (jint)sync.mAudioAdjustMode);
- env->SetFloatField(settings, fields.tolerance, (jfloat)sync.mTolerance);
- env->SetFloatField(settings, fields.frame_rate, (jfloat)frameRate);
+ env->SetIntField(params, fields.sync_source, (jint)sync.mSource);
+ env->SetIntField(params, fields.audio_adjust_mode, (jint)sync.mAudioAdjustMode);
+ env->SetFloatField(params, fields.tolerance, (jfloat)sync.mTolerance);
+ env->SetFloatField(params, fields.frame_rate, (jfloat)frameRate);
env->SetIntField(
- settings, fields.set,
+ params, fields.set,
(syncSourceSet ? fields.set_sync_source : 0)
| (audioAdjustModeSet ? fields.set_audio_adjust_mode : 0)
| (toleranceSet ? fields.set_tolerance : 0)
| (frameRateSet ? fields.set_frame_rate : 0));
- return settings;
+ return params;
}
} // namespace android
diff --git a/media/jni/android_media_SyncSettings.h b/media/jni/android_media_SyncParams.h
index 23530db..543d79a 100644
--- a/media/jni/android_media_SyncSettings.h
+++ b/media/jni/android_media_SyncParams.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef _ANDROID_MEDIA_SYNC_SETTINGS_H_
-#define _ANDROID_MEDIA_SYNC_SETTINGS_H_
+#ifndef _ANDROID_MEDIA_SYNC_PARAMS_H_
+#define _ANDROID_MEDIA_SYNC_PARAMS_H_
#include "jni.h"
@@ -23,7 +23,7 @@
namespace android {
-struct SyncSettings {
+struct SyncParams {
AVSyncSettings sync;
float frameRate;
@@ -53,13 +53,13 @@ struct SyncSettings {
void exit(JNIEnv *env);
};
- // fills this from an android.media.SyncSettings object
- void fillFromJobject(JNIEnv *env, const fields_t& fields, jobject settings);
+ // fills this from an android.media.SyncParams object
+ void fillFromJobject(JNIEnv *env, const fields_t& fields, jobject params);
- // returns this as a android.media.SyncSettings object
+ // returns this as a android.media.SyncParams object
jobject asJobject(JNIEnv *env, const fields_t& fields);
};
} // namespace android
-#endif // _ANDROID_MEDIA_SYNC_SETTINGS_H_
+#endif // _ANDROID_MEDIA_SYNC_PARAMS_H_