OSDN Git Service

Make PlaybackParams parcelable
authorJae Seo <jaeseo@google.com>
Sat, 16 May 2015 00:15:48 +0000 (17:15 -0700)
committerLajos Molnar <lajos@google.com>
Mon, 18 May 2015 17:54:47 +0000 (17:54 +0000)
Bug: 21170699
Change-Id: I31b446e0b772bdfb65166564e48aa93cf73b74ae

api/current.txt
api/system-current.txt
media/java/android/media/PlaybackParams.aidl [new file with mode: 0644]
media/java/android/media/PlaybackParams.java

index a400fa6..2cf8969 100644 (file)
@@ -16462,18 +16462,21 @@ package android.media {
     ctor public NotProvisionedException(java.lang.String);
   }
 
-  public final class PlaybackParams {
+  public final class PlaybackParams implements android.os.Parcelable {
     ctor public PlaybackParams();
     method public android.media.PlaybackParams allowDefaults();
+    method public int describeContents();
     method public int getAudioFallbackMode();
     method public float getPitch();
     method public float getSpeed();
     method public android.media.PlaybackParams setAudioFallbackMode(int);
     method public android.media.PlaybackParams setPitch(float);
     method public android.media.PlaybackParams setSpeed(float);
+    method public void writeToParcel(android.os.Parcel, int);
     field public static final int AUDIO_FALLBACK_MODE_DEFAULT = 0; // 0x0
     field public static final int AUDIO_FALLBACK_MODE_FAIL = 2; // 0x2
     field public static final int AUDIO_FALLBACK_MODE_MUTE = 1; // 0x1
+    field public static final android.os.Parcelable.Creator<android.media.PlaybackParams> CREATOR;
   }
 
   public final class Rating implements android.os.Parcelable {
index 14b56c7..4dcfd39 100644 (file)
@@ -17702,18 +17702,21 @@ package android.media {
     ctor public NotProvisionedException(java.lang.String);
   }
 
-  public final class PlaybackParams {
+  public final class PlaybackParams implements android.os.Parcelable {
     ctor public PlaybackParams();
     method public android.media.PlaybackParams allowDefaults();
+    method public int describeContents();
     method public int getAudioFallbackMode();
     method public float getPitch();
     method public float getSpeed();
     method public android.media.PlaybackParams setAudioFallbackMode(int);
     method public android.media.PlaybackParams setPitch(float);
     method public android.media.PlaybackParams setSpeed(float);
+    method public void writeToParcel(android.os.Parcel, int);
     field public static final int AUDIO_FALLBACK_MODE_DEFAULT = 0; // 0x0
     field public static final int AUDIO_FALLBACK_MODE_FAIL = 2; // 0x2
     field public static final int AUDIO_FALLBACK_MODE_MUTE = 1; // 0x1
+    field public static final android.os.Parcelable.Creator<android.media.PlaybackParams> CREATOR;
   }
 
   public final class Rating implements android.os.Parcelable {
diff --git a/media/java/android/media/PlaybackParams.aidl b/media/java/android/media/PlaybackParams.aidl
new file mode 100644 (file)
index 0000000..0356117
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media;
+
+parcelable PlaybackParams;
index e41b2b6..8810ac5 100644 (file)
 
 package android.media;
 
+import android.annotation.IntDef;
+import android.os.Parcel;
+import android.os.Parcelable;
+
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
-import android.annotation.IntDef;
-
 /**
  * Structure for common playback params.
  *
@@ -52,7 +54,7 @@ import android.annotation.IntDef;
  * similar to {@link AudioTrack#setPlaybackRate(int)}.</li>
  * </ul>
  */
-public final class PlaybackParams {
+public final class PlaybackParams implements Parcelable {
     /** @hide */
     @IntDef(
         value = {
@@ -94,6 +96,20 @@ public final class PlaybackParams {
     private float mPitch = 1.0f;
     private float mSpeed = 1.0f;
 
+    public PlaybackParams() {
+    }
+
+    private PlaybackParams(Parcel in) {
+        mSet = in.readInt();
+        mAudioFallbackMode = in.readInt();
+        mAudioStretchMode = in.readInt();
+        mPitch = in.readFloat();
+        if (mPitch < 0.f) {
+            mPitch = 0.f;
+        }
+        mSpeed = in.readFloat();
+    }
+
     /**
      * Allows defaults to be returned for properties not set.
      * Otherwise a {@link java.lang.IllegalArgumentException} exception
@@ -199,4 +215,32 @@ public final class PlaybackParams {
         }
         return mSpeed;
     }
+
+    public static final Parcelable.Creator<PlaybackParams> CREATOR =
+            new Parcelable.Creator<PlaybackParams>() {
+                @Override
+                public PlaybackParams createFromParcel(Parcel in) {
+                    return new PlaybackParams(in);
+                }
+
+                @Override
+                public PlaybackParams[] newArray(int size) {
+                    return new PlaybackParams[size];
+                }
+            };
+
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(mSet);
+        dest.writeInt(mAudioFallbackMode);
+        dest.writeInt(mAudioStretchMode);
+        dest.writeFloat(mPitch);
+        dest.writeFloat(mSpeed);
+    }
 }