[PATCH] alsa_dev ignores period size return by ALSA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey folks,

we have recently come across a problem with the ALSA backend in pjmedia.
We've got a special setup with fixed sound parameters in our ALSA config
and found that alsa_dev ignores the period size returned by the calls
to snd_pcm_hw_params_set_period_size_near().
alsa_dev simply assumes that it always gets the period size it requests
which was not the case in our environment
and lead to random crashes of our application because the buffer
that is allocated later on was wrongly sized.

Best regards,
Andreas Wehrmann

Index: pjmedia/src/pjmedia-audiodev/alsa_dev.c
===================================================================
--- pjmedia/src/pjmedia-audiodev/alsa_dev.c	(revision 6048)
+++ pjmedia/src/pjmedia-audiodev/alsa_dev.c	(working copy)
@@ -689,6 +689,7 @@
     tmp_period_size = stream->pb_frames;
     snd_pcm_hw_params_set_period_size_near (stream->pb_pcm, params,
 					    &tmp_period_size, NULL);
+    stream->pb_frames = tmp_period_size;
     TRACE_((THIS_FILE, "open_playback: period size set to: %d",
 	    tmp_period_size));
 
@@ -807,6 +808,7 @@
     tmp_period_size = stream->ca_frames;
     snd_pcm_hw_params_set_period_size_near (stream->ca_pcm, params,
 					    &tmp_period_size, NULL);
+    stream->ca_frames = tmp_period_size;
     TRACE_((THIS_FILE, "open_capture: period size set to: %d",
 	    tmp_period_size));
 
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux