diff options
author | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:04 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:04 +0200 |
commit | 2bf7ec4f3935c68e6d129ffac17820411b3ea44d (patch) | |
tree | 8689514b06b6e9220def40fc1a82ead33dd17455 | |
parent | 154aa496e8c18bba3dc10c607987c187f4686ae4 (diff) | |
download | mpd-2bf7ec4f3935c68e6d129ffac17820411b3ea44d.tar.gz mpd-2bf7ec4f3935c68e6d129ffac17820411b3ea44d.tar.xz mpd-2bf7ec4f3935c68e6d129ffac17820411b3ea44d.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/decoder_api.c | 31 | ||||
-rw-r--r-- | src/decoder_api.h | 6 | ||||
-rw-r--r-- | src/inputPlugins/_flac_common.h | 2 | ||||
-rw-r--r-- | src/inputPlugins/aac_plugin.c | 6 | ||||
-rw-r--r-- | src/inputPlugins/audiofile_plugin.c | 6 | ||||
-rw-r--r-- | src/inputPlugins/flac_plugin.c | 2 | ||||
-rw-r--r-- | src/inputPlugins/mod_plugin.c | 6 | ||||
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 7 | ||||
-rw-r--r-- | src/inputPlugins/mp4_plugin.c | 7 | ||||
-rw-r--r-- | src/inputPlugins/mpc_plugin.c | 7 | ||||
-rw-r--r-- | src/inputPlugins/oggflac_plugin.c | 2 | ||||
-rw-r--r-- | src/inputPlugins/oggvorbis_plugin.c | 7 | ||||
-rw-r--r-- | src/inputPlugins/wavpack_plugin.c | 7 |
14 files changed, 66 insertions, 31 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 4a4196499..5d5375f0c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,6 +104,7 @@ mpd_SOURCES = \ conf.c \ dbUtils.c \ decode.c \ + decoder_api.c \ directory.c \ inputPlugin.c \ inputStream.c \ diff --git a/src/decoder_api.c b/src/decoder_api.c new file mode 100644 index 000000000..dfd1850b5 --- /dev/null +++ b/src/decoder_api.c @@ -0,0 +1,31 @@ +/* the Music Player Daemon (MPD) + * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com) + * Copyright (C) 2008 Max Kellermann <max@duempel.org> + * This project's homepage is: http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "decoder_api.h" + +#include "playerData.h" +#include "gcc.h" + +void decoder_initialized(mpd_unused struct decoder * decoder) +{ + assert(dc.state == DECODE_STATE_START); + + dc.state = DECODE_STATE_DECODE; + notify_signal(&pc.notify); +} diff --git a/src/decoder_api.h b/src/decoder_api.h index f4e0c13b9..c9ab3ebbb 100644 --- a/src/decoder_api.h +++ b/src/decoder_api.h @@ -34,4 +34,10 @@ */ struct decoder; +/** + * Notify the player thread that it has finished initialization and + * that it has read the song's meta data. + */ +void decoder_initialized(struct decoder * decoder); + #endif 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 { |