Merge "Audio: Make AudioTimestamp be parcelable"
This commit is contained in:
committed by
Android (Google) Code Review
commit
9fcd09ed51
@@ -20899,8 +20899,11 @@ package android.media {
|
||||
method public void onRoutingChanged(android.media.AudioRouting);
|
||||
}
|
||||
|
||||
public final class AudioTimestamp {
|
||||
public final class AudioTimestamp implements android.os.Parcelable {
|
||||
ctor public AudioTimestamp();
|
||||
method public int describeContents();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.media.AudioTimestamp> CREATOR;
|
||||
field public static final int TIMEBASE_BOOTTIME = 1; // 0x1
|
||||
field public static final int TIMEBASE_MONOTONIC = 0; // 0x0
|
||||
field public long framePosition;
|
||||
|
||||
19
media/java/android/media/AudioTimestamp.aidl
Normal file
19
media/java/android/media/AudioTimestamp.aidl
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 AudioTimestamp;
|
||||
@@ -16,11 +16,14 @@
|
||||
|
||||
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 android.annotation.IntDef;
|
||||
|
||||
/**
|
||||
* Structure that groups a position in frame units relative to an assumed audio stream,
|
||||
* together with the estimated time when that frame enters or leaves the audio
|
||||
@@ -33,8 +36,7 @@ import android.annotation.IntDef;
|
||||
* @see AudioTrack#getTimestamp AudioTrack.getTimestamp(AudioTimestamp)
|
||||
* @see AudioRecord#getTimestamp AudioRecord.getTimestamp(AudioTimestamp, int)
|
||||
*/
|
||||
public final class AudioTimestamp
|
||||
{
|
||||
public final class AudioTimestamp implements Parcelable {
|
||||
/**
|
||||
* Clock monotonic or its equivalent on the system,
|
||||
* in the same units and timebase as {@link java.lang.System#nanoTime}.
|
||||
@@ -86,4 +88,47 @@ public final class AudioTimestamp
|
||||
* with a timebase of {@link #TIMEBASE_MONOTONIC}.
|
||||
*/
|
||||
public long nanoTime;
|
||||
|
||||
public AudioTimestamp() {
|
||||
}
|
||||
|
||||
private AudioTimestamp(@NonNull Parcel in) {
|
||||
framePosition = in.readLong();
|
||||
nanoTime = in.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AudioTimeStamp:"
|
||||
+ " framePos=" + framePosition
|
||||
+ " nanoTime=" + nanoTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||
dest.writeLong(framePosition);
|
||||
dest.writeLong(nanoTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance from a {@link Parcel}.
|
||||
*/
|
||||
@NonNull
|
||||
public static final Creator<AudioTimestamp> CREATOR = new Creator<>() {
|
||||
@Override
|
||||
public AudioTimestamp createFromParcel(@NonNull Parcel in) {
|
||||
return new AudioTimestamp(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AudioTimestamp[] newArray(int size) {
|
||||
return new AudioTimestamp[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user