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

Commit 5292504b authored by Ivan Chiang's avatar Ivan Chiang
Browse files

Audio: Make AudioTimestamp be parcelable

Test: atest AudioTimestampTest
Bug: 259001306
Change-Id: Ie5702085e072aef85493b697a4b38d71d99452ba
parent 88068450
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -20896,8 +20896,11 @@ package android.media {
    method public void onRoutingChanged(android.media.AudioRouting);
    method public void onRoutingChanged(android.media.AudioRouting);
  }
  }
  public final class AudioTimestamp {
  public final class AudioTimestamp implements android.os.Parcelable {
    ctor public AudioTimestamp();
    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_BOOTTIME = 1; // 0x1
    field public static final int TIMEBASE_MONOTONIC = 0; // 0x0
    field public static final int TIMEBASE_MONOTONIC = 0; // 0x0
    field public long framePosition;
    field public long framePosition;
+19 −0
Original line number Original line Diff line number Diff line
/*
 * 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;
+49 −4
Original line number Original line Diff line number Diff line
@@ -16,11 +16,14 @@


package android.media;
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.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.RetentionPolicy;


import android.annotation.IntDef;

/**
/**
 * Structure that groups a position in frame units relative to an assumed audio stream,
 * 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
 * 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 AudioTrack#getTimestamp AudioTrack.getTimestamp(AudioTimestamp)
 * @see AudioRecord#getTimestamp AudioRecord.getTimestamp(AudioTimestamp, int)
 * @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,
     * Clock monotonic or its equivalent on the system,
     * in the same units and timebase as {@link java.lang.System#nanoTime}.
     * 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}.
     * with a timebase of {@link #TIMEBASE_MONOTONIC}.
     */
     */
    public long nanoTime;
    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];
        }
    };
}