File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 27
27
#include <string.h>
28
28
#include <syslog.h>
29
29
#include <sys/eventfd.h>
30
+ #include <sys/ioctl.h>
30
31
#include <sys/param.h>
31
32
#include <sys/time.h>
32
33
#include <unistd.h>
@@ -820,10 +821,15 @@ static void *io_worker_routine(struct io_worker *w) {
820
821
ffb_shift (& buffer , frames * w -> ba_pcm .channels );
821
822
822
823
int ret ;
823
- if (( ret = snd_pcm_delay ( w -> snd_pcm ,
824
- & pcm_delay_frames [ pcm_delay_frames_i ++ % ARRAYSIZE ( pcm_delay_frames )] )) != 0 )
824
+ snd_pcm_sframes_t delay_frames = 0 ;
825
+ if (( ret = snd_pcm_delay ( w -> snd_pcm , & delay_frames )) != 0 )
825
826
warn ("Couldn't get PCM delay: %s" , snd_strerror (ret ));
826
827
else {
828
+ unsigned int buffered = 0 ;
829
+ ioctl (w -> ba_pcm_fd , FIONREAD , & buffered );
830
+ buffered += ffb_blen_out (& buffer );
831
+ delay_frames += buffered / (w -> ba_pcm .channels * pcm_format_size );
832
+ pcm_delay_frames [pcm_delay_frames_i ++ % ARRAYSIZE (pcm_delay_frames )] = delay_frames ;
827
833
828
834
struct timespec ts_now ;
829
835
/* Rate limit delay updates to 1 update per second. */
You can’t perform that action at this time.
0 commit comments