summaryrefslogtreecommitdiff
path: root/plugins/flac
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-12-25 18:10:33 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-12-25 18:10:33 +0100
commit4d6226caa4a770caecb208de7f71b40c521454a2 (patch)
treea480e57b45f9ec125dae5f2f06e19dc257a44eb1 /plugins/flac
parent3f91fde9095524adf05e8fdc5d50dbfea391dd4f (diff)
bitrate reporting for flac and vorbis plugins
Diffstat (limited to 'plugins/flac')
-rw-r--r--plugins/flac/flac.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/flac/flac.c b/plugins/flac/flac.c
index e9699377..07f54387 100644
--- a/plugins/flac/flac.c
+++ b/plugins/flac/flac.c
@@ -48,6 +48,7 @@ typedef struct {
int channels;
int totalsamples;
int bps;
+ int bytesread;
} cue_cb_data_t;
static cue_cb_data_t flac_callbacks;
@@ -56,6 +57,7 @@ static cue_cb_data_t flac_callbacks;
FLAC__StreamDecoderReadStatus flac_read_cb (const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) {
cue_cb_data_t *cb = (cue_cb_data_t *)client_data;
size_t r = deadbeef->fread (buffer, 1, *bytes, cb->file);
+ cb->bytesread += r;
*bytes = r;
if (r == 0) {
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
@@ -91,9 +93,15 @@ FLAC__bool flac_eof_cb (const FLAC__StreamDecoder *decoder, void *client_data) {
static FLAC__StreamDecoderWriteStatus
cflac_write_callback (const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const inputbuffer[], void *client_data) {
+ cue_cb_data_t *cb = (cue_cb_data_t *)client_data;
if (frame->header.blocksize == 0) {
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
+ int bitrate = cb->bytesread / ((float)frame->header.blocksize / frame->header.sample_rate) * 8;
+ cb->bytesread = 0;
+ if (bitrate > 0) {
+ deadbeef->streamer_set_bitrate (bitrate/1000);
+ }
int readbytes = frame->header.blocksize * plugin.info.channels * plugin.info.bps / 8;
int bufsize = BUFFERSIZE-remaining;
int bufsamples = bufsize / (plugin.info.channels * plugin.info.bps / 8);
@@ -242,6 +250,7 @@ cflac_read_int16 (char *bytes, int size) {
}
}
int initsize = size;
+ int nbytes_in = 0;
do {
if (remaining) {
int s = size * 2;