From 01b708bc13d082079beb794a11e138b2ad890f83 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Mon, 7 Mar 2005 00:51:21 +0000 Subject: add support for parsing ape tags in musepack files git-svn-id: https://svn.musicpd.org/mpd/trunk@3030 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/inputPlugins/mpc_plugin.c | 47 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'src/inputPlugins') diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c index 45ef0bd16..9687eba6c 100644 --- a/src/inputPlugins/mpc_plugin.c +++ b/src/inputPlugins/mpc_plugin.c @@ -47,7 +47,7 @@ static mpc_int32_t mpc_read_cb(void * vdata, void * ptr, mpc_int32_t size) { while(1) { ret = readFromInputStream(data->inStream, ptr, 1, size); if(ret == 0 && !inputStreamAtEOF(data->inStream) && - !data->dc->stop) + (data->dc && !data->dc->stop)) { my_usleep(10000); } @@ -272,17 +272,50 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc, return 0; } +static float mpcGetTime(char * file) { + InputStream inStream; + float time = -1; + + mpc_reader reader; + mpc_streaminfo info; + MpcCallbackData data; + + data.inStream = &inStream; + data.dc = NULL; + + reader.read = mpc_read_cb; + reader.seek = mpc_seek_cb; + reader.tell = mpc_tell_cb; + reader.get_size = mpc_getsize_cb; + reader.canseek = mpc_canseek_cb; + reader.data = &data; + + mpc_streaminfo_init(&info); + + if(openInputStream(&inStream, file) < 0) return -1; + + if(mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) { + closeInputStream(&inStream); + return -1; + } + + time = mpc_streaminfo_get_length(&info); + + closeInputStream(&inStream); + + return time; +} + static MpdTag * mpcTagDup(char * file) { MpdTag * ret = NULL; - FILE * fp; - - fp = fopen(file,"r"); - if(!fp) return NULL; + float time = mpcGetTime(file); - /* get tag info here */ + if(time < 0) return NULL; + ret = apeDup(file); + if(!ret) ret = id3Dup(file); if(!ret) ret = newMpdTag(); - ret->time = 0; + ret->time = time; return ret; } -- cgit v1.2.3