Better handle pausing with missing audio frames

This commit is contained in:
dec05eba
2024-01-19 18:41:09 +01:00
parent 89309215c3
commit 496e00e947

View File

@@ -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!!!