Skip to content

Commit

Permalink
Merge pull request #70 from jianinz/master
Browse files Browse the repository at this point in the history
fix(recorder): make sure onVideoFileReady could only be called once
Thanks ! great pull request !!
  • Loading branch information
MasayukiSuda authored Oct 28, 2020
2 parents 1824bae + 3c29010 commit 02d7f8d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ private void destroyPreview() {
private final MediaEncoder.MediaEncoderListener mediaEncoderListener = new MediaEncoder.MediaEncoderListener() {
private boolean videoStopped;
private boolean audioStopped;
private boolean videoExitReady;
private boolean audioExitReady;

@Override
public void onPrepared(final MediaEncoder encoder) {
Expand Down Expand Up @@ -221,8 +223,14 @@ public void onStopped(final MediaEncoder encoder) {
}

@Override
public void onExit() {
if (videoStopped && audioStopped) {
public void onExit(final MediaEncoder encoder) {
if (encoder instanceof MediaVideoEncoder && videoStopped) {
videoExitReady = true;
}
if (encoder instanceof MediaAudioEncoder && audioStopped) {
audioExitReady = true;
}
if (videoExitReady && audioExitReady) {
cameraRecordListener.onVideoFileReady();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface MediaEncoderListener {

void onStopped(MediaEncoder encoder);

void onExit();
void onExit(MediaEncoder encoder);
}

protected final Object sync = new Object();
Expand Down Expand Up @@ -145,7 +145,7 @@ public void run() {
requestStop = true;
isCapturing = false;
}
listener.onExit();
listener.onExit(this);
}

/*
Expand Down

0 comments on commit 02d7f8d

Please sign in to comment.