aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-01-19 18:41:09 +0100
committerdec05eba <dec05eba@protonmail.com>2024-01-19 18:41:09 +0100
commit496e00e947bd37c5eed6e9d96950bd06722278f7 (patch)
treebb9fddcc301dd0db015b47828cfa333263cf3961
parent89309215c39cb7f9d4db7ae2760840d6655f1088 (diff)
Better handle pausing with missing audio frames
-rw-r--r--src/main.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 21f5f8c..801625e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2296,6 +2296,16 @@ int main(int argc, char **argv) {
const double this_audio_frame_time = clock_get_monotonic_seconds() - paused_time_offset;
+ if(paused) {
+ if(got_audio_data)
+ received_audio_time = this_audio_frame_time;
+
+ if(!audio_device.sound_device.handle)
+ usleep(timeout_ms * 1000);
+
+ continue;
+ }
+
int ret = av_frame_make_writable(audio_device.frame);
if (ret < 0) {
fprintf(stderr, "Failed to make audio frame writable\n");
@@ -2313,13 +2323,6 @@ int main(int argc, char **argv) {
if(got_audio_data)
received_audio_time = this_audio_frame_time;
- if(paused) {
- received_audio_time = this_audio_frame_time;
- if(!audio_device.sound_device.handle)
- usleep(timeout_ms * 1000);
- continue;
- }
-
// Jesus is there a better way to do this? I JUST WANT TO KEEP VIDEO AND AUDIO SYNCED HOLY FUCK I WANT TO KILL MYSELF NOW.
// THIS PIECE OF SHIT WANTS EMPTY FRAMES OTHERWISE VIDEO PLAYS TOO FAST TO KEEP UP WITH AUDIO OR THE AUDIO PLAYS TOO EARLY.
// BUT WE CANT USE DELAYS TO GIVE DUMMY DATA BECAUSE PULSEAUDIO MIGHT GIVE AUDIO A BIG DELAYED!!!