diff options
author | Max Kellermann <max@duempel.org> | 2008-09-23 23:59:54 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-23 23:59:54 +0200 |
commit | 128d8c7c15c0713cfccc42dfeea9b0cd9ed11d14 (patch) | |
tree | 92bb882c28b4f2621e3cccfbf1e1aa740f76a55c /src/inputPlugins | |
parent | e4f5d6bdf47c96dc9c0b5fe287598bc10b168a71 (diff) | |
download | mpd-128d8c7c15c0713cfccc42dfeea9b0cd9ed11d14.tar.gz mpd-128d8c7c15c0713cfccc42dfeea9b0cd9ed11d14.tar.xz mpd-128d8c7c15c0713cfccc42dfeea9b0cd9ed11d14.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | src/inputPlugins/flac_plugin.c | 3 | ||||
-rw-r--r-- | src/inputPlugins/oggflac_plugin.c | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 15d5c6d63..a579209e4 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -237,7 +237,8 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, FLAC__uint32 samples = frame->header.blocksize; unsigned int c_samp; const unsigned int num_channels = frame->header.channels; - const unsigned int bytes_per_sample = (data->audio_format.bits / 8); + const unsigned int bytes_per_sample = + audio_format_sample_size(&data->audio_format); const unsigned int bytes_per_channel = bytes_per_sample * frame->header.channels; const unsigned int max_samples = FLAC_CHUNK_SIZE / bytes_per_channel; diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c index e0cf02524..31ddaab7f 100644 --- a/src/inputPlugins/oggflac_plugin.c +++ b/src/inputPlugins/oggflac_plugin.c @@ -160,7 +160,7 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(mpd_unused const FLAC__uint16 u16; unsigned char *uc; unsigned int c_samp, c_chan; - int i; + unsigned int i; float timeChange; timeChange = ((float)samples) / frame->header.sample_rate; @@ -183,7 +183,7 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(mpd_unused const c_chan++) { u16 = buf[c_chan][c_samp]; uc = (unsigned char *)&u16; - for (i = 0; i < (data->audio_format.bits / 8); i++) { + for (i = 0; i < audio_format_sample_size(&data->audio_format); i++) { if (data->chunk_length >= FLAC_CHUNK_SIZE) { if (flacSendChunk(data) < 0) { return |