diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2014-09-21 16:50:57 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-09-22 02:51:35 -0400 |
commit | a9960e6a293e6fc3ed414643bb4e4106272e4d0a (patch) | |
tree | f00c53cde94fe2f6935adad07c8d56ee9795b984 /sound | |
parent | 8245b3634516e6b7eb1c94594c0fd41d233502aa (diff) |
ALSA: pcm: fix fifo_size frame calculation
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>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-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 9acc77eae487..0032278567ad 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -1782,14 +1782,16 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream, | |||
1782 | { | 1782 | { |
1783 | struct snd_pcm_hw_params *params = arg; | 1783 | struct snd_pcm_hw_params *params = arg; |
1784 | snd_pcm_format_t format; | 1784 | snd_pcm_format_t format; |
1785 | int channels, width; | 1785 | int channels; |
1786 | ssize_t frame_size; | ||
1786 | 1787 | ||
1787 | params->fifo_size = substream->runtime->hw.fifo_size; | 1788 | params->fifo_size = substream->runtime->hw.fifo_size; |
1788 | if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { | 1789 | if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { |
1789 | format = params_format(params); | 1790 | format = params_format(params); |
1790 | channels = params_channels(params); | 1791 | channels = params_channels(params); |
1791 | width = snd_pcm_format_physical_width(format); | 1792 | frame_size = snd_pcm_format_size(format, channels); |
1792 | params->fifo_size /= width * channels; | 1793 | if (frame_size > 0) |
1794 | params->fifo_size /= (unsigned)frame_size; | ||
1793 | } | 1795 | } |
1794 | return 0; | 1796 | return 0; |
1795 | } | 1797 | } |