From 4695d954d5d5bf3813783eb7f4d8b4bc12545d26 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 16 Apr 2024 20:09:20 +0200 Subject: shit and poop --- src/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d88e8d5..439c8fb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2383,6 +2383,8 @@ int main(int argc, char **argv) { } memset(empty_audio, 0, audio_buffer_size); + const double audio_startup_time_seconds = 0.080833; + for(AudioTrack &audio_track : audio_tracks) { for(AudioDevice &audio_device : audio_track.audio_devices) { audio_device.thread = std::thread([&]() mutable { @@ -2427,7 +2429,7 @@ int main(int argc, char **argv) { const bool got_audio_data = sound_buffer_size >= 0; //const double time_after_read_seconds = clock_get_monotonic_seconds(); //const double time_to_read_seconds = time_after_read_seconds - time_before_read_seconds; - const double this_audio_frame_time = clock_get_monotonic_seconds() - paused_time_offset; + const double this_audio_frame_time = (clock_get_monotonic_seconds() - audio_startup_time_seconds) - paused_time_offset; if(paused) { if(got_audio_data) @@ -2566,7 +2568,8 @@ int main(int argc, char **argv) { int err = 0; while ((err = av_buffersink_get_frame(audio_track.sink, aframe)) >= 0) { - const int64_t new_pts = ((clock_get_monotonic_seconds() - paused_time_offset) - record_start_time) * AV_TIME_BASE; + const double this_audio_frame_time = (clock_get_monotonic_seconds() - audio_startup_time_seconds) - paused_time_offset; + const int64_t new_pts = (this_audio_frame_time - record_start_time) * AV_TIME_BASE; if(new_pts == aframe->pts) continue; aframe->pts = new_pts; -- cgit v1.2.3