forked from auracaster/pyalsaaudio
Use correct sample bit width
snd_pcm_hw_params_get_sbits gives the number of significant bits, not the actual number of bits stored. Change to snd_pcm_format_physical_width. This fixes a bug where, for example on my hardware: format = 'S32_LE' significant bits = 24 physical bits = 32 the program will segfault because the allocated buffer is too small.
This commit is contained in:
committed by
Lars Immisch
parent
0aba948277
commit
eda913b203
@@ -403,7 +403,7 @@ static int alsapcm_setup(alsapcm_t *self)
|
||||
snd_pcm_hw_params_get_period_size(hwparams, &self->periodsize, &dir);
|
||||
snd_pcm_hw_params_get_periods(hwparams, &self->periods, &dir);
|
||||
|
||||
self->framesize = self->channels * snd_pcm_hw_params_get_sbits(hwparams)/8;
|
||||
self->framesize = self->channels * snd_pcm_format_physical_width(self->format)/8;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user