Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9020aff authored by Lajos Molnar's avatar Lajos Molnar
Browse files

media: clarify valid values in PlaybackParams and SyncParams

Bug: 21134712
Change-Id: I42182733013d70e11d8c59bf4f5daa7eeb374597
parent 50ba032f
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -158,8 +158,12 @@ public final class PlaybackParams {
     * Sets the pitch factor.
     * Sets the pitch factor.
     * @param pitch
     * @param pitch
     * @return this <code>PlaybackParams</code> instance.
     * @return this <code>PlaybackParams</code> instance.
     * @throws InvalidArgumentException if the pitch is negative
     */
     */
    public PlaybackParams setPitch(float pitch) {
    public PlaybackParams setPitch(float pitch) {
        if (pitch < 0.f) {
            throw new IllegalArgumentException("pitch must not be negative");
        }
        mPitch = pitch;
        mPitch = pitch;
        mSet |= SET_PITCH;
        mSet |= SET_PITCH;
        return this;
        return this;
+12 −6
Original line number Original line Diff line number Diff line
@@ -51,9 +51,9 @@ import android.annotation.IntDef;
 * </ul>
 * </ul>
 * <p> <strong>tolerance:</strong> specifies the amount of allowed playback rate
 * <p> <strong>tolerance:</strong> specifies the amount of allowed playback rate
 * change to keep media in sync with the sync source. The handling of this depends
 * change to keep media in sync with the sync source. The handling of this depends
 * on the sync source.
 * on the sync source, but must not be negative, and must be less than one.
 * <p> <strong>frameRate:</strong> initial hint for video frame rate. Used when
 * <p> <strong>frameRate:</strong> initial hint for video frame rate. Used when
 * sync source is vsync.
 * sync source is vsync. Negative values can be used to clear a previous hint.
 */
 */
public final class SyncParams {
public final class SyncParams {
    /** @hide */
    /** @hide */
@@ -163,7 +163,7 @@ public final class SyncParams {
    private int mSet = 0;
    private int mSet = 0;


    // params
    // params
    private int mAudioAdjustMode = AUDIO_ADJUST_MODE_STRETCH;
    private int mAudioAdjustMode = AUDIO_ADJUST_MODE_DEFAULT;
    private int mSyncSource = SYNC_SOURCE_DEFAULT;
    private int mSyncSource = SYNC_SOURCE_DEFAULT;
    private float mTolerance = 0.f;
    private float mTolerance = 0.f;
    private float mFrameRate = 0.f;
    private float mFrameRate = 0.f;
@@ -227,13 +227,17 @@ public final class SyncParams {
    }
    }


    /**
    /**
     * Sets the tolerance. The default tolerance is 0.
     * Sets the tolerance. The default tolerance is platform specific, but is never more than 1/24.
     * @param tolerance A non-negative number representing
     * @param tolerance A non-negative number representing
     *     the maximum deviation of the playback rate from the playback rate
     *     the maximum deviation of the playback rate from the playback rate
     *     set. ({@code abs(actual_rate - set_rate) / set_rate})
     *     set. ({@code abs(actual_rate - set_rate) / set_rate})
     * @return this <code>SyncParams</code> instance.
     * @return this <code>SyncParams</code> instance.
     * @throws InvalidArgumentException if the tolerance is negative, or not less than one
     */
     */
    public SyncParams setTolerance(float tolerance) {
    public SyncParams setTolerance(float tolerance) {
        if (tolerance < 0.f || tolerance >= 1.f) {
            throw new IllegalArgumentException("tolerance must be less than one and non-negative");
        }
        mTolerance = tolerance;
        mTolerance = tolerance;
        mSet |= SET_TOLERANCE;
        mSet |= SET_TOLERANCE;
        return this;
        return this;
@@ -256,7 +260,8 @@ public final class SyncParams {
    /**
    /**
     * Sets the video frame rate hint to be used. By default the frame rate is unspecified.
     * 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
     * @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.
     *     the video frame rate to be used when using vsync as the sync source. A negative
     *     number is used to clear a previous hint.
     * @return this <code>SyncParams</code> instance.
     * @return this <code>SyncParams</code> instance.
     */
     */
    public SyncParams setFrameRate(float frameRate) {
    public SyncParams setFrameRate(float frameRate) {
@@ -269,7 +274,8 @@ public final class SyncParams {
     * Retrieves the video frame rate hint.
     * Retrieves the video frame rate hint.
     * @return frame rate factor. A non-negative number representing
     * @return frame rate factor. A non-negative number representing
     *     the maximum deviation of the playback rate from the playback rate
     *     the maximum deviation of the playback rate from the playback rate
     *     set. ({@code abs(actual_rate - set_rate) / set_rate})
     *     set. ({@code abs(actual_rate - set_rate) / set_rate}), or a negative
     *     number representing the desire to clear a previous hint using these params.
     * @throws IllegalStateException if frame rate is not set.
     * @throws IllegalStateException if frame rate is not set.
     */
     */
    public float getFrameRate() {
    public float getFrameRate() {