aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/inputPlugins/_flac_common.h4
-rw-r--r--src/inputPlugins/flac_plugin.c9
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