I'm getting confused by ALSA API again, can anyone clarify.
I'm setting up ALSA with this :
int bufchunks = 10;
// bufchunks are the number of 512 sample buffers alsa is using
unsigned int buflen;
unsigned int wanted_buflen = 13 * bufchunks;
// milliseconds * number of frames
int dir=1;
// Value is in useconds
wanted_buflen=wanted_buflen * 1000;
// convert milliseconds to useconds
buflen = wanted_buflen;
if (snd_pcm_hw_params_set_buffer_time_near(playback_handle, hw_params,
&buflen, &dir) < 0)
{
fprintf(stderr,"%s: ALSA: initialise_sound_system() - Couldn't
set buffer length",PROGNAME);
exit(1);
}
I am reading the latency like this :
int get_playback_latency_ms()
{
int framesleft;
int ms_in_buffer;
framesleft=snd_pcm_avail (playback_handle);
// How many samples behind is the player
return( (framesleft*1000)/playback_sample_rate );
// frames to milliseconds
}
printf("%d\n",get_playback_latency_ms());
In my main loop gives me results like this.
23
12
0
82
70
58
47
35
24
12
If I increase the bufchunks value I seem to get larger latency (If I
pause terminal output with ^S it takes a longer time to stop playing),
yet the latency values i'm reading always seem to be the same.
How do I read a true latency in milliseconds ?
Thanks,
Jon
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Alsa-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-user