From 5affc2b587323f55201d5db768b838505b5a4b72 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Mon, 22 Feb 2016 17:12:15 -0800 Subject: [PATCH] Make android.media.AudioFormat parcelable Bug 22876530 Change-Id: If027715aad32ce8796a7e223ba51c301a3dd1192 --- api/current.txt | 5 ++- api/removed.txt | 2 +- api/system-current.txt | 5 ++- api/system-removed.txt | 2 +- api/test-current.txt | 5 ++- api/test-removed.txt | 2 +- media/java/android/media/AudioFormat.aidl | 19 ++++++++++ media/java/android/media/AudioFormat.java | 43 ++++++++++++++++++++++- 8 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 media/java/android/media/AudioFormat.aidl diff --git a/api/current.txt b/api/current.txt index 1022ee1ab0efd..530828abe6d24 100644 --- a/api/current.txt +++ b/api/current.txt @@ -19706,12 +19706,14 @@ package android.media { field public static final int TYPE_WIRED_HEADSET = 3; // 0x3 } - public class AudioFormat { + public class AudioFormat implements android.os.Parcelable { + method public int describeContents(); method public int getChannelCount(); method public int getChannelIndexMask(); method public int getChannelMask(); method public int getEncoding(); method public int getSampleRate(); + method public void writeToParcel(android.os.Parcel, int); field public static final deprecated int CHANNEL_CONFIGURATION_DEFAULT = 1; // 0x1 field public static final deprecated int CHANNEL_CONFIGURATION_INVALID = 0; // 0x0 field public static final deprecated int CHANNEL_CONFIGURATION_MONO = 2; // 0x2 @@ -19753,6 +19755,7 @@ package android.media { field public static final int CHANNEL_OUT_SIDE_RIGHT = 4096; // 0x1000 field public static final int CHANNEL_OUT_STEREO = 12; // 0xc field public static final int CHANNEL_OUT_SURROUND = 1052; // 0x41c + field public static final android.os.Parcelable.Creator CREATOR; field public static final int ENCODING_AC3 = 5; // 0x5 field public static final int ENCODING_DEFAULT = 1; // 0x1 field public static final int ENCODING_DTS = 7; // 0x7 diff --git a/api/removed.txt b/api/removed.txt index 0bf659438340d..3fe97b7e14d15 100644 --- a/api/removed.txt +++ b/api/removed.txt @@ -35,7 +35,7 @@ package android.database { package android.media { - public class AudioFormat { + public class AudioFormat implements android.os.Parcelable { ctor public AudioFormat(); } diff --git a/api/system-current.txt b/api/system-current.txt index 0ed1ecb7e7eee..d70583485995b 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -21194,12 +21194,14 @@ package android.media { field public static final android.os.Parcelable.Creator CREATOR; } - public class AudioFormat { + public class AudioFormat implements android.os.Parcelable { + method public int describeContents(); method public int getChannelCount(); method public int getChannelIndexMask(); method public int getChannelMask(); method public int getEncoding(); method public int getSampleRate(); + method public void writeToParcel(android.os.Parcel, int); field public static final deprecated int CHANNEL_CONFIGURATION_DEFAULT = 1; // 0x1 field public static final deprecated int CHANNEL_CONFIGURATION_INVALID = 0; // 0x0 field public static final deprecated int CHANNEL_CONFIGURATION_MONO = 2; // 0x2 @@ -21241,6 +21243,7 @@ package android.media { field public static final int CHANNEL_OUT_SIDE_RIGHT = 4096; // 0x1000 field public static final int CHANNEL_OUT_STEREO = 12; // 0xc field public static final int CHANNEL_OUT_SURROUND = 1052; // 0x41c + field public static final android.os.Parcelable.Creator CREATOR; field public static final int ENCODING_AC3 = 5; // 0x5 field public static final int ENCODING_DEFAULT = 1; // 0x1 field public static final int ENCODING_DTS = 7; // 0x7 diff --git a/api/system-removed.txt b/api/system-removed.txt index 27de91312fae7..aa4750a636e0b 100644 --- a/api/system-removed.txt +++ b/api/system-removed.txt @@ -26,7 +26,7 @@ package android.database { package android.media { - public class AudioFormat { + public class AudioFormat implements android.os.Parcelable { ctor public AudioFormat(); } diff --git a/api/test-current.txt b/api/test-current.txt index e7f86aaa04876..c10ffa75189db 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -19715,12 +19715,14 @@ package android.media { field public static final int TYPE_WIRED_HEADSET = 3; // 0x3 } - public class AudioFormat { + public class AudioFormat implements android.os.Parcelable { + method public int describeContents(); method public int getChannelCount(); method public int getChannelIndexMask(); method public int getChannelMask(); method public int getEncoding(); method public int getSampleRate(); + method public void writeToParcel(android.os.Parcel, int); field public static final deprecated int CHANNEL_CONFIGURATION_DEFAULT = 1; // 0x1 field public static final deprecated int CHANNEL_CONFIGURATION_INVALID = 0; // 0x0 field public static final deprecated int CHANNEL_CONFIGURATION_MONO = 2; // 0x2 @@ -19762,6 +19764,7 @@ package android.media { field public static final int CHANNEL_OUT_SIDE_RIGHT = 4096; // 0x1000 field public static final int CHANNEL_OUT_STEREO = 12; // 0xc field public static final int CHANNEL_OUT_SURROUND = 1052; // 0x41c + field public static final android.os.Parcelable.Creator CREATOR; field public static final int ENCODING_AC3 = 5; // 0x5 field public static final int ENCODING_DEFAULT = 1; // 0x1 field public static final int ENCODING_DTS = 7; // 0x7 diff --git a/api/test-removed.txt b/api/test-removed.txt index 0bf659438340d..3fe97b7e14d15 100644 --- a/api/test-removed.txt +++ b/api/test-removed.txt @@ -35,7 +35,7 @@ package android.database { package android.media { - public class AudioFormat { + public class AudioFormat implements android.os.Parcelable { ctor public AudioFormat(); } diff --git a/media/java/android/media/AudioFormat.aidl b/media/java/android/media/AudioFormat.aidl new file mode 100644 index 0000000000000..8613f550e3c8a --- /dev/null +++ b/media/java/android/media/AudioFormat.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2016 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 AudioFormat; diff --git a/media/java/android/media/AudioFormat.java b/media/java/android/media/AudioFormat.java index 000a56d186b53..22f4f04bcea8d 100644 --- a/media/java/android/media/AudioFormat.java +++ b/media/java/android/media/AudioFormat.java @@ -18,10 +18,13 @@ package android.media; import android.annotation.IntDef; import android.annotation.NonNull; +import android.os.Parcel; +import android.os.Parcelable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Arrays; +import java.util.Objects; /** * The {@link AudioFormat} class is used to access a number of audio format and @@ -209,7 +212,7 @@ import java.util.Arrays; * AudioTrack.getPlaybackHeadPosition()}), * depending on the context where audio frame is used. */ -public class AudioFormat { +public class AudioFormat implements Parcelable { //--------------------------------------------------------- // Constants @@ -873,6 +876,44 @@ public class AudioFormat { } } + @Override + public int hashCode() { + return Objects.hash(mPropertySetMask, mSampleRate, mEncoding, mChannelMask, + mChannelIndexMask); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(mPropertySetMask); + dest.writeInt(mEncoding); + dest.writeInt(mSampleRate); + dest.writeInt(mChannelMask); + dest.writeInt(mChannelIndexMask); + } + + private AudioFormat(Parcel in) { + mPropertySetMask = in.readInt(); + mEncoding = in.readInt(); + mSampleRate = in.readInt(); + mChannelMask = in.readInt(); + mChannelIndexMask = in.readInt(); + } + + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { + public AudioFormat createFromParcel(Parcel p) { + return new AudioFormat(p); + } + public AudioFormat[] newArray(int size) { + return new AudioFormat[size]; + } + }; + @Override public String toString () { return new String("AudioFormat:"