protected void flushCodec() throws ExoPlaybackException { codecHotswapDeadlineMs = C.TIME_UNSET; resetInputBuffer(); resetOutputBuffer(); waitingForFirstSyncFrame = true; waitingForKeys = false; shouldSkipOutputBuffer = false; decodeOnlyPresentationTimestamps.clear(); codecNeedsAdaptationWorkaroundBuffer = false; shouldSkipAdaptationWorkaroundOutputBuffer = false; if (codecNeedsFlushWorkaround || (codecNeedsEosFlushWorkaround && codecReceivedEos)) { releaseCodec(); maybeInitCodec(); } else if (codecReinitializationState != REINITIALIZATION_STATE_NONE) { // We're already waiting to release and re-initialize the codec. Since we're now flushing, // there's no need to wait any longer. releaseCodec(); maybeInitCodec(); } else { // We can flush and re-use the existing decoder. codec.flush(); codecReceivedBuffers = false; } if (codecReconfigured && format != null) { // Any reconfiguration data that we send shortly before the flush may be discarded. We // avoid this issue by sending reconfiguration data following every flush. codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING; } }
@Override public void seek(long timeInUs, boolean shouldFlush) { extractor.seekTo(timeInUs, MediaExtractor.SEEK_TO_CLOSEST_SYNC); currentTimeUs = timeInUs; //Log.d("DECODE", "CURRENT TIME: " + String.valueOf(currentTimeUs)); //Log.d("DECODE", "total duration: " + String.valueOf(durationUs)); // if (shouldFlush) codec.flush(); }
private void reset(int width, int height) { if (mediaCodecThread == null || mediaCodec == null) { throw new RuntimeException("Incorrect reset call for non-initialized decoder."); } Logging.d(TAG, "Java reset: " + width + " x " + height); mediaCodec.flush(); this.width = width; this.height = height; decodeStartTimeMs.clear(); dequeuedSurfaceOutputBuffers.clear(); hasDecodedFirstFrame = false; droppedFrames = 0; }
public void stop() { synchronized (sync) { running = false; if (thread != null) { thread.interrupt(); try { thread.join(100); } catch (InterruptedException e) { thread.interrupt(); } thread = null; } if (videoEncoder != null) { videoEncoder.flush(); videoEncoder.stop(); videoEncoder.release(); videoEncoder = null; } queue.clear(); fpsLimiter.reset(); spsPpsSetted = false; inputSurface = null; } }
private void flushCodec() throws ExoPlaybackException { codecHotswapTimeMs = -1; inputIndex = -1; outputIndex = -1; waitingForFirstSyncFrame = true; waitingForKeys = false; decodeOnlyPresentationTimestamps.clear(); if (Util.SDK_INT < 18 || (codecNeedsEosFlushWorkaround && codecReceivedEos)) { // Workaround framework bugs. See [Internal: b/8347958, b/8578467, b/8543366, b/23361053]. releaseCodec(); maybeInitCodec(); } else if (codecReinitializationState != REINITIALIZATION_STATE_NONE) { // We're already waiting to release and re-initialize the codec. Since we're now flushing, // there's no need to wait any longer. releaseCodec(); maybeInitCodec(); } else { // We can flush and re-use the existing decoder. codec.flush(); codecHasQueuedBuffers = false; } if (codecReconfigured && format != null) { // Any reconfiguration data that we send shortly before the flush may be discarded. We // avoid this issue by sending reconfiguration data following every flush. codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING; } }
callOnStop(); if (mIsRunning) { mMediaCodec.flush(); synchronized (mSync) { if (mState == STATE_WAIT)