@@ -118,8 +118,8 @@ private void init(VideoDecoderInterface videoDecoderInterface,
118118 this .audioDecoderInterface = audioDecoderInterface ;
119119 videoEncoder = new VideoEncoder (getVideoData );
120120 audioEncoder = new AudioEncoder (getAudioData );
121- videoDecoder = new VideoDecoder (videoDecoderInterface , decoderInterface );
122- audioDecoder = new AudioDecoder (getMicrophoneData , audioDecoderInterface , decoderInterface );
121+ videoDecoder = new VideoDecoder (videoDecoderInterface , decoderInterfaceVideo );
122+ audioDecoder = new AudioDecoder (getMicrophoneData , audioDecoderInterface , decoderInterfaceAudio );
123123 recordController = new AndroidMuxerRecordController ();
124124 }
125125
@@ -673,7 +673,7 @@ private void resetVideoDecoder(IORunnable runnable) throws IOException {
673673 int width = videoDecoder .getWidth ();
674674 int height = videoDecoder .getHeight ();
675675 boolean wasRunning = videoDecoder .isRunning ();
676- VideoDecoder videoDecoder = new VideoDecoder (videoDecoderInterface , decoderInterface );
676+ VideoDecoder videoDecoder = new VideoDecoder (videoDecoderInterface , decoderInterfaceVideo );
677677 videoDecoder .setExtractor (this .videoDecoder .getExtractor ());
678678 runnable .run (videoDecoder );
679679 if (width != videoDecoder .getWidth () || height != videoDecoder .getHeight ()) throw new IOException ("Resolution must be the same that the previous file" );
@@ -687,7 +687,7 @@ private void resetAudioDecoder(IORunnable runnable) throws IOException {
687687 int sampleRate = audioDecoder .getSampleRate ();
688688 boolean isStereo = audioDecoder .isStereo ();
689689 boolean wasRunning = audioDecoder .isRunning ();
690- AudioDecoder audioDecoder = new AudioDecoder (getMicrophoneData , audioDecoderInterface , decoderInterface );
690+ AudioDecoder audioDecoder = new AudioDecoder (getMicrophoneData , audioDecoderInterface , decoderInterfaceAudio );
691691 audioDecoder .setExtractor (this .audioDecoder .getExtractor ());
692692 runnable .run (audioDecoder );
693693 if (sampleRate != audioDecoder .getSampleRate ()) throw new IOException ("SampleRate must be the same that the previous file" );
@@ -765,12 +765,19 @@ public void onVideoFormat(@NonNull MediaFormat mediaFormat) {
765765 }
766766 };
767767
768- private final DecoderInterface decoderInterface = new DecoderInterface () {
768+ private final DecoderInterface decoderInterfaceVideo = new DecoderInterface () {
769769
770770 @ Override
771771 public void onLoop () {
772- videoDecoder .reset (glInterface .getSurface ());
773- audioDecoder .reset (null );
772+ if (videoDecoder .isRunning ()) videoDecoder .reset (glInterface .getSurface ());
773+ }
774+ };
775+
776+ private final DecoderInterface decoderInterfaceAudio = new DecoderInterface () {
777+
778+ @ Override
779+ public void onLoop () {
780+ if (audioDecoder .isRunning ()) audioDecoder .reset (null );
774781 }
775782 };
776783
0 commit comments