aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-08-26 04:22:58 -0700
committerEric Wong <normalperson@yhbt.net>2008-08-26 04:26:48 -0700
commit9cb6d62a0302d8e49b2225b97602379db7566b5e (patch)
tree0ae4fc4a8376c4f6e78dfebae0724c78e346f9a9 /src/inputPlugins
parent4be65a911b6024dc924d1e7d016cab8c42179f71 (diff)
downloadmpd-9cb6d62a0302d8e49b2225b97602379db7566b5e.tar.gz
mpd-9cb6d62a0302d8e49b2225b97602379db7566b5e.tar.xz
mpd-9cb6d62a0302d8e49b2225b97602379db7566b5e.zip
Reimplement dynamic metadata handling
This has been tested for both playback of streams and outputting to streams, and seems to work fine with minimal locking. This reuses the sequence number infrastructure in OutputBuffer for synchronizing metadata payloads; so (IMNSHO) should be much more understandable than various flags being set here and there.. It could still use some cleanup and much testing, but synchronization issues should be minimal.
Diffstat (limited to 'src/inputPlugins')
-rw-r--r--src/inputPlugins/mp3_plugin.c7
-rw-r--r--src/inputPlugins/oggvorbis_plugin.c16
2 files changed, 14 insertions, 9 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 5bbd7601f..c36cab6f0 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -921,7 +921,7 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
data->inStream->metaTitle);
free(data->inStream->metaTitle);
data->inStream->metaTitle = NULL;
- freeMpdTag(tag);
+ metadata_pipe_send(tag, data->elapsedTime);
}
samplesLeft = (data->synth).pcm.length;
@@ -1050,20 +1050,19 @@ static int mp3_decode(InputStream * inStream)
if (inStream->metaName) {
addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
}
- freeMpdTag(tag);
} else if (tag) {
if (inStream->metaName) {
clearItemsFromMpdTag(tag, TAG_ITEM_NAME);
addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
}
- freeMpdTag(tag);
} else if (inStream->metaName) {
tag = newMpdTag();
if (inStream->metaName) {
addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
}
- freeMpdTag(tag);
}
+ if (tag)
+ metadata_pipe_send(tag, 0);
while (mp3Read(&data, &replayGainInfo) != DECODE_BREAK) ;
/* send last little bit if not dc_intr() */
diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c
index fcedda54a..cb6eed28e 100644
--- a/src/inputPlugins/oggvorbis_plugin.c
+++ b/src/inputPlugins/oggvorbis_plugin.c
@@ -196,7 +196,8 @@ static MpdTag *oggCommentsParse(char **comments)
}
static void putOggCommentsIntoOutputBuffer(char *streamName,
- char **comments)
+ char **comments,
+ float time)
{
MpdTag *tag;
@@ -212,7 +213,12 @@ static void putOggCommentsIntoOutputBuffer(char *streamName,
addItemToMpdTag(tag, TAG_ITEM_NAME, streamName);
}
- freeMpdTag(tag);
+ metadata_pipe_send(tag, time);
+}
+
+static float current_time(OggVorbis_File *vf)
+{
+ return (ov_pcm_tell(vf) / dc.audio_format.sampleRate);
}
/* public */
@@ -291,7 +297,8 @@ static int oggvorbis_decode(InputStream * inStream)
dc.audio_format.sampleRate = vi->rate;
comments = ov_comment(&vf, -1)->user_comments;
putOggCommentsIntoOutputBuffer(inStream->metaName,
- comments);
+ comments,
+ current_time(&vf));
ogg_getReplayGainInfo(comments, &replayGainInfo);
}
@@ -310,8 +317,7 @@ static int oggvorbis_decode(InputStream * inStream)
if ((test = ov_bitrate_instant(&vf)) > 0) {
bitRate = test / 1000;
}
- ob_send(chunk, chunkpos,
- ov_pcm_tell(&vf) / dc.audio_format.sampleRate,
+ ob_send(chunk, chunkpos, current_time(&vf),
bitRate, replayGainInfo);
chunkpos = 0;
if (dc_intr())