From 2bf7ec4f3935c68e6d129ffac17820411b3ea44d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 26 Aug 2008 08:27:04 +0200 Subject: added decoder_initialized() decoder_initialized() sets the state to DECODE_STATE_DECODE and wakes up the player thread. It is called by the decoder plugin after its internal initialization is finished. More arguments will be added later to prevent direct accesses to the DecoderControl struct. --- src/inputPlugins/_flac_common.h | 2 +- src/inputPlugins/aac_plugin.c | 6 +++--- src/inputPlugins/audiofile_plugin.c | 6 +++--- src/inputPlugins/flac_plugin.c | 2 +- src/inputPlugins/mod_plugin.c | 6 +++--- src/inputPlugins/mp3_plugin.c | 7 +++---- src/inputPlugins/mp4_plugin.c | 7 +++---- src/inputPlugins/mpc_plugin.c | 7 +++---- src/inputPlugins/oggflac_plugin.c | 2 +- src/inputPlugins/oggvorbis_plugin.c | 7 +++---- src/inputPlugins/wavpack_plugin.c | 7 ++++--- 11 files changed, 28 insertions(+), 31 deletions(-) (limited to 'src/inputPlugins') diff --git a/src/inputPlugins/_flac_common.h b/src/inputPlugins/_flac_common.h index 0437a416d..2d59f4d9d 100644 --- a/src/inputPlugins/_flac_common.h +++ b/src/inputPlugins/_flac_common.h @@ -22,7 +22,7 @@ #ifndef _FLAC_COMMON_H #define _FLAC_COMMON_H -#include "../inputPlugin.h" +#include "../decoder_api.h" #if defined(HAVE_FLAC) || defined(HAVE_OGGFLAC) diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c index 4f1818478..d03826c8f 100644 --- a/src/inputPlugins/aac_plugin.c +++ b/src/inputPlugins/aac_plugin.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../inputPlugin.h" +#include "../decoder_api.h" #ifdef HAVE_FAAD @@ -278,7 +278,7 @@ static int getAacTotalTime(char *file) return file_time; } -static int aac_decode(mpd_unused struct decoder * mpd_decoder, char *path) +static int aac_decode(struct decoder * mpd_decoder, char *path) { float file_time; float totalTime; @@ -373,7 +373,7 @@ static int aac_decode(mpd_unused struct decoder * mpd_decoder, char *path) dc.audioFormat.sampleRate = sampleRate; getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat)); - dc.state = DECODE_STATE_DECODE; + decoder_initialized(mpd_decoder); } advanceAacBuffer(&b, frameInfo.bytesconsumed); diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c index 0cc357135..faa58fe64 100644 --- a/src/inputPlugins/audiofile_plugin.c +++ b/src/inputPlugins/audiofile_plugin.c @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../inputPlugin.h" +#include "../decoder_api.h" #ifdef HAVE_AUDIOFILE @@ -40,7 +40,7 @@ static int getAudiofileTotalTime(char *file) return total_time; } -static int audiofile_decode(mpd_unused struct decoder * decoder, char *path) +static int audiofile_decode(struct decoder * decoder, char *path) { int fs, frame_count; AFfilehandle af_fp; @@ -85,7 +85,7 @@ static int audiofile_decode(mpd_unused struct decoder * decoder, char *path) fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1); - dc.state = DECODE_STATE_DECODE; + decoder_initialized(decoder); { int ret, eof = 0, current = 0; char chunk[CHUNK_SIZE]; diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 7c4b8e356..43be1a2b9 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, } } - dc.state = DECODE_STATE_DECODE; + decoder_initialized(decoder); while (1) { if (!flac_process_single(flacDec)) diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c index a041f1e34..c09803ee4 100644 --- a/src/inputPlugins/mod_plugin.c +++ b/src/inputPlugins/mod_plugin.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../inputPlugin.h" +#include "../decoder_api.h" #ifdef HAVE_MIKMOD @@ -159,7 +159,7 @@ static void mod_close(mod_Data * data) free(data); } -static int mod_decode(mpd_unused struct decoder * decoder, char *path) +static int mod_decode(struct decoder * decoder, char *path) { mod_Data *data; float total_time = 0.0; @@ -185,7 +185,7 @@ static int mod_decode(mpd_unused struct decoder * decoder, char *path) 1.0 / ((dc.audioFormat.bits * dc.audioFormat.channels / 8.0) * (float)dc.audioFormat.sampleRate); - dc.state = DECODE_STATE_DECODE; + decoder_initialized(decoder); while (1) { if (dc.command == DECODE_COMMAND_SEEK) { dc.seekError = 1; diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index e68452470..f91895358 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../inputPlugin.h" +#include "../decoder_api.h" #ifdef HAVE_MAD @@ -1015,8 +1015,7 @@ static void initAudioFormatFromMp3DecodeData(mp3DecodeData * data, af->channels = MAD_NCHANNELS(&(data->frame).header); } -static int mp3_decode(mpd_unused struct decoder * decoder, - InputStream * inStream) +static int mp3_decode(struct decoder * decoder, InputStream * inStream) { mp3DecodeData data; MpdTag *tag = NULL; @@ -1062,7 +1061,7 @@ static int mp3_decode(mpd_unused struct decoder * decoder, freeMpdTag(tag); } - dc.state = DECODE_STATE_DECODE; + decoder_initialized(decoder); while (mp3Read(&data, &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 e715b3983..de658511f 100644 --- a/src/inputPlugins/mp4_plugin.c +++ b/src/inputPlugins/mp4_plugin.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../inputPlugin.h" +#include "../decoder_api.h" #ifdef HAVE_FAAD @@ -78,8 +78,7 @@ static uint32_t mp4_inputStreamSeekCallback(void *inStream, uint64_t position) return seekInputStream((InputStream *) inStream, position, SEEK_SET); } -static int mp4_decode(mpd_unused struct decoder * mpd_decoder, - InputStream * inStream) +static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream) { mp4ff_t *mp4fh; mp4ff_callback_t *mp4cb; @@ -250,7 +249,7 @@ static int mp4_decode(mpd_unused struct decoder * mpd_decoder, dc.audioFormat.channels = frameInfo.channels; getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat)); - dc.state = DECODE_STATE_DECODE; + decoder_initialized(mpd_decoder); } if (channels * (unsigned long)(dur + offset) > frameInfo.samples) { diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c index f69e9eddb..d4ee40f93 100644 --- a/src/inputPlugins/mpc_plugin.c +++ b/src/inputPlugins/mpc_plugin.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../inputPlugin.h" +#include "../decoder_api.h" #ifdef HAVE_MPCDEC @@ -106,8 +106,7 @@ static inline mpd_sint16 convertSample(MPC_SAMPLE_FORMAT sample) return val; } -static int mpc_decode(mpd_unused struct decoder * mpd_decoder, - InputStream * inStream) +static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream) { mpc_decoder decoder; mpc_reader reader; @@ -174,7 +173,7 @@ static int mpc_decode(mpd_unused struct decoder * mpd_decoder, replayGainInfo->trackGain = info.gain_title * 0.01; replayGainInfo->trackPeak = info.peak_title / 32767.0; - dc.state = DECODE_STATE_DECODE; + decoder_initialized(mpd_decoder); while (!eof) { if (dc.command == DECODE_COMMAND_SEEK) { diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c index a365f73cc..91b4de435 100644 --- a/src/inputPlugins/oggflac_plugin.c +++ b/src/inputPlugins/oggflac_plugin.c @@ -346,7 +346,7 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream) goto fail; } - dc.state = DECODE_STATE_DECODE; + decoder_initialized(mpd_decoder); while (1) { OggFLAC__seekable_stream_decoder_process_single(decoder); diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c index cb0c5a948..0867de69d 100644 --- a/src/inputPlugins/oggvorbis_plugin.c +++ b/src/inputPlugins/oggvorbis_plugin.c @@ -18,7 +18,7 @@ /* TODO 'ogg' should probably be replaced with 'oggvorbis' in all instances */ -#include "../inputPlugin.h" +#include "../decoder_api.h" #ifdef HAVE_OGGVORBIS @@ -210,8 +210,7 @@ static void putOggCommentsIntoOutputBuffer(char *streamName, } /* public */ -static int oggvorbis_decode(mpd_unused struct decoder * decoder, - InputStream * inStream) +static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream) { OggVorbis_File vf; ov_callbacks callbacks; @@ -287,7 +286,7 @@ static int oggvorbis_decode(mpd_unused struct decoder * decoder, if (dc.state == DECODE_STATE_START) { getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat)); - dc.state = DECODE_STATE_DECODE; + decoder_initialized(decoder); } 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 99491a232..cd832fdc4 100644 --- a/src/inputPlugins/wavpack_plugin.c +++ b/src/inputPlugins/wavpack_plugin.c @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../inputPlugin.h" +#include "../decoder_api.h" #ifdef HAVE_WAVPACK @@ -124,7 +124,7 @@ static void format_samples_float(mpd_unused int Bps, void *buffer, * This does the main decoding thing. * Requires an already opened WavpackContext. */ -static void wavpack_decode(mpd_unused struct decoder * decoder, +static void wavpack_decode(struct decoder * decoder, WavpackContext *wpc, int canseek, ReplayGainInfo *replayGainInfo) { @@ -166,9 +166,10 @@ static void wavpack_decode(mpd_unused struct decoder * decoder, getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat)); dc.totalTime = (float)allsamples / dc.audioFormat.sampleRate; - dc.state = DECODE_STATE_DECODE; dc.seekable = canseek; + decoder_initialized(decoder); + position = 0; do { -- cgit v1.2.3