Skip to content

Display and control your Android device

Move last packet recording

Romain Vimont4b246cd963eb
diff --git a/app/src/recorder.c b/app/src/recorder.c
index aa3aea0e..85f0fd2a 100644
--- a/app/src/recorder.c
+++ b/app/src/recorder.c
@@ -220,19 +220,6 @@ sc_recorder_process_packets(struct sc_recorder *recorder) {
if (recorder->stopped && sc_queue_is_empty(&recorder->queue)) {
sc_mutex_unlock(&recorder->mutex);
- struct sc_record_packet *last = previous;
- if (last) {
- // assign an arbitrary duration to the last packet
- last->packet->duration = 100000;
- bool ok = sc_recorder_write(recorder, last->packet);
- if (!ok) {
- // failing to write the last frame is not very serious, no
- // future frame may depend on it, so the resulting file
- // will still be valid
- LOGW("Could not record last packet");
- }
- sc_record_packet_delete(last);
- }
break;
}
@@ -283,6 +270,21 @@ sc_recorder_process_packets(struct sc_recorder *recorder) {
return false;
}
+ // Write the last packet
+ struct sc_record_packet *last = previous;
+ if (last) {
+ // assign an arbitrary duration to the last packet
+ last->packet->duration = 100000;
+ bool ok = sc_recorder_write(recorder, last->packet);
+ if (!ok) {
+ // failing to write the last frame is not very serious, no
+ // future frame may depend on it, so the resulting file
+ // will still be valid
+ LOGW("Could not record last packet");
+ }
+ sc_record_packet_delete(last);
+ }
+
int ret = av_write_trailer(recorder->ctx);
if (ret < 0) {
LOGE("Failed to write trailer to %s", recorder->filename);