Hi Fons/Marc,
For Digital radio the audio data is received in compressed format. Using audio codec it is uncompressed. The uncompressed audio will be sent to audio sink with a block size of 24ms. Before sending these audio blocks are timestamped using PC microsecond timer. To access the clock value of timer, I do a "direct" read of memory mapped hardware register (TSC) to avoid OS delays and jitter etc. So the logic is whenever an audio compressed frame arrives at the audio codec, it is timestamped with the current time (Ti) and after uncompressed each audio frame blocks (24ms) is timestamped by adding 24ms ( Ti + ( frame_no * frame_duration ) ), where Ti is the start time and frame_no is the decoded uncompressed frames ranges from 0 to n and frame_duration is 24ms. When these audio frames reaches the audio sink, it reads the current time (Tc) from same clock (TSC) and measure the elapsed time , diff = ( ( Tk + delay ) - Tc ), where Tk = ( Ti + ( frame_no * frame_duration ) ) and delay is 2 frame delay (48ms) . Every time the audio sink call back happens (aftre streaming an aduio frame(24ms) interrupt happens) , the diff is calculated and accumulated. Ideally if the audio sink is sending at the "nominal sample rate" the delay should be constant. After some N seconds this accumulated value is averaged by dividing by N sec. So I get the drift in sampling rate in terms of samples. Then all I need to do is slow down or speed up the sampling rate based on which side the drift is. Is it possible to change the sample rate of ALSA by drift amount ? -ben ________________________________ From: Fons Adriaensen <f...@linuxaudio.org> Sent: Monday, November 7, 2016 1:34:07 AM To: Marcus Müller Cc: Benny Alexandar; discuss-gnuradio@gnu.org Subject: Re: [Discuss-gnuradio] Broadcast Receiver Audio Synchronization ( Delay locked loop for the two-clock problem) On Sun, Nov 06, 2016 at 07:32:47PM +0100, Marcus Müller wrote: > under the hood, sinks are sync_blocks. Which is what surprises me. Sinks have no outputs, and sources have no inputs, so the whole 'sync' concept seems out of place... Ciao, -- FA A world of exhaustive, reliable metadata would be an utopia. It's also a pipe-dream, founded on self-delusion, nerd hubris and hysterically inflated market opportunities. (Cory Doctorow)
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio