diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2014-09-21 22:50:57 +0200 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2014-11-05 20:27:45 +0000 |
commit | 53412c3f7c9fd3cac2a33195dad87fdc1bc25103 (patch) | |
tree | 480bc1197cc764420dbd108b4f95ebc82c9e539e | |
parent | 51562cd4de104521223f8e4e9cbe04bef401a79f (diff) | |
download | lwn-53412c3f7c9fd3cac2a33195dad87fdc1bc25103.tar.gz lwn-53412c3f7c9fd3cac2a33195dad87fdc1bc25103.zip |
ALSA: pcm: fix fifo_size frame calculation
commit a9960e6a293e6fc3ed414643bb4e4106272e4d0a upstream.
The calculated frame size was wrong because snd_pcm_format_physical_width()
actually returns the number of bits, not bytes.
Use snd_pcm_format_size() instead, which not only returns bytes, but also
simplifies the calculation.
Fixes: 8bea869c5e56 ("ALSA: PCM midlevel: improve fifo_size handling")
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | sound/core/pcm_lib.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index cf0d46e5909e..7f00d34f0abd 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1692,14 +1692,16 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream, { struct snd_pcm_hw_params *params = arg; snd_pcm_format_t format; - int channels, width; + int channels; + ssize_t frame_size; params->fifo_size = substream->runtime->hw.fifo_size; if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { format = params_format(params); channels = params_channels(params); - width = snd_pcm_format_physical_width(format); - params->fifo_size /= width * channels; + frame_size = snd_pcm_format_size(format, channels); + if (frame_size > 0) + params->fifo_size /= (unsigned)frame_size; } return 0; } |