mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
echo-cancel: keep frame_size a power of 2
The speex echo canceler prefers a power of 2 for the frame size. Round down the ideal frame_size to the nearest power of two. This makes sure we don't create more than the requested frame_size_ms latency while still providing a power of 2 to the speex echo canceller.
This commit is contained in:
parent
1983337f0e
commit
d18cae458f
1 changed files with 8 additions and 1 deletions
|
|
@ -1269,7 +1269,7 @@ int pa__init(pa_module*m) {
|
|||
pa_source_new_data source_data;
|
||||
pa_sink_new_data sink_data;
|
||||
pa_memchunk silence;
|
||||
int framelen, rate;
|
||||
int framelen, rate, y;
|
||||
uint32_t frame_size_ms, filter_size_ms;
|
||||
uint32_t adjust_time_sec;
|
||||
|
||||
|
|
@ -1323,6 +1323,13 @@ int pa__init(pa_module*m) {
|
|||
u->frame_size_ms = frame_size_ms;
|
||||
rate = ss.rate;
|
||||
framelen = (rate * frame_size_ms) / 1000;
|
||||
|
||||
/* framelen should be a power of 2, round down to nearest power of two */
|
||||
y = 1 << ((8 * sizeof (int)) - 2);
|
||||
while (y > framelen)
|
||||
y >>= 1;
|
||||
framelen = y;
|
||||
|
||||
u->blocksize = framelen * pa_frame_size (&ss);
|
||||
pa_log_debug ("Using framelen %d, blocksize %lld, channels %d, rate %d", framelen, (long long) u->blocksize,
|
||||
ss.channels, ss.rate);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue