diff options
author | Max Kellermann <max@duempel.org> | 2008-04-12 04:19:55 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-04-12 04:19:55 +0000 |
commit | 96eb0119cce704c10f43aae422cd56594af0a29c (patch) | |
tree | 40d94e4cf416a6a6be18ff9a009111dd460106f3 /src | |
parent | 14529af732703dc0706be7db87a5292d0d122e77 (diff) | |
download | mpd-96eb0119cce704c10f43aae422cd56594af0a29c.tar.gz mpd-96eb0119cce704c10f43aae422cd56594af0a29c.tar.xz mpd-96eb0119cce704c10f43aae422cd56594af0a29c.zip |
use unsigned integers and size_t in the flac plugin
git-svn-id: https://svn.musicpd.org/mpd/trunk@7324 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r-- | src/inputPlugins/_flac_common.h | 4 | ||||
-rw-r--r-- | src/inputPlugins/flac_plugin.c | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/inputPlugins/_flac_common.h b/src/inputPlugins/_flac_common.h index 94f9cd1db..faeccf1ca 100644 --- a/src/inputPlugins/_flac_common.h +++ b/src/inputPlugins/_flac_common.h @@ -144,9 +144,9 @@ typedef size_t flac_read_status_size_t; typedef struct { unsigned char chunk[FLAC_CHUNK_SIZE]; - int chunk_length; + size_t chunk_length; float time; - int bitRate; + unsigned int bitRate; FLAC__uint64 position; OutputBuffer *cb; DecoderControl *dc; diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 23d61e805..fc55919b4 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -216,15 +216,20 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, FLAC__uint16 u16; unsigned char *uc; unsigned int c_samp, c_chan; - int i; + unsigned int i; float timeChange; FLAC__uint64 newPosition = 0; + assert(data->dc->audioFormat.bits > 0); + timeChange = ((float)samples) / frame->header.sample_rate; data->time += timeChange; flac_get_decode_position(dec, &newPosition); if (data->position) { + assert(newPosition >= data->position); + assert(timeChange >= 0); + data->bitRate = ((newPosition - data->position) * 8.0 / timeChange) / 1000 + 0.5; @@ -236,7 +241,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, c_chan++) { u16 = buf[c_chan][c_samp]; uc = (unsigned char *)&u16; - for (i = 0; i < (data->dc->audioFormat.bits / 8); i++) { + for (i = 0; i < (unsigned)(data->dc->audioFormat.bits / 8); i++) { if (data->chunk_length >= FLAC_CHUNK_SIZE) { if (flacSendChunk(data) < 0) { return |