audio_format: added audio_format_frame_size()

A frame contains one sample per channel, thus it is sample_size *
channels.  This patch includes some cleanup for various locations
where the sample size for 24 bit audio was still 3 bytes (instead of
4).
This commit is contained in:
Max Kellermann
2008-10-10 14:41:37 +02:00
parent de2cb3f375
commit 96155a3376
5 changed files with 12 additions and 7 deletions

View File

@@ -288,7 +288,7 @@ configure_hw:
if (err < 0)
goto error;
ad->sampleSize = audio_format_sample_size(audioFormat) * audioFormat->channels;
ad->sampleSize = audio_format_frame_size(audioFormat);
DEBUG("ALSA device \"%s\" will be playing %i bit, %u channel audio at "
"%u Hz\n", ad->device, audioFormat->bits,

View File

@@ -266,8 +266,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
streamDesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
#endif
streamDesc.mBytesPerPacket =
audioFormat->channels * audio_format_sample_size(audioFormat);
streamDesc.mBytesPerPacket = audio_format_frame_size(audioFormat);
streamDesc.mFramesPerPacket = 1;
streamDesc.mBytesPerFrame = streamDesc.mBytesPerPacket;
streamDesc.mChannelsPerFrame = audioFormat->channels;
@@ -284,7 +283,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
/* create a buffer of 1s */
od->bufferSize = (audioFormat->sample_rate) *
(audioFormat->bits >> 3) * (audioFormat->channels);
audio_format_frame_size(audioFormat);
od->buffer = xrealloc(od->buffer, od->bufferSize);
od->pos = 0;