audio_format: added audio_format_sample_size()

The inline function audio_format_sample_size() calculates how many
bytes each sample consumes.  This function already takes into account
that 24 bit samples are 4 bytes long, not 3.
This commit is contained in:
Max Kellermann
2008-09-23 23:59:54 +02:00
parent e4f5d6bdf4
commit 128d8c7c15
7 changed files with 23 additions and 9 deletions

View File

@@ -289,7 +289,7 @@ configure_hw:
if (err < 0)
goto error;
ad->sampleSize = (audioFormat->bits / 8) * audioFormat->channels;
ad->sampleSize = audio_format_sample_size(audioFormat) * audioFormat->channels;
audioOutput->open = 1;

View File

@@ -268,7 +268,7 @@ static int osx_openDevice(struct audio_output *audioOutput)
#endif
streamDesc.mBytesPerPacket =
audioFormat->channels * audioFormat->bits / 8;
audioFormat->channels * audio_format_sample_size(audioFormat);
streamDesc.mFramesPerPacket = 1;
streamDesc.mBytesPerFrame = streamDesc.mBytesPerPacket;
streamDesc.mChannelsPerFrame = audioFormat->channels;

View File

@@ -141,7 +141,7 @@ static int shout_mp3_encoder_encode(struct shout_data *sd,
float (*lamebuf)[2];
struct shout_buffer *buf = &(sd->buf);
unsigned int samples;
int bytes = sd->audio_format.bits / 8;
int bytes = audio_format_sample_size(&sd->audio_format);
struct lame_data *ld = (struct lame_data *)sd->encoder_data;
int bytes_out;

View File

@@ -257,7 +257,7 @@ static int shout_ogg_encoder_encode(struct shout_data *sd,
int j;
float **vorbbuf;
unsigned int samples;
int bytes = sd->audio_format.bits / 8;
int bytes = audio_format_sample_size(&sd->audio_format);
struct ogg_vorbis_data *od = (struct ogg_vorbis_data *)sd->encoder_data;
samples = size / (bytes * sd->audio_format.channels);