Skip to content

Commit

Permalink
ALSA: pcm: fix fifo_size frame calculation
Browse files Browse the repository at this point in the history
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: 8bea869 ("ALSA: PCM midlevel: improve fifo_size handling")
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Clemens Ladisch authored and Takashi Iwai committed Sep 22, 2014
1 parent 8245b36 commit a9960e6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sound/core/pcm_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1782,14 +1782,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;
}
Expand Down

0 comments on commit a9960e6

Please sign in to comment.