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.
This commit is contained in:
parent
154aa496e8
commit
2bf7ec4f39
@ -104,6 +104,7 @@ mpd_SOURCES = \
|
||||
conf.c \
|
||||
dbUtils.c \
|
||||
decode.c \
|
||||
decoder_api.c \
|
||||
directory.c \
|
||||
inputPlugin.c \
|
||||
inputStream.c \
|
||||
|
31
src/decoder_api.c
Normal file
31
src/decoder_api.c
Normal file
@ -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);
|
||||
}
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user