aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/mpc_plugin.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2005-03-07 00:51:21 +0000
committerWarren Dukes <warren.dukes@gmail.com>2005-03-07 00:51:21 +0000
commit01b708bc13d082079beb794a11e138b2ad890f83 (patch)
treee7453f51cb04a6fb685757cbed574bc8455e99af /src/inputPlugins/mpc_plugin.c
parent32a1f952e85d5c8f2f2c19dffecc05b4ee8364b2 (diff)
downloadmpd-01b708bc13d082079beb794a11e138b2ad890f83.tar.gz
mpd-01b708bc13d082079beb794a11e138b2ad890f83.tar.xz
mpd-01b708bc13d082079beb794a11e138b2ad890f83.zip
add support for parsing ape tags in musepack files
git-svn-id: https://svn.musicpd.org/mpd/trunk@3030 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/inputPlugins/mpc_plugin.c')
-rw-r--r--src/inputPlugins/mpc_plugin.c47
1 files changed, 40 insertions, 7 deletions
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;
}