google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.74k stars 6.03k forks source link

AudioSink By Override by myself instead DefaultAudioSink #10356

Closed louiewh closed 2 years ago

louiewh commented 2 years ago

I override the DefaultAudioSink.

this is my AudioSink AudioOutput is a abstract class and the AudioOutput of AudioCompatSink param is using AudioTrack。 But there are some issure.

  1. video can't play
  2. audio play some time , then stop
package com.tme.karaoke.support.player.audio;

import android.media.AudioTrack;

import androidx.annotation.Nullable;

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.audio.AudioSink;
import com.google.android.exoplayer2.audio.AuxEffectInfo;
import com.google.android.exoplayer2.audio.DefaultAudioSink;
import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer;
import com.google.android.exoplayer2.util.Log;
import com.tencent.karaoketv.audiochannel.AudioFrame;
import com.tencent.karaoketv.audiochannel.AudioOutput;
import com.tencent.karaoketv.audiochannel.AudioOutputInstaller;
import com.tencent.karaoketv.audiochannel.AudioPlayState;

import java.io.IOException;
import java.nio.ByteBuffer;

/**
 * @ClassName: AudioCompatSink
 * @Description: java类作用描述
 * @Author: louiewang
 * @Date: 2022/6/16 3:00 下午
 */
public class AudioCompatSink implements AudioSink {

    private final String TAG = "AudioCompatSink";
    private Format mFormat;
    private AudioOutput mAudioOutput;
    private DefaultAudioSink mDefaultAudioSink;
    private PlaybackParameters mPlaybackParameters;
    private AudioOutputInstaller mAudioOutputInstaller;

    public AudioCompatSink(AudioOutputInstaller installer, AudioOutput audioOutput, DefaultAudioSink  defaultAudioSink){
        mAudioOutputInstaller = installer;
        mAudioOutput = audioOutput;
        mDefaultAudioSink = defaultAudioSink;
    }

    /**
     * Sets the listener for sink events, which should be the audio renderer.
     *
     * @param listener The listener for sink events, which should be the audio renderer.
     */
    @Override
    public void setListener(Listener listener) {

    }

    /**
     * Returns whether the sink supports a given {@link Format}.
     *
     * @param format The format.
     * @return Whether the sink supports the format.
     */
    @Override
    public boolean supportsFormat(Format format) {
        if (mDefaultAudioSink != null){
            return mDefaultAudioSink.supportsFormat(format);
        }
        return false;
    }

    /**
     * Returns the level of support that the sink provides for a given {@link Format}.
     *
     * @param format The format.
     * @return The level of support provided.
     */
    @Override
    public int getFormatSupport(Format format) {
//        if (mAudioOutput != null){
//           return  SINK_FORMAT_SUPPORTED_DIRECTLY;
//        }

        if(mDefaultAudioSink != null){
            mDefaultAudioSink.getFormatSupport(format);
        }

        return SINK_FORMAT_UNSUPPORTED;
    }

    /**
     * Returns the playback position in the stream starting at zero, in microseconds, or {@link
     * #CURRENT_POSITION_NOT_SET} if it is not yet available.
     *
     * @param sourceEnded Specify {@code true} if no more input buffers will be provided.
     * @return The playback position relative to the start of playback, in microseconds.
     */
    @Override
    public long getCurrentPositionUs(boolean sourceEnded) {
        if(mAudioOutput != null){
            try {
                long pos = (0xFFFFFFFFL & mAudioOutput.getPlaybackHeadPosition()) * C.MICROS_PER_SECOND / 44100;
                Log.e(TAG, "getCurrentPositionUs->"+pos);
                return pos;
            } catch (IOException e) {
                Log.e(TAG, "getCurrentPositionUs", e);
            }
        }

        return CURRENT_POSITION_NOT_SET;
    }

    /**
     * Configures (or reconfigures) the sink.
     *
     * @param inputFormat         The format of audio data provided in the input buffers.
     * @param specifiedBufferSize A specific size for the playback buffer in bytes, or 0 to infer a
     *                            suitable buffer size.
     * @param outputChannels      A mapping from input to output channels that is applied to this sink's
     *                            input as a preprocessing step, if handling PCM input. Specify {@code null} to leave the
     *                            input unchanged. Otherwise, the element at index {@code i} specifies index of the input
     *                            channel to map to output channel {@code i} when preprocessing input buffers. After the map
     *                            is applied the audio data will have {@code outputChannels.length} channels.
     * @throws ConfigurationException If an error occurs configuring the sink.
     */
    @Override
    public void configure(Format inputFormat, int specifiedBufferSize, @Nullable int[] outputChannels) throws ConfigurationException {
        mFormat = inputFormat;
    }

    /**
     * Starts or resumes consuming audio if initialized.
     */
    @Override
    public void play() {
        try {
            mAudioOutput.start();
        } catch (IOException e) {
            Log.e(TAG, "play", e);
        }
    }

    /**
     * Signals to the sink that the next buffer may be discontinuous with the previous buffer.
     */
    @Override
    public void handleDiscontinuity() {
        Log.i(TAG, "handleDiscontinuity"+"->DO nothing");
    }

    /**
     * Attempts to process data from a {@link ByteBuffer}, starting from its current position and
     * ending at its limit (exclusive). The position of the {@link ByteBuffer} is advanced by the
     * number of bytes that were handled. {@link Listener#onPositionDiscontinuity()} will be called if
     * {@code presentationTimeUs} is discontinuous with the last buffer handled since the last reset.
     *
     * <p>Returns whether the data was handled in full. If the data was not handled in full then the
     * same {@link ByteBuffer} must be provided to subsequent calls until it has been fully consumed,
     * except in the case of an intervening call to {@link #flush()} (or to {@link #configure(Format,
     * int, int[])} that causes the sink to be flushed).
     *
     * @param buffer                 The buffer containing audio data.
     * @param presentationTimeUs     The presentation timestamp of the buffer in microseconds.
     * @param encodedAccessUnitCount The number of encoded access units in the buffer, or 1 if the
     *                               buffer contains PCM audio. This allows batching multiple encoded access units in one
     *                               buffer.
     * @return Whether the buffer was handled fully.
     * @throws InitializationException If an error occurs initializing the sink.
     * @throws WriteException          If an error occurs writing the audio data.
     */
    @Override
    public boolean handleBuffer(ByteBuffer buffer, long presentationTimeUs, int encodedAccessUnitCount) throws InitializationException, WriteException {
        if(buffer.remaining() <= 0){
            return true;
        }

        byte[] arr = new byte[buffer.remaining()];
        buffer.get(arr);
        AudioFrame audioFrame = new AudioFrame(arr, arr.length);
        try {
            mAudioOutput.write(audioFrame);
        } catch (IOException e) {
            Log.e(TAG, "handleBuffer", e);
        }

        return buffer.remaining() == 0;
    }

    /**
     * Processes any remaining data. {@link #isEnded()} will return {@code true} when no data remains.
     *
     * @throws WriteException If an error occurs draining data to the sink.
     */
    @Override
    public void playToEndOfStream() throws WriteException {
//        if(mAudioOutput != null){
//            mAudioOutput.get
//            try {
//                mAudioOutput.release();
//            } catch (IOException e) {
//                Log.e(TAG, "playToEndOfStream", e);
//            }
//        }
    }

    /**
     * Returns whether {@link #playToEndOfStream} has been called and all buffers have been processed.
     */
    @Override
    public boolean isEnded() {
        try {
            return mAudioOutput.getPlayState() == AudioPlayState.PLAYSTATE_STOPPED;
        } catch (IOException e) {
            Log.e(TAG, "isEnded", e);
        }

        return false;
    }

    /**
     * Returns whether the sink has data pending that has not been consumed yet.
     */
    @Override
    public boolean hasPendingData() {
//        Log.i(TAG, "hasPendingData"+"->DO nothing");
        return false;
    }

    /**
     * Attempts to set the playback parameters. The audio sink may override these parameters if they
     * are not supported.
     *
     * @param playbackParameters The new playback parameters to attempt to set.
     */
    @Override
    public void setPlaybackParameters(PlaybackParameters playbackParameters) {
        mPlaybackParameters = playbackParameters;
    }

    /**
     * Returns the active {@link PlaybackParameters}.
     */
    @Override
    public PlaybackParameters getPlaybackParameters() {
        return mPlaybackParameters;
    }

    /**
     * Sets whether silences should be skipped in the audio stream.
     *
     * @param skipSilenceEnabled
     */
    @Override
    public void setSkipSilenceEnabled(boolean skipSilenceEnabled) {
        if(mDefaultAudioSink != null){
            mDefaultAudioSink.setSkipSilenceEnabled(skipSilenceEnabled);
        }
    }

    /**
     * Returns whether silences are skipped in the audio stream.
     */
    @Override
    public boolean getSkipSilenceEnabled() {
        return false;
    }

    /**
     * Sets attributes for audio playback. If the attributes have changed and if the sink is not
     * configured for use with tunneling, then it is reset and the audio session id is cleared.
     *
     * <p>If the sink is configured for use with tunneling then the audio attributes are ignored. The
     * sink is not reset and the audio session id is not cleared. The passed attributes will be used
     * if the sink is later re-configured into non-tunneled mode.
     *
     * @param audioAttributes The attributes for audio playback.
     */
    @Override
    public void setAudioAttributes(AudioAttributes audioAttributes) {
        if(mDefaultAudioSink != null){
            mDefaultAudioSink.setAudioAttributes(audioAttributes);
        }
    }

    /**
     * Sets the audio session id.
     *
     * @param audioSessionId
     */
    @Override
    public void setAudioSessionId(int audioSessionId) {

    }

    /**
     * Sets the auxiliary effect.
     *
     * @param auxEffectInfo
     */
    @Override
    public void setAuxEffectInfo(AuxEffectInfo auxEffectInfo) {

    }

    /**
     * Enables tunneling, if possible. The sink is reset if tunneling was previously disabled.
     * Enabling tunneling is only possible if the sink is based on a platform {@link AudioTrack}, and
     * requires platform API version 21 onwards.
     *
     * @throws IllegalStateException Thrown if enabling tunneling on platform API version &lt; 21.
     */
    @Override
    public void enableTunnelingV21() {
        Log.i(TAG, "enableTunnelingV21"+"->DO nothing");
    }

    /**
     * Disables tunneling. If tunneling was previously enabled then the sink is reset and any audio
     * session id is cleared.
     */
    @Override
    public void disableTunneling() {
        Log.i(TAG, "disableTunneling"+"->DO nothing");
    }

    /**
     * Sets the playback volume.
     *
     * @param volume Linear output gain to apply to all channels. Should be in the range [0.0, 1.0].
     */
    @Override
    public void setVolume(float volume) {
        if(mAudioOutput != null){
            try {
                mAudioOutput.setVolume(volume);
            } catch (IOException e) {
                Log.e(TAG, "setVolume", e);
            }
        }
    }

    /**
     * Pauses playback.
     */
    @Override
    public void pause() {
        if(mAudioOutput != null){
            try {
                mAudioOutput.pause();
            } catch (IOException e) {
                Log.e(TAG, "pause", e);
            }
        }
    }

    /**
     * Flushes the sink, after which it is ready to receive buffers from a new playback position.
     *
     * <p>The audio session may remain active until {@link #reset()} is called.
     */
    @Override
    public void flush() {
        if(mAudioOutput != null){
            try {
                mAudioOutput.flush();
            } catch (IOException e) {
                Log.e(TAG, "flush", e);
            }
        }
    }

    /**
     * Flushes the sink, after which it is ready to receive buffers from a new playback position.
     *
     * <p>Does not release the {@link AudioTrack} held by the sink.
     *
     * <p>This method is experimental, and will be renamed or removed in a future release.
     *
     * <p>Only for experimental use as part of {@link
     * MediaCodecAudioRenderer#experimentalSetEnableKeepAudioTrackOnSeek(boolean)}.
     */
    @Override
    public void experimentalFlushWithoutAudioTrackRelease() {
        Log.i(TAG, "experimentalFlushWithoutAudioTrackRelease"+"->DO nothing");
    }

    /**
     * Resets the sink, releasing any resources that it currently holds.
     */
    @Override
    public void reset() {
        if(mAudioOutput != null){
            try {
                mAudioOutput.release();
            } catch (IOException e) {
                Log.e(TAG, "reset", e);
            }
        }
    }
}

This is my AudioOutput code

import java.io.IOException;

public class AudioTrackDevice extends AudioOutput implements AudioPlayState {

    private static final String TAG = "AudioTrackDevice";
    private AudioTrack mAudioTrack;
    private int mPlaybackBufferSize;
    private int mPlayState = PLAYSTATE_NEW;
    private static final AudioLog LOG = new AudioLog(TAG);
    private static final int BUFFER_SCALE = 4;

    public AudioTrackDevice(AudioParams params) {
        this.init(params);
    }

    private void init(AudioParams audioParams) {
        if (audioParams == null) {
            return;
        }
        if (mPlaybackBufferSize > 0) {
            return;
        }
        long sampleRate = audioParams.sampleRate;
        int channelCount = audioParams.channelCount;
        int bitDept = audioParams.bitDepth;

        int channelConfiguration = AudioFormat.CHANNEL_OUT_STEREO;
        switch (channelCount) {
            case 1:
                channelConfiguration = AudioFormat.CHANNEL_OUT_MONO;
                break;
            case 2:
                channelConfiguration = AudioFormat.CHANNEL_OUT_STEREO;
                break;
            case 6:
                channelConfiguration = AudioFormat.CHANNEL_OUT_5POINT1;
                break;
            case 8:
                channelConfiguration = AudioFormat.CHANNEL_OUT_7POINT1;
                break;
        }
       // LOG.print("create track sampleRate = "+sampleRate+", channelConfiguration = "+channelConfiguration+",audioFormat = "+audioFormat);

        int audioFormat = bitDept == AudioParams.BIT_DEPTH_8BIT ? AudioFormat.ENCODING_PCM_8BIT : AudioFormat.ENCODING_PCM_16BIT;

        LOG.print("create track sampleRate = "+sampleRate+", channelConfiguration = "+channelConfiguration+",audioFormat = "+audioFormat);

        mPlaybackBufferSize = AudioTrack.getMinBufferSize((int) sampleRate, channelConfiguration, audioFormat) * BUFFER_SCALE;

        LOG.print("create track buffersize = "+mPlaybackBufferSize);

        //可能存在获取到的大小为-1的情况,这时候使用默认
        if(mPlaybackBufferSize <= 0){
            mPlaybackBufferSize = 7104;
        }

        mAudioTrack = new AudioTrack(
                AudioManager.STREAM_MUSIC,
                (int) sampleRate,
                channelConfiguration,
                audioFormat,
                mPlaybackBufferSize,
                AudioTrack.MODE_STREAM);
    }

    @Override
    public void start() throws IOException {
        AudioTrack audioTrack = mAudioTrack;
        if (audioTrack != null) {
            audioTrack.play();
            mPlayState = PLAYSTATE_PLAYING;
            notifyPlayStateChanged(mPlayState);
        }
    }

    @Override
    public void stop() throws IOException {
        AudioTrack audioTrack = mAudioTrack;
        if (audioTrack != null) {
            audioTrack.stop();
            mPlayState = PLAYSTATE_STOPPED;
            notifyPlayStateChanged(mPlayState);
        }
    }

    @Override
    public void resume() throws IOException {
        AudioTrack audioTrack = mAudioTrack;
        if (audioTrack != null) {
            audioTrack.play();
            mPlayState = PLAYSTATE_PLAYING;
            notifyPlayStateChanged(mPlayState);
        }
    }

    @Override
    public void pause() throws IOException {
        AudioTrack audioTrack = mAudioTrack;
        if (audioTrack != null) {
            audioTrack.pause();
            mPlayState = PLAYSTATE_PAUSED;
            notifyPlayStateChanged(mPlayState);
        }
    }

    @Override
    public void flush() throws IOException {
        AudioTrack audioTrack = mAudioTrack;
        if (audioTrack != null) {
            audioTrack.flush();
        }
    }

//    private static void debugPrintNativeTrackInJavaObj(AudioTrack audioTrack) {
//        try {
//            LOG.print("call debugPrintNativeTrackInJavaObj start");
//            Field field = AudioTrack.class.getDeclaredField("mNativeTrackInJavaObj");
//            Object mNativeTrackInJavaObj = null;
//            if (field != null) {
//                field.setAccessible(true);
//                mNativeTrackInJavaObj  = field.get(audioTrack);
//                LOG.print("mNativeTrackInJavaObj = "+mNativeTrackInJavaObj);
//            }
//            LOG.print("call debugPrintNativeTrackInJavaObj success");
//        } catch (Throwable throwable) {
//            LOG.print("call debugPrintNativeTrackInJavaObj error "+throwable);
//        }
//    }
//
//    private static void debugPrintJniData(AudioTrack audioTrack) {
//        try {
//            LOG.print("call debugPrintJniData start");
//            Field field = AudioTrack.class.getDeclaredField("mJniData");
//            Object mJniData = null;
//            if (field != null) {
//                field.setAccessible(true);
//                mJniData  = field.get(audioTrack);
//                LOG.print("mJniData = "+mJniData);
//            }
//            LOG.print("call debugPrintJniData success");
//        } catch (Throwable throwable) {
//            LOG.print("call debugPrintJniData error "+throwable);
//        }
//    }
//
//
//    private static void debugPrintEventHandlerDelegate(AudioTrack audioTrack) {
//        try {
//            LOG.print("debugPrintEventHandlerDelegate start");
//
//            debugPrintNativeTrackInJavaObj(audioTrack);
//            debugPrintJniData(audioTrack);
//            Field field = AudioTrack.class.getDeclaredField("mEventHandlerDelegate");
//            Object mEventHandlerDelegate = null;
//            if (field != null) {
//                field.setAccessible(true);
//                mEventHandlerDelegate  = field.get(audioTrack);
//                LOG.print("mEventHandlerDelegate = "+mEventHandlerDelegate);
//            }
//            LOG.print("debugPrintEventHandlerDelegate end");
//        } catch (Throwable throwable) {
//            LOG.print("debugPrintEventHandlerDelegate error "+throwable);
//        }
//    }

    @Override
    public void release() throws IOException {
        LOG.print("call release() start ");
        AudioTrack audioTrack = mAudioTrack;
        if (audioTrack != null) {
//            debugPrintEventHandlerDelegate(audioTrack);
//            new ReleaseAudioTrack(audioTrack);
            // TODO
//            MediaUtils.release(audioTrack);
            mPlayState = PLAYSTATE_NEW;
            notifyPlayStateChanged(mPlayState);
        }
        mAudioTrack = null;
        mPlaybackBufferSize = 0;
    }

    @Override
    public int write(AudioFrame audioFrame) throws IOException {
        if (audioFrame == null) {
            return 0;
        }

        final AudioTrack audioTrack = mAudioTrack;
        if (audioTrack != null) {

            if (audioFrame.isByteData()) {
                return audioTrack.write(audioFrame.byteBuffer,0,audioFrame.size);
            } else {
                return audioTrack.write(audioFrame.buffer, 0, audioFrame.size);
            }
        }
        return 0;
    }

    @Override
    public void setVolume(float volume) throws IOException {
        AudioTrack audioTrack = mAudioTrack;
        if (audioTrack != null) {
            audioTrack.setStereoVolume(volume, volume);
        }
    }

    @Override
    public void setMicVolume(float volume) throws IOException {

    }

    @Override
    public int getPlaybackHeadPosition() throws IOException {
        AudioTrack audioTrack = mAudioTrack;
        if (audioTrack != null) {
            return audioTrack.getPlaybackHeadPosition();
        }
        return 0;
    }

    @Override
    public final int getPlaybackBufferSize() throws IOException {
        return mPlaybackBufferSize;
    }

    @Override
    public int getAudioSessionId() {
        AudioTrack audioTrack = mAudioTrack;
        if (audioTrack != null) {
            return audioTrack.getAudioSessionId();
        }
        return 0;
    }

    @Override
    public int getPlayState() {
        return mPlayState;
    }
}
louiewh commented 2 years ago

The log uses DefaultAudioSink

2022-06-20 10:53:05.527 29397-29397/com.example.karaoke D/KaraokeAudioSink: KaraokeAudioSink:com.google.android.exoplayer2.audio.DefaultAudioSink@5586f89 2022-06-20 10:53:05.528 29397-29397/com.example.karaoke D/KaraokeAudioSink: setListener:com.google.android.exoplayer2.audio.MediaCodecAudioRenderer$AudioSinkListener@5996b8e 2022-06-20 10:53:05.536 29397-29427/com.example.karaoke D/KaraokeAudioSink: setAudioSessionId:681 2022-06-20 10:53:05.608 29397-29397/com.example.karaoke D/KaraokeEventLogger: surfaceSize [eventTime=0.07, mediaPos=0.00, window=0, 1600, 2227] 2022-06-20 10:53:06.584 29397-29397/com.example.karaoke D/KaraokeEventLogger: timeline [eventTime=1.04, mediaPos=0.00, window=0, periodCount=1, windowCount=1, reason=PLAYLIST_CHANGED 2022-06-20 10:53:06.585 29397-29397/com.example.karaoke D/KaraokeEventLogger: period [?] 2022-06-20 10:53:06.585 29397-29397/com.example.karaoke D/KaraokeEventLogger: window [?, seekable=false, dynamic=true] 2022-06-20 10:53:06.585 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:06.587 29397-29397/com.example.karaoke D/KaraokeEventLogger: mediaItem [eventTime=1.05, mediaPos=0.00, window=0, reason=PLAYLIST_CHANGED] 2022-06-20 10:53:06.592 29397-29397/com.example.karaoke D/KaraokeEventLogger: state [eventTime=1.05, mediaPos=0.00, window=0, BUFFERING] 2022-06-20 10:53:06.600 29397-29397/com.example.karaoke D/KaraokeEventLogger: playWhenReady [eventTime=1.06, mediaPos=0.00, window=0, true, USER_REQUEST] 2022-06-20 10:53:06.617 29397-29397/com.example.karaoke D/KaraokeEventLogger: timeline [eventTime=1.08, mediaPos=0.00, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE 2022-06-20 10:53:06.618 29397-29397/com.example.karaoke D/KaraokeEventLogger: period [?] 2022-06-20 10:53:06.618 29397-29397/com.example.karaoke D/KaraokeEventLogger: window [?, seekable=false, dynamic=false] 2022-06-20 10:53:06.618 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:06.618 29397-29397/com.example.karaoke D/KaraokeEventLogger: loading [eventTime=1.08, mediaPos=0.00, window=0, period=0, true] 2022-06-20 10:53:07.270 29397-29397/com.example.karaoke D/KaraokeEventLogger: timeline [eventTime=1.73, mediaPos=0.00, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE 2022-06-20 10:53:07.270 29397-29397/com.example.karaoke D/KaraokeEventLogger: period [230.74] 2022-06-20 10:53:07.270 29397-29397/com.example.karaoke D/KaraokeEventLogger: window [230.74, seekable=true, dynamic=false] 2022-06-20 10:53:07.270 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:07.313 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(2, null, null, audio/mp4a-latm, mp4a.40.2, -1, en, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:53:07.314 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.314 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:53:07.314 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:53:07.314 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(2, null, null, audio/mp4a-latm, mp4a.40.2, -1, en, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:53:07.314 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(2, null, null, audio/mp4a-latm, mp4a.40.2, -1, en, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(2, null, null, audio/mp4a-latm, mp4a.40.2, -1, en, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.315 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.316 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.317 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.317 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.317 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.317 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:53:07.317 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.317 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.320 29397-29427/com.example.karaoke D/KaraokeAudioSink: disableTunneling: 2022-06-20 10:53:07.320 29397-29427/com.example.karaoke D/KaraokeAudioSink: flush: 2022-06-20 10:53:07.320 29397-29397/com.example.karaoke D/KaraokeEventLogger: videoEnabled [eventTime=1.78, mediaPos=0.00, window=0, period=0] 2022-06-20 10:53:07.321 29397-29397/com.example.karaoke D/KaraokeEventLogger: audioEnabled [eventTime=1.78, mediaPos=0.00, window=0, period=0] 2022-06-20 10:53:07.323 29397-29397/com.example.karaoke D/KaraokeEventLogger: tracks [eventTime=1.78, mediaPos=0.00, window=0, period=0 2022-06-20 10:53:07.323 29397-29397/com.example.karaoke D/KaraokeEventLogger: MediaCodecVideoRenderer [ 2022-06-20 10:53:07.323 29397-29397/com.example.karaoke D/KaraokeEventLogger: Group:0, adaptive_supported=N/A [ 2022-06-20 10:53:07.323 29397-29397/com.example.karaoke D/KaraokeEventLogger: [X] Track:0, id=1, mimeType=video/avc, codecs=avc1.640028, res=1920x1080, fps=25.0, supported=YES 2022-06-20 10:53:07.323 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:07.323 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: MediaCodecAudioRenderer [ 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: Group:0, adaptive_supported=N/A [ 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: [ ] Track:0, id=2, mimeType=audio/mp4a-latm, codecs=mp4a.40.2, channels=2, sample_rate=48000, language=en, supported=YES 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: Group:1, adaptive_supported=N/A [ 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: [ ] Track:0, id=1, mimeType=audio/mp4a-latm, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=und, supported=YES 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: Group:2, adaptive_supported=N/A [ 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: [X] Track:0, id=1, mimeType=audio/mp4a-latm, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=und, supported=YES 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: Metadata [ 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: TALB: description=null: value= 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: TPE1: description=null: value=周杰伦 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: ----: domain=com.apple.iTunes, description=cdec 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: ----: domain=com.apple.iTunes, description=iTunSMPB 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: TIT2: description=null: value=夜曲 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: TSSE: description=null: value=Nero AAC codec / 1.5.4.0 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: TextRenderer [] 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: MetadataRenderer [] 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: CameraMotionRenderer [] 2022-06-20 10:53:07.324 29397-29397/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:53:07.328 29397-29397/com.example.karaoke D/KaraokeEventLogger: downstreamFormat [eventTime=1.79, mediaPos=0.00, window=0, period=0, id=1, mimeType=video/avc, codecs=avc1.640028, res=1920x1080, fps=25.0] 2022-06-20 10:53:07.358 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.358 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.359 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.359 29397-29427/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:53:07.359 29397-29397/com.example.karaoke D/KaraokeEventLogger: videoDecoderInitialized [eventTime=1.82, mediaPos=0.00, window=0, period=0, OMX.qcom.video.decoder.avc] 2022-06-20 10:53:07.360 29397-29397/com.example.karaoke D/KaraokeEventLogger: videoInputFormat [eventTime=1.82, mediaPos=0.00, window=0, period=0, id=1, mimeType=video/avc, codecs=avc1.640028, res=1920x1080, fps=25.0] 2022-06-20 10:53:07.388 29397-29397/com.example.karaoke D/KaraokeEventLogger: audioDecoderInitialized [eventTime=1.85, mediaPos=0.00, window=0, period=0, c2.android.aac.decoder] 2022-06-20 10:53:07.390 29397-29397/com.example.karaoke D/KaraokeEventLogger: audioInputFormat [eventTime=1.85, mediaPos=0.00, window=0, period=0, id=1, mimeType=audio/mp4a-latm, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=und] 2022-06-20 10:53:07.398 29397-29427/com.example.karaoke D/KaraokeAudioSink: configureFormat(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:53:07.410 29397-29427/com.example.karaoke D/KaraokeAudioSink: /storage/emulated/0/Android/data/com.example.karaoke/cache/AudioSlink.pcm 2022-06-20 10:53:07.472 29397-29397/com.example.karaoke D/KaraokeEventLogger: videoSize [eventTime=1.93, mediaPos=0.00, window=0, period=0, 1920, 1080] 2022-06-20 10:53:07.488 29397-29397/com.example.karaoke D/KaraokeEventLogger: surfaceSize [eventTime=1.95, mediaPos=0.00, window=0, period=0, 1600, 900] 2022-06-20 10:53:07.491 29397-29397/com.example.karaoke D/KaraokeEventLogger: renderedFirstFrame [eventTime=1.95, mediaPos=0.00, window=0, period=0, Surface(name=null)/@0xdfde92e] 2022-06-20 10:53:08.030 29397-29427/com.example.karaoke D/KaraokeAudioSink: play 2022-06-20 10:53:08.037 29397-29397/com.example.karaoke D/KaraokeEventLogger: state [eventTime=2.50, mediaPos=0.00, window=0, period=0, READY] 2022-06-20 10:53:08.040 29397-29397/com.example.karaoke D/KaraokeEventLogger: isPlaying [eventTime=2.50, mediaPos=0.00, window=0, period=0, true] 2022-06-20 10:53:08.040 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.040 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.050 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.050 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.059 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.060 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.069 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.070 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.080 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.080 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.090 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.091 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.102 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.102 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.111 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.112 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.123 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.123 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.134 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.134 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.144 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.144 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000 2022-06-20 10:53:08.155 29397-29427/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1000000000000

louiewh commented 2 years ago

The log uses AudioCompatSink I find mediaPos and getCurrentPositionUs is exception

2022-06-20 10:55:00.715 29542-29542/com.example.karaoke D/KaraokeAudioSink: KaraokeAudioSink:com.tme.karaoke.support.player.audio.AudioCompatSink@b47e78d 2022-06-20 10:55:00.715 29542-29542/com.example.karaoke D/KaraokeAudioSink: setListener:com.google.android.exoplayer2.audio.MediaCodecAudioRenderer$AudioSinkListener@a38bd42 2022-06-20 10:55:00.724 29542-29573/com.example.karaoke D/KaraokeAudioSink: setAudioSessionId:697 2022-06-20 10:55:00.795 29542-29542/com.example.karaoke D/KaraokeEventLogger: surfaceSize [eventTime=0.07, mediaPos=0.00, window=0, 1600, 2227] 2022-06-20 10:55:01.478 29542-29542/com.example.karaoke D/KaraokeEventLogger: timeline [eventTime=0.75, mediaPos=0.00, window=0, periodCount=1, windowCount=1, reason=PLAYLIST_CHANGED 2022-06-20 10:55:01.478 29542-29542/com.example.karaoke D/KaraokeEventLogger: period [?] 2022-06-20 10:55:01.478 29542-29542/com.example.karaoke D/KaraokeEventLogger: window [?, seekable=false, dynamic=true] 2022-06-20 10:55:01.478 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:01.481 29542-29542/com.example.karaoke D/KaraokeEventLogger: mediaItem [eventTime=0.75, mediaPos=0.00, window=0, reason=PLAYLIST_CHANGED] 2022-06-20 10:55:01.486 29542-29542/com.example.karaoke D/KaraokeEventLogger: state [eventTime=0.76, mediaPos=0.00, window=0, BUFFERING] 2022-06-20 10:55:01.496 29542-29542/com.example.karaoke D/KaraokeEventLogger: playWhenReady [eventTime=0.77, mediaPos=0.00, window=0, true, USER_REQUEST] 2022-06-20 10:55:01.513 29542-29542/com.example.karaoke D/KaraokeEventLogger: timeline [eventTime=0.79, mediaPos=0.00, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE 2022-06-20 10:55:01.513 29542-29542/com.example.karaoke D/KaraokeEventLogger: period [?] 2022-06-20 10:55:01.513 29542-29542/com.example.karaoke D/KaraokeEventLogger: window [?, seekable=false, dynamic=false] 2022-06-20 10:55:01.513 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:01.513 29542-29542/com.example.karaoke D/KaraokeEventLogger: loading [eventTime=0.79, mediaPos=0.00, window=0, period=0, true] 2022-06-20 10:55:02.362 29542-29542/com.example.karaoke D/KaraokeEventLogger: timeline [eventTime=1.64, mediaPos=0.00, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE 2022-06-20 10:55:02.362 29542-29542/com.example.karaoke D/KaraokeEventLogger: period [230.74] 2022-06-20 10:55:02.362 29542-29542/com.example.karaoke D/KaraokeEventLogger: window [230.74, seekable=true, dynamic=false] 2022-06-20 10:55:02.362 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:02.415 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(2, null, null, audio/mp4a-latm, mp4a.40.2, -1, en, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:55:02.415 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.415 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:55:02.415 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:55:02.415 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(2, null, null, audio/mp4a-latm, mp4a.40.2, -1, en, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:55:02.416 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.416 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(2, null, null, audio/mp4a-latm, mp4a.40.2, -1, en, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:55:02.416 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.417 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:55:02.417 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:55:02.417 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(2, null, null, audio/mp4a-latm, mp4a.40.2, -1, en, [-1, -1, -1.0], [2, 48000]) 2022-06-20 10:55:02.417 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.417 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.417 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.417 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.417 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:55:02.417 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.417 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.418 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.418 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.418 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.418 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:55:02.418 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.418 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.418 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.418 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.418 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.419 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:55:02.419 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.419 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.419 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.419 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.419 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.419 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:true 2022-06-20 10:55:02.419 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.419 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.423 29542-29573/com.example.karaoke D/KaraokeAudioSink: disableTunneling: 2022-06-20 10:55:02.423 29542-29573/com.example.karaoke D/KaraokeAudioSink: flush: 2022-06-20 10:55:02.423 29542-29542/com.example.karaoke D/KaraokeEventLogger: videoEnabled [eventTime=1.70, mediaPos=0.00, window=0, period=0] 2022-06-20 10:55:02.424 29542-29542/com.example.karaoke D/KaraokeEventLogger: audioEnabled [eventTime=1.70, mediaPos=0.00, window=0, period=0] 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: tracks [eventTime=1.70, mediaPos=0.00, window=0, period=0 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: MediaCodecVideoRenderer [ 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: Group:0, adaptive_supported=N/A [ 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: [X] Track:0, id=1, mimeType=video/avc, codecs=avc1.640028, res=1920x1080, fps=25.0, supported=YES 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: MediaCodecAudioRenderer [ 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: Group:0, adaptive_supported=N/A [ 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: [ ] Track:0, id=2, mimeType=audio/mp4a-latm, codecs=mp4a.40.2, channels=2, sample_rate=48000, language=en, supported=YES 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: Group:1, adaptive_supported=N/A [ 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: [ ] Track:0, id=1, mimeType=audio/mp4a-latm, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=und, supported=YES 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: Group:2, adaptive_supported=N/A [ 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: [X] Track:0, id=1, mimeType=audio/mp4a-latm, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=und, supported=YES 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: Metadata [ 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: TALB: description=null: value= 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: TPE1: description=null: value=周杰伦 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: ----: domain=com.apple.iTunes, description=cdec 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: ----: domain=com.apple.iTunes, description=iTunSMPB 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: TIT2: description=null: value=夜曲 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: TSSE: description=null: value=Nero AAC codec / 1.5.4.0 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:02.426 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:02.427 29542-29542/com.example.karaoke D/KaraokeEventLogger: TextRenderer [] 2022-06-20 10:55:02.427 29542-29542/com.example.karaoke D/KaraokeEventLogger: MetadataRenderer [] 2022-06-20 10:55:02.427 29542-29542/com.example.karaoke D/KaraokeEventLogger: CameraMotionRenderer [] 2022-06-20 10:55:02.427 29542-29542/com.example.karaoke D/KaraokeEventLogger: ] 2022-06-20 10:55:02.430 29542-29542/com.example.karaoke D/KaraokeEventLogger: downstreamFormat [eventTime=1.71, mediaPos=0.00, window=0, period=0, id=1, mimeType=video/avc, codecs=avc1.640028, res=1920x1080, fps=25.0] 2022-06-20 10:55:02.464 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.464 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.464 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:Format(1, null, null, audio/mp4a-latm, mp4a.40.2, -1, und, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.464 29542-29573/com.example.karaoke D/KaraokeAudioSink: supportsFormat:false 2022-06-20 10:55:02.465 29542-29542/com.example.karaoke D/KaraokeEventLogger: videoDecoderInitialized [eventTime=1.74, mediaPos=0.00, window=0, period=0, OMX.qcom.video.decoder.avc] 2022-06-20 10:55:02.465 29542-29542/com.example.karaoke D/KaraokeEventLogger: videoInputFormat [eventTime=1.74, mediaPos=0.00, window=0, period=0, id=1, mimeType=video/avc, codecs=avc1.640028, res=1920x1080, fps=25.0] 2022-06-20 10:55:02.491 29542-29542/com.example.karaoke D/KaraokeEventLogger: audioDecoderInitialized [eventTime=1.77, mediaPos=0.00, window=0, period=0, c2.android.aac.decoder] 2022-06-20 10:55:02.492 29542-29542/com.example.karaoke D/KaraokeEventLogger: audioInputFormat [eventTime=1.77, mediaPos=0.00, window=0, period=0, id=1, mimeType=audio/mp4a-latm, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=und] 2022-06-20 10:55:02.502 29542-29573/com.example.karaoke D/KaraokeAudioSink: configureFormat(null, null, null, audio/raw, null, -1, null, [-1, -1, -1.0], [2, 44100]) 2022-06-20 10:55:02.507 29542-29573/com.example.karaoke D/KaraokeAudioSink: /storage/emulated/0/Android/data/com.example.karaoke/cache/AudioSlink.pcm 2022-06-20 10:55:02.564 29542-29542/com.example.karaoke D/KaraokeEventLogger: videoSize [eventTime=1.84, mediaPos=0.00, window=0, period=0, 1920, 1080] 2022-06-20 10:55:02.565 29542-29542/com.example.karaoke D/KaraokeEventLogger: renderedFirstFrame [eventTime=1.84, mediaPos=0.00, window=0, period=0, Surface(name=null)/@0x352a0e2] 2022-06-20 10:55:02.577 29542-29542/com.example.karaoke D/KaraokeEventLogger: surfaceSize [eventTime=1.85, mediaPos=0.00, window=0, period=0, 1600, 900] 2022-06-20 10:55:03.116 29542-29573/com.example.karaoke D/KaraokeAudioSink: play 2022-06-20 10:55:03.124 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:0 2022-06-20 10:55:03.124 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:0 2022-06-20 10:55:03.126 29542-29542/com.example.karaoke D/KaraokeEventLogger: state [eventTime=2.40, mediaPos=-1000000.00, window=0, period=0, READY] 2022-06-20 10:55:03.128 29542-29542/com.example.karaoke D/KaraokeEventLogger: isPlaying [eventTime=2.40, mediaPos=-1000000.00, window=0, period=0, true] 2022-06-20 10:55:03.284 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:140000 2022-06-20 10:55:03.285 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:140000 2022-06-20 10:55:03.292 29542-29542/com.example.karaoke D/KaraokeEventLogger: loading [eventTime=2.57, mediaPos=-999999.88, window=0, period=0, false] 2022-06-20 10:55:03.294 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:160000 2022-06-20 10:55:03.294 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:160000 2022-06-20 10:55:03.394 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:280000 2022-06-20 10:55:03.394 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:280000 2022-06-20 10:55:03.404 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:280000 2022-06-20 10:55:03.404 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:280000 2022-06-20 10:55:03.416 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:300000 2022-06-20 10:55:03.416 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:300000 2022-06-20 10:55:03.427 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:300000 2022-06-20 10:55:03.427 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:300000 2022-06-20 10:55:03.554 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:440000 2022-06-20 10:55:03.554 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:440000 2022-06-20 10:55:03.564 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:440000 2022-06-20 10:55:03.564 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:440000 2022-06-20 10:55:03.694 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:580000 2022-06-20 10:55:03.695 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:580000 2022-06-20 10:55:03.704 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:580000 2022-06-20 10:55:03.704 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:580000 2022-06-20 10:55:03.715 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:600000 2022-06-20 10:55:03.715 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:600000 2022-06-20 10:55:03.724 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:600000 2022-06-20 10:55:03.724 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:600000 2022-06-20 10:55:03.854 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:740000 2022-06-20 10:55:03.854 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:740000 2022-06-20 10:55:03.864 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:740000 2022-06-20 10:55:03.865 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:740000 2022-06-20 10:55:03.875 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:760000 2022-06-20 10:55:03.875 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:760000 2022-06-20 10:55:04.001 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:880000 2022-06-20 10:55:04.002 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:880000 2022-06-20 10:55:04.011 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:900000 2022-06-20 10:55:04.011 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:900000 2022-06-20 10:55:04.139 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1020000 2022-06-20 10:55:04.140 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1020000 2022-06-20 10:55:04.150 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1040000 2022-06-20 10:55:04.151 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1040000 2022-06-20 10:55:04.278 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1160000 2022-06-20 10:55:04.279 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1160000 2022-06-20 10:55:04.294 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1180000 2022-06-20 10:55:04.294 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1180000 2022-06-20 10:55:04.305 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1180000 2022-06-20 10:55:04.305 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1180000 2022-06-20 10:55:04.420 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1300000 2022-06-20 10:55:04.421 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1300000 2022-06-20 10:55:04.430 29542-29573/com.example.karaoke D/KaraokeAudioSink: getCurrentPositionUs:1320000

icbaker commented 2 years ago

I'm afraid we don't have resources to answer questions of the form "I've implemented interface X, it doesn't work, what have I done wrong?".

If you want to implement a relatively complicated and low-level interface like AudioSink then I'm afraid it's really up to you to do most of the debugging on any problems you encounter.

We are able to assist with very specific questions about implementing these interfaces, like "When implementing method Y of interface X, should I do clearly-defined behaviour A or B?".

I'll leave this question open for now - but unless the question can be made more specific I'm afraid we're not going to be able to help.

louiewh commented 2 years ago

Thanks replay I resolve this problem by at handBuffer if(startMediaTimeUsNeedsInit){ startMediaTimeUs = max(0, presentationTimeUs); if(startMediaTimeUs > 0) { startMediaTimeUsNeedsInit = false; } }

at getCurrentPositionUs if(mAudioOutput != null){ try { long pos = (0xFFFFFFFFL & mAudioOutput.getPlaybackHeadPosition()) * C.MICROS_PER_SECOND / 44100; Log.e(TAG, "getCurrentPositionUs->"+pos); return pos + startMediaTimeUs; } catch (IOException e) { Log.e(TAG, "getCurrentPositionUs", e); } } return CURRENT_POSITION_NOT_SET;

but at log I find some dropFrame log . Any suggestion ?

louiewh commented 2 years ago

AudioSlink Api may simple, such as DataSource ?