Java 类com.google.android.exoplayer.audio.AudioTrack 实例源码

项目:ExoPlayer-Demo    文件:LibopusAudioTrackRenderer.java   
@Override
protected void onDisabled() throws ExoPlaybackException {
  inputBuffer = null;
  outputBuffer = null;
  format = null;
  audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
  try {
    if (decoder != null) {
      decoder.release();
      decoder = null;
      codecCounters.codecReleaseCount++;
    }
    audioTrack.release();
  } finally {
    super.onDisabled();
  }
}
项目:ExoPlayer-Demo    文件:LibflacAudioTrackRenderer.java   
@Override
protected void onDisabled() throws ExoPlaybackException {
  inputBuffer = null;
  outputBuffer = null;
  format = null;
  audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
  try {
    if (decoder != null) {
      decoder.release();
      decoder = null;
      codecCounters.codecReleaseCount++;
    }
    audioTrack.release();
  } finally {
    super.onDisabled();
  }
}
项目:android_packages_apps_tv    文件:Ac3PassthroughTrackRenderer.java   
private boolean processOutput() throws ExoPlaybackException {
    if (mOutputStreamEnded) {
        return false;
    }
    if (!mOutputReady) {
        if (mInputStreamEnded) {
            mOutputStreamEnded = true;
            mEndOfStreamMs = SystemClock.elapsedRealtime();
            return false;
        }
        return true;
    }

    ensureAudioTrackInitialized();
    int handleBufferResult;
    try {
        // To reduce discontinuity, interpolate presentation time.
        mInterpolatedTimeUs = mPresentationTimeUs
                + mPresentationCount * AC3_SAMPLE_DURATION_US;
        handleBufferResult = AUDIO_TRACK.handleBuffer(mOutputBuffer,
                0, mOutputBuffer.limit(), mInterpolatedTimeUs);
    } catch (AudioTrack.WriteException e) {
        notifyAudioTrackWriteError(e);
        throw new ExoPlaybackException(e);
    }

    if ((handleBufferResult & AudioTrack.RESULT_POSITION_DISCONTINUITY) != 0) {
        Log.i(TAG, "Play discontinuity happened");
        mCurrentPositionUs = Long.MIN_VALUE;
    }
    if ((handleBufferResult & AudioTrack.RESULT_BUFFER_CONSUMED) != 0) {
        mCodecCounters.renderedOutputBufferCount++;
        mOutputReady = false;
        return true;
    }
    return false;
}
项目:android_packages_apps_tv    文件:Ac3PassthroughTrackRenderer.java   
@Override
public long getPositionUs() {
    if (!AUDIO_TRACK.isInitialized()) {
        return mAudioClock.getPositionUs();
    } else if (!AUDIO_TRACK.isEnabled()) {
        if (mInterpolatedTimeUs > 0) {
            return mInterpolatedTimeUs - ESTIMATED_TRACK_RENDERING_DELAY_US;
        }
        return mPresentationTimeUs;
    }
    long audioTrackCurrentPositionUs = AUDIO_TRACK.getCurrentPositionUs(isEnded());
    if (audioTrackCurrentPositionUs == AudioTrack.CURRENT_POSITION_NOT_SET) {
        mPreviousPositionUs = 0L;
        if (DEBUG) {
            long oldPositionUs = Math.max(mCurrentPositionUs, 0);
            long currentPositionUs = Math.max(mPresentationTimeUs, mCurrentPositionUs);
            Log.d(TAG, "Audio position is not set, diff in us: "
                    + String.valueOf(currentPositionUs - oldPositionUs));
        }
        mCurrentPositionUs = Math.max(mPresentationTimeUs, mCurrentPositionUs);
    } else {
        if (mPreviousPositionUs
                > audioTrackCurrentPositionUs + BACKWARD_AUDIO_TRACK_MOVE_THRESHOLD_US) {
            Log.e(TAG, "audio_position BACK JUMP: "
                    + (mPreviousPositionUs - audioTrackCurrentPositionUs));
            mCurrentPositionUs = audioTrackCurrentPositionUs;
        } else {
            mCurrentPositionUs = Math.max(mCurrentPositionUs, audioTrackCurrentPositionUs);
        }
        mPreviousPositionUs = audioTrackCurrentPositionUs;
    }
    long upperBound = mPresentationTimeUs + CURRENT_POSITION_FROM_PTS_LIMIT_US;
    if (mCurrentPositionUs > upperBound) {
        mCurrentPositionUs = upperBound;
    }
    return mCurrentPositionUs;
}
项目:android_packages_apps_tv    文件:Ac3PassthroughTrackRenderer.java   
private void notifyAudioTrackInitializationError(final AudioTrack.InitializationException e) {
    if (mEventHandler == null || mEventListener == null) {
        return;
    }
    mEventHandler.post(new Runnable() {
        @Override
        public void run() {
            mEventListener.onAudioTrackInitializationError(e);
        }
    });
}
项目:android_packages_apps_tv    文件:AudioTrackWrapper.java   
public void initialize() throws AudioTrack.InitializationException {
    if (!mIsEnabled) {
        return;
    }
    if (mAudioSessionID != AudioTrack.SESSION_ID_NOT_SET) {
        mAudioTrack.initialize(mAudioSessionID);
    } else {
        mAudioSessionID = mAudioTrack.initialize();
    }
}
项目:android_packages_apps_tv    文件:AudioTrackWrapper.java   
public int handleBuffer(ByteBuffer buffer, int offset, int size, long presentationTimeUs)
        throws AudioTrack.WriteException {
    if (!mIsEnabled) {
        return AudioTrack.RESULT_BUFFER_CONSUMED;
    }
    return mAudioTrack.handleBuffer(buffer, offset, size, presentationTimeUs);
}
项目:miku    文件:MediaCodecAudioTrackRenderer.java   
@Override
public long getPositionUs() {
  long newCurrentPositionUs = audioTrack.getCurrentPositionUs(isEnded());
  if (newCurrentPositionUs != AudioTrack.CURRENT_POSITION_NOT_SET) {
    currentPositionUs = allowPositionDiscontinuity
        ? newCurrentPositionUs
        : Math.max(currentPositionUs, newCurrentPositionUs);
    allowPositionDiscontinuity = false;
  }
  return (long) (currentPositionUs * audioTrack.getPlaybackSpeed());
}
项目:miku    文件:MediaCodecAudioTrackRenderer.java   
@Override
protected void onDisabled() {
  audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
  try {
    audioTrack.release();
  } finally {
    super.onDisabled();
  }
}
项目:miku    文件:MediaCodecAudioTrackRenderer.java   
private void notifyAudioTrackInitializationError(final AudioTrack.InitializationException e) {
  if (eventHandler != null && eventListener != null) {
    eventHandler.post(new Runnable() {
      @Override
      public void run() {
        eventListener.onAudioTrackInitializationError(e);
      }
    });
  }
}
项目:miku    文件:MediaCodecAudioTrackRenderer.java   
private void notifyAudioTrackWriteError(final AudioTrack.WriteException e) {
  if (eventHandler != null && eventListener != null) {
    eventHandler.post(new Runnable() {
      @Override
      public void run() {
        eventListener.onAudioTrackWriteError(e);
      }
    });
  }
}
项目:ExoPlayer-Demo    文件:LibopusAudioTrackRenderer.java   
/**
 * @param source The upstream source from which the renderer obtains samples.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public LibopusAudioTrackRenderer(SampleSource source, Handler eventHandler,
    EventListener eventListener) {
  super(source);
  this.eventHandler = eventHandler;
  this.eventListener = eventListener;
  this.audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
  audioTrack = new AudioTrack();
  formatHolder = new MediaFormatHolder();
}
项目:ExoPlayer-Demo    文件:LibopusAudioTrackRenderer.java   
@Override
public long getPositionUs() {
  long newCurrentPositionUs = audioTrack.getCurrentPositionUs(isEnded());
  if (newCurrentPositionUs != AudioTrack.CURRENT_POSITION_NOT_SET) {
    currentPositionUs = allowPositionDiscontinuity ? newCurrentPositionUs
        : Math.max(currentPositionUs, newCurrentPositionUs);
    allowPositionDiscontinuity = false;
  }
  return currentPositionUs;
}
项目:ExoPlayer-Demo    文件:LibopusAudioTrackRenderer.java   
private void notifyAudioTrackInitializationError(final AudioTrack.InitializationException e) {
  if (eventHandler != null && eventListener != null) {
    eventHandler.post(new Runnable() {
      @Override
      public void run() {
        eventListener.onAudioTrackInitializationError(e);
      }
    });
  }
}
项目:ExoPlayer-Demo    文件:LibopusAudioTrackRenderer.java   
private void notifyAudioTrackWriteError(final AudioTrack.WriteException e) {
  if (eventHandler != null && eventListener != null) {
    eventHandler.post(new Runnable() {
      @Override
      public void run() {
        eventListener.onAudioTrackWriteError(e);
      }
    });
  }
}
项目:ExoPlayer-Demo    文件:LibflacAudioTrackRenderer.java   
/**
 * @param source The upstream source from which the renderer obtains samples.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public LibflacAudioTrackRenderer(SampleSource source, Handler eventHandler,
    EventListener eventListener) {
  super(source);
  this.eventHandler = eventHandler;
  this.eventListener = eventListener;
  this.audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
  this.audioTrack = new AudioTrack();
  formatHolder = new MediaFormatHolder();
}
项目:ExoPlayer-Demo    文件:LibflacAudioTrackRenderer.java   
@Override
public long getPositionUs() {
  long newCurrentPositionUs = audioTrack.getCurrentPositionUs(isEnded());
  if (newCurrentPositionUs != AudioTrack.CURRENT_POSITION_NOT_SET) {
    currentPositionUs = allowPositionDiscontinuity ? newCurrentPositionUs
        : Math.max(currentPositionUs, newCurrentPositionUs);
    allowPositionDiscontinuity = false;
  }
  return currentPositionUs;
}
项目:ExoPlayer-Demo    文件:LibflacAudioTrackRenderer.java   
private void notifyAudioTrackInitializationError(final AudioTrack.InitializationException e) {
  if (eventHandler != null && eventListener != null) {
    eventHandler.post(new Runnable() {
      @Override
      public void run() {
        eventListener.onAudioTrackInitializationError(e);
      }
    });
  }
}
项目:ExoPlayer-Demo    文件:LibflacAudioTrackRenderer.java   
private void notifyAudioTrackWriteError(final AudioTrack.WriteException e) {
  if (eventHandler != null && eventListener != null) {
    eventHandler.post(new Runnable() {
      @Override
      public void run() {
        eventListener.onAudioTrackWriteError(e);
      }
    });
  }
}
项目:ExoPlayer-Demo    文件:MediaCodecAudioTrackRenderer.java   
@Override
public long getPositionUs() {
  long newCurrentPositionUs = audioTrack.getCurrentPositionUs(isEnded());
  if (newCurrentPositionUs != AudioTrack.CURRENT_POSITION_NOT_SET) {
    currentPositionUs = allowPositionDiscontinuity ? newCurrentPositionUs
        : Math.max(currentPositionUs, newCurrentPositionUs);
    allowPositionDiscontinuity = false;
  }
  return currentPositionUs;
}
项目:ExoPlayer-Demo    文件:MediaCodecAudioTrackRenderer.java   
@Override
protected void onDisabled() throws ExoPlaybackException {
  audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
  try {
    audioTrack.release();
  } finally {
    super.onDisabled();
  }
}
项目:ExoPlayer-Demo    文件:MediaCodecAudioTrackRenderer.java   
private void notifyAudioTrackInitializationError(final AudioTrack.InitializationException e) {
  if (eventHandler != null && eventListener != null) {
    eventHandler.post(new Runnable() {
      @Override
      public void run() {
        eventListener.onAudioTrackInitializationError(e);
      }
    });
  }
}
项目:ExoPlayer-Demo    文件:MediaCodecAudioTrackRenderer.java   
private void notifyAudioTrackWriteError(final AudioTrack.WriteException e) {
  if (eventHandler != null && eventListener != null) {
    eventHandler.post(new Runnable()  {
      @Override
      public void run() {
        eventListener.onAudioTrackWriteError(e);
      }
    });
  }
}
项目:androidtv-sample    文件:DemoPlayer.java   
@Override
public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
    if (internalErrorListener != null) {
        internalErrorListener.onAudioTrackInitializationError(e);
    }
}
项目:androidtv-sample    文件:DemoPlayer.java   
@Override
public void onAudioTrackWriteError(AudioTrack.WriteException e) {
    if (internalErrorListener != null) {
        internalErrorListener.onAudioTrackWriteError(e);
    }
}
项目:androidtv-sample    文件:VideoPlayer.java   
@Override
public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
    if (internalErrorListener != null) {
        internalErrorListener.onAudioTrackInitializationError(e);
    }
}
项目:androidtv-sample    文件:VideoPlayer.java   
@Override
public void onAudioTrackWriteError(AudioTrack.WriteException e) {
    if (internalErrorListener != null) {
        internalErrorListener.onAudioTrackWriteError(e);
    }
}
项目:AndroidTvDemo    文件:EventLogger.java   
@Override
public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
  printInternalError("audioTrackInitializationError", e);
}
项目:AndroidTvDemo    文件:EventLogger.java   
@Override
public void onAudioTrackWriteError(AudioTrack.WriteException e) {
  printInternalError("audioTrackWriteError", e);
}
项目:AndroidTvDemo    文件:DemoPlayer.java   
@Override
public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
  if (internalErrorListener != null) {
    internalErrorListener.onAudioTrackInitializationError(e);
  }
}
项目:AndroidTvDemo    文件:DemoPlayer.java   
@Override
public void onAudioTrackWriteError(AudioTrack.WriteException e) {
  if (internalErrorListener != null) {
    internalErrorListener.onAudioTrackWriteError(e);
  }
}
项目:chilly    文件:VideoPlayer.java   
@Override
public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
    if (internalErrorListener != null) {
        internalErrorListener.onAudioTrackInitializationError(e);
    }
}
项目:chilly    文件:VideoPlayer.java   
@Override
public void onAudioTrackWriteError(AudioTrack.WriteException e) {
    if (internalErrorListener != null) {
        internalErrorListener.onAudioTrackWriteError(e);
    }
}
项目:ShaddockVideoPlayer    文件:EventLogger.java   
@Override
public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
  printInternalError("audioTrackInitializationError", e);
}
项目:ShaddockVideoPlayer    文件:EventLogger.java   
@Override
public void onAudioTrackWriteError(AudioTrack.WriteException e) {
  printInternalError("audioTrackWriteError", e);
}
项目:ShaddockVideoPlayer    文件:DemoPlayer.java   
@Override
public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
  if (internalErrorListener != null) {
    internalErrorListener.onAudioTrackInitializationError(e);
  }
}
项目:ShaddockVideoPlayer    文件:DemoPlayer.java   
@Override
public void onAudioTrackWriteError(AudioTrack.WriteException e) {
  if (internalErrorListener != null) {
    internalErrorListener.onAudioTrackWriteError(e);
  }
}
项目:android-tv-news    文件:VideoPlayer.java   
@Override
public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
    if (internalErrorListener != null) {
        internalErrorListener.onAudioTrackInitializationError(e);
    }
}
项目:android-tv-news    文件:VideoPlayer.java   
@Override
public void onAudioTrackWriteError(AudioTrack.WriteException e) {
    if (internalErrorListener != null) {
        internalErrorListener.onAudioTrackWriteError(e);
    }
}
项目:mimi-reader    文件:ExoPlayerHelper.java   
@Override
public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
    if (internalErrorListener != null) {
        internalErrorListener.onAudioTrackInitializationError(e);
    }
}