aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:05 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:05 +0200
commit0d8b551c5a3aeadfd6901469946078d5a95ecb42 (patch)
tree3fd36e06ef46dfcfc7f9e426b42668318aec8d59 /src/inputPlugins
parent4590a98f0eb9484e185e7e0c25a3373c8e9076ea (diff)
downloadmpd-0d8b551c5a3aeadfd6901469946078d5a95ecb42.tar.gz
mpd-0d8b551c5a3aeadfd6901469946078d5a95ecb42.tar.xz
mpd-0d8b551c5a3aeadfd6901469946078d5a95ecb42.zip
added parameter total_time to decoder_initialized()
Similar to the previous patch: pass total_time instead of manipulating dc->totalTime directly.
Diffstat (limited to 'src/inputPlugins')
-rw-r--r--src/inputPlugins/_flac_common.c2
-rw-r--r--src/inputPlugins/_flac_common.h1
-rw-r--r--src/inputPlugins/aac_plugin.c5
-rw-r--r--src/inputPlugins/audiofile_plugin.c8
-rw-r--r--src/inputPlugins/flac_plugin.c2
-rw-r--r--src/inputPlugins/mod_plugin.c3
-rw-r--r--src/inputPlugins/mp3_plugin.c4
-rw-r--r--src/inputPlugins/mp4_plugin.c7
-rw-r--r--src/inputPlugins/mpc_plugin.c5
-rw-r--r--src/inputPlugins/oggflac_plugin.c2
-rw-r--r--src/inputPlugins/oggvorbis_plugin.c9
-rw-r--r--src/inputPlugins/wavpack_plugin.c4
12 files changed, 25 insertions, 27 deletions
diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c
index c48f43da9..e658d77ea 100644
--- a/src/inputPlugins/_flac_common.c
+++ b/src/inputPlugins/_flac_common.c
@@ -165,7 +165,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
data->audio_format.bits = (mpd_sint8)si->bits_per_sample;
data->audio_format.sampleRate = si->sample_rate;
data->audio_format.channels = (mpd_sint8)si->channels;
- dc.totalTime = ((float)si->total_samples) / (si->sample_rate);
+ data->total_time = ((float)si->total_samples) / (si->sample_rate);
break;
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
flacParseReplayGain(block, data);
diff --git a/src/inputPlugins/_flac_common.h b/src/inputPlugins/_flac_common.h
index e87ae9307..21f710628 100644
--- a/src/inputPlugins/_flac_common.h
+++ b/src/inputPlugins/_flac_common.h
@@ -144,6 +144,7 @@ typedef struct {
float time;
unsigned int bitRate;
AudioFormat audio_format;
+ float total_time;
FLAC__uint64 position;
struct decoder *decoder;
InputStream *inStream;
diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c
index 4fa54c646..f2d15101d 100644
--- a/src/inputPlugins/aac_plugin.c
+++ b/src/inputPlugins/aac_plugin.c
@@ -338,8 +338,6 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
audio_format.bits = 16;
- dc.totalTime = totalTime;
-
file_time = 0.0;
advanceAacBuffer(&b, bread);
@@ -372,7 +370,8 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
if (dc.state != DECODE_STATE_DECODE) {
audio_format.channels = frameInfo.channels;
audio_format.sampleRate = sampleRate;
- decoder_initialized(mpd_decoder, &audio_format);
+ decoder_initialized(mpd_decoder, &audio_format,
+ totalTime);
}
advanceAacBuffer(&b, frameInfo.bytesconsumed);
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index f96ea2fca..a50061d2b 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -46,6 +46,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
AFfilehandle af_fp;
int bits;
AudioFormat audio_format;
+ float total_time;
mpd_uint16 bitRate;
struct stat st;
@@ -71,10 +72,9 @@ static int audiofile_decode(struct decoder * decoder, char *path)
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
- dc.totalTime =
- ((float)frame_count / (float)audio_format.sampleRate);
+ total_time = ((float)frame_count / (float)audio_format.sampleRate);
- bitRate = (mpd_uint16)(st.st_size * 8.0 / dc.totalTime / 1000.0 + 0.5);
+ bitRate = (mpd_uint16)(st.st_size * 8.0 / total_time / 1000.0 + 0.5);
if (audio_format.bits != 8 && audio_format.bits != 16) {
ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n",
@@ -85,7 +85,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
- decoder_initialized(decoder, &audio_format);
+ decoder_initialized(decoder, &audio_format, total_time);
{
int ret, eof = 0, current = 0;
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c
index f5d5469f7..f94e39d88 100644
--- a/src/inputPlugins/flac_plugin.c
+++ b/src/inputPlugins/flac_plugin.c
@@ -415,7 +415,7 @@ static int flac_decode_internal(struct decoder * decoder,
}
}
- decoder_initialized(decoder, &data.audio_format);
+ decoder_initialized(decoder, &data.audio_format, data.total_time);
while (1) {
if (!flac_process_single(flacDec))
diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c
index 4ab1338bf..179dc707c 100644
--- a/src/inputPlugins/mod_plugin.c
+++ b/src/inputPlugins/mod_plugin.c
@@ -176,7 +176,6 @@ static int mod_decode(struct decoder * decoder, char *path)
return -1;
}
- dc.totalTime = 0;
audio_format.bits = 16;
audio_format.sampleRate = 44100;
audio_format.channels = 2;
@@ -185,7 +184,7 @@ static int mod_decode(struct decoder * decoder, char *path)
1.0 / ((audio_format.bits * audio_format.channels / 8.0) *
(float)audio_format.sampleRate);
- decoder_initialized(decoder, &audio_format);
+ decoder_initialized(decoder, &audio_format, 0);
while (1) {
if (dc.command == DECODE_COMMAND_SEEK) {
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index a7f39a3a4..27d0fab2e 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -1035,8 +1035,6 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
initAudioFormatFromMp3DecodeData(&data, &audio_format);
- dc.totalTime = data.totalTime;
-
if (inStream->metaTitle) {
if (tag)
freeMpdTag(tag);
@@ -1062,7 +1060,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
freeMpdTag(tag);
}
- decoder_initialized(decoder, &audio_format);
+ decoder_initialized(decoder, &audio_format, data.totalTime);
while (mp3Read(&data, decoder, &replayGainInfo) != DECODE_BREAK) ;
/* send last little bit if not DECODE_COMMAND_STOP */
diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c
index d2c0f1b6c..ac681a073 100644
--- a/src/inputPlugins/mp4_plugin.c
+++ b/src/inputPlugins/mp4_plugin.c
@@ -83,7 +83,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
mp4ff_t *mp4fh;
mp4ff_callback_t *mp4cb;
int32_t track;
- float file_time;
+ float file_time, total_time;
int32_t scale;
faacDecHandle decoder;
faacDecFrameInfo frameInfo;
@@ -170,7 +170,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
free(mp4cb);
return -1;
}
- dc.totalTime = ((float)file_time) / scale;
+ total_time = ((float)file_time) / scale;
numSamples = mp4ff_num_samples(mp4fh, track);
@@ -248,7 +248,8 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
#endif
audio_format.sampleRate = scale;
audio_format.channels = frameInfo.channels;
- decoder_initialized(mpd_decoder, &audio_format);
+ decoder_initialized(mpd_decoder, &audio_format,
+ total_time);
}
if (channels * (unsigned long)(dur + offset) > frameInfo.samples) {
diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c
index 5a57ea4c8..399adf972 100644
--- a/src/inputPlugins/mpc_plugin.c
+++ b/src/inputPlugins/mpc_plugin.c
@@ -160,8 +160,6 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
return 0;
}
- dc.totalTime = mpc_streaminfo_get_length(&info);
-
audio_format.bits = 16;
audio_format.channels = info.channels;
audio_format.sampleRate = info.sample_freq;
@@ -172,7 +170,8 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
replayGainInfo->trackGain = info.gain_title * 0.01;
replayGainInfo->trackPeak = info.peak_title / 32767.0;
- decoder_initialized(mpd_decoder, &audio_format);
+ decoder_initialized(mpd_decoder, &audio_format,
+ mpc_streaminfo_get_length(&info));
while (!eof) {
if (dc.command == DECODE_COMMAND_SEEK) {
diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c
index 5879b7054..f8cb4c09a 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -345,7 +345,7 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
goto fail;
}
- decoder_initialized(mpd_decoder, &data.audio_format);
+ decoder_initialized(mpd_decoder, &data.audio_format, data.total_time);
while (1) {
OggFLAC__seekable_stream_decoder_process_single(decoder);
diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c
index 2fb0a9e52..e53e27de7 100644
--- a/src/inputPlugins/oggvorbis_plugin.c
+++ b/src/inputPlugins/oggvorbis_plugin.c
@@ -262,9 +262,6 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
}
return 0;
}
- dc.totalTime = ov_time_total(&vf, -1);
- if (dc.totalTime < 0)
- dc.totalTime = 0;
audio_format.bits = 16;
while (1) {
@@ -285,7 +282,11 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
audio_format.channels = vi->channels;
audio_format.sampleRate = vi->rate;
if (dc.state == DECODE_STATE_START) {
- decoder_initialized(decoder, &audio_format);
+ float total_time = ov_time_total(&vf, -1);
+ if (total_time < 0)
+ total_time = 0;
+ decoder_initialized(decoder, &audio_format,
+ total_time);
}
comments = ov_comment(&vf, -1)->user_comments;
putOggCommentsIntoOutputBuffer(inStream->metaName,
diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c
index 167278f01..a74da7e30 100644
--- a/src/inputPlugins/wavpack_plugin.c
+++ b/src/inputPlugins/wavpack_plugin.c
@@ -164,10 +164,10 @@ static void wavpack_decode(struct decoder * decoder,
samplesreq = sizeof(chunk) / (4 * audio_format.channels);
- dc.totalTime = (float)allsamples / audio_format.sampleRate;
dc.seekable = canseek;
- decoder_initialized(decoder, &audio_format);
+ decoder_initialized(decoder, &audio_format,
+ (float)allsamples / audio_format.sampleRate);
position = 0;