Skip to contentSkip to conversation

prealloc/buffer time limit?

DISCUSSION Ron Cococcia 3 participants 7 messages Feb 10, 2006 – Feb 14, 2006

lore
Share & tools
lore
#0 lore raw

Hello,

Recently I've been playing around with buffering in ALSA to reduce the number of underruns I observe when playing audio under heavy system load. The playback device has 64k allocated by default, and I upped it to 128k (echo 128 > /proc/asound/card0/pcm0p/sub0/prealloc). I observed a significant reduction in underruns with this change. The buffer time went from 371519 to 743038 (using snd_pcm_hw_params_set_buffer_time_near to 5000000 (not .5 sec, but 5 sec)). I am assuming that the value is updated to give the actual available buffer time after snd_pcm_hw_params has complete (please inform me if I am wrong!!).

I then tried to up it to 256, and it didn't work (prealloc remained at 128). I went into the driver for the sound device (intel8x0), and noticed the buffer_max being set to 128. I modified the max values to 512k (overkill, but I want to experiment a little), recompiled, installed, etc.

When I tried to increase it to 256, prealloc reports 256 successfully (same for 512). The buffer time did not increase, however. I am looking to be able to increase the buffer time a little further. I have been poking through code (at a snail's pace unfortunately) to see if I can find some other place where this value is limited (driver, lib, etc). Either prealloc reports the value and doesn't actually have a larger buffer, or some other buffer time limit is in place that I haven't been able to find yet.

Is there some other place I can check to increase the buffer time (in particular, if I increase the prealloc size).

TIA,
Ron

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642

#1 lore raw
Quoted 2 lines · Ron Cococcia

I went into the driver for the sound device (intel8x0), and noticed the buffer_max being set to 128. I modified the max values to 512k

There is no buffer_max symbol. What exactly did you change?

Regards,
Clemens

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642

#2 lore raw

My apologies :) I've been flipping between 2 different tasks, and flipped the symbol name. I am referring to "prealloc_max_size", part of the ich_pcm_table struct for intel8x0.

Thanks and best regards,
Ron

Quoted 11 lines · Clemens Ladisch
Quoted 2 lines · Ron Cococcia

I went into the driver for the sound device (intel8x0), and noticed the buffer_max being set to 128. I modified the max values to 512k

There is no buffer_max symbol. What exactly did you change?

Regards,
Clemens

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642

#3 lore raw

A. Because it's contrary to the direction we normally read in. Q. Why is top-posting so bad, then?
A. Top-posting.
Q. What's the biggest problem with readability on the Net?

Quoted 2 lines · Ron Cococcia

I am referring to "prealloc_max_size", part of the ich_pcm_table struct for intel8x0.

Change appropriate fields in snd_intel8x0_stream, too.

HTH
Clemens

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642

#6 lore raw
In reply to Ron Cococcia
Quoted 27 lines · Ron Cococcia

Hello,

Recently I've been playing around with buffering in ALSA to reduce the number of underruns I observe when playing audio under heavy system load. The playback device has 64k allocated by default, and I upped it to 128k (echo 128 > /proc/asound/card0/pcm0p/sub0/prealloc). I observed a significant reduction in underruns with this change. The buffer time went from 371519 to 743038 (using snd_pcm_hw_params_set_buffer_time_near to 5000000 (not .5 sec, but 5 sec)). I am assuming that the value is updated to give the actual available buffer time after snd_pcm_hw_params has complete (please inform me if I am wrong!!).

I then tried to up it to 256, and it didn't work (prealloc remained at 128). I went into the driver for the sound device (intel8x0), and noticed the buffer_max being set to 128. I modified the max values to 512k (overkill, but I want to experiment a little), recompiled, installed, etc.

When I tried to increase it to 256, prealloc reports 256 successfully (same for 512). The buffer time did not increase, however. I am looking to be able to increase the buffer time a little further. I have been poking through code (at a snail's pace unfortunately) to see if I can find some other place where this value is limited (driver, lib, etc). Either prealloc reports the value and doesn't actually have a larger buffer, or some other buffer time limit is in place that I haven't been able to find yet.

Quoted 6 lines

Is there some other place I can check to increase the buffer time (in particular, if I increase the prealloc size).

TIA,
Ron

You are most likely running up against the hardware limitations of the sound card.
If the hardware DMA pointer is only X bits long, it won't matter how big you make the buffer, the sound card will not be able to use it.

James

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642

#4 lore raw
In reply to Clemens Ladisch
Quoted 2 lines · Clemens Ladisch

Change appropriate fields in snd_intel8x0_stream, too.

That's exactly what I was looking for :) As James mentioned, it might not work correctly, but I'm experimenting to see what I can make it do.

Thanks again!

-Ron

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642

#5 lore raw
Quoted 5 lines · Ron Cococcia
Quoted 1 line · Clemens Ladisch

Change appropriate fields in snd_intel8x0_stream, too.

That's exactly what I was looking for :) As James mentioned, it might not work correctly, but I'm experimenting to see what I can make it do.

This hardware has not size limit for its DMA buffer.

Clemens

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642