aboutsummaryrefslogtreecommitdiff
path: root/audio/wavaudio.c
diff options
context:
space:
mode:
authorKővágó, Zoltán <dirty.ice.hu@gmail.com>2019-10-13 21:58:02 +0200
committerGerd Hoffmann <kraxel@redhat.com>2019-10-18 08:14:05 +0200
commit2b9cce8c8c37b95290c48c037e51e001985124d1 (patch)
tree82fbbf3fff30c561215cada4c3f2a97f8cda1dbb /audio/wavaudio.c
parentcecc1e79bf9ad9a0e2d3ce513d4f71792a0985f6 (diff)
audio: replace shift in audio_pcm_info with bytes_per_frame
The bit shifting trick worked because the number of bytes per frame was always a power-of-two (since QEMU only supports mono, stereo and 8, 16 and 32 bit samples). But if we want to add support for surround sound, this no longer holds true. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 1351fd9bcce0ff20d81850c5292722194329de02.1570996490.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio/wavaudio.c')
-rw-r--r--audio/wavaudio.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/audio/wavaudio.c b/audio/wavaudio.c
index 47efdc1b1e..e46d834bd3 100644
--- a/audio/wavaudio.c
+++ b/audio/wavaudio.c
@@ -43,14 +43,14 @@ static size_t wav_write_out(HWVoiceOut *hw, void *buf, size_t len)
{
WAVVoiceOut *wav = (WAVVoiceOut *) hw;
int64_t bytes = audio_rate_get_bytes(&hw->info, &wav->rate, len);
- assert(bytes >> hw->info.shift << hw->info.shift == bytes);
+ assert(bytes % hw->info.bytes_per_frame == 0);
if (bytes && fwrite(buf, bytes, 1, wav->f) != 1) {
dolog("wav_write_out: fwrite of %" PRId64 " bytes failed\nReason: %s\n",
bytes, strerror(errno));
}
- wav->total_samples += bytes >> hw->info.shift;
+ wav->total_samples += bytes / hw->info.bytes_per_frame;
return bytes;
}
@@ -134,7 +134,7 @@ static void wav_fini_out (HWVoiceOut *hw)
WAVVoiceOut *wav = (WAVVoiceOut *) hw;
uint8_t rlen[4];
uint8_t dlen[4];
- uint32_t datalen = wav->total_samples << hw->info.shift;
+ uint32_t datalen = wav->total_samples * hw->info.bytes_per_frame;
uint32_t rifflen = datalen + 36;
if (!wav->f) {