aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ. Alexander Treuman <jat@spatialrift.net>2007-06-25 13:37:21 +0000
committerJ. Alexander Treuman <jat@spatialrift.net>2007-06-25 13:37:21 +0000
commitf83d1aa460a67ed92119eebbe712b16839a07077 (patch)
tree8efbf7eebb051ac53a30652ab018586888fdb720 /src
parentac5a7c2d828420445f03d23d15c899d6e4d126ec (diff)
downloadmpd-f83d1aa460a67ed92119eebbe712b16839a07077.tar.gz
mpd-f83d1aa460a67ed92119eebbe712b16839a07077.tar.xz
mpd-f83d1aa460a67ed92119eebbe712b16839a07077.zip
inputPlugins/wavpack_plugin: adding dummy code for ReplayGain support
This ReplayGain code is currently disabled because WavpackGetTagItem can't seem to find replaygain_* fields in APEv2 tags (which is how wvgain stores ReplayGain values). Additionally, because APEv2 tags are stored at the end of the file, this code is only implemented for regular files and not HTTP streams. Using HTTP seeking it *may* be possible to implement it for both. git-svn-id: https://svn.musicpd.org/mpd/trunk@6656 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/inputPlugins/wavpack_plugin.c88
1 files changed, 84 insertions, 4 deletions
diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c
index be7a6fa5a..7c50466b7 100644
--- a/src/inputPlugins/wavpack_plugin.c
+++ b/src/inputPlugins/wavpack_plugin.c
@@ -120,7 +120,8 @@ static void format_samples_float(int Bps, void *buffer, uint32_t samcnt)
* Requires an already opened WavpackContext.
*/
static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc,
- WavpackContext *wpc, int canseek)
+ WavpackContext *wpc, int canseek,
+ ReplayGainInfo *replayGainInfo)
{
void (*format_samples)(int Bps, void *buffer, uint32_t samcnt);
char chunk[CHUNK_SIZE];
@@ -195,7 +196,7 @@ static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc,
sendDataToOutputBuffer(cb, NULL, dc, 0, chunk,
samplesgot * outsamplesize,
- time, bitrate, NULL);
+ time, bitrate, replayGainInfo);
}
} while (samplesgot == samplesreq);
@@ -206,6 +207,73 @@ static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc,
}
/*
+ * These functions aren't currently used, which just results in warnings.
+ */
+#if 0
+static char *wavpack_tag(WavpackContext *wpc, char *key)
+{
+ char *value = NULL;
+ int size;
+
+ size = WavpackGetTagItem(wpc, key, NULL, 0);
+ if (size > 0) {
+ size++;
+ value = xmalloc(size);
+ if (!value)
+ return NULL;
+ WavpackGetTagItem(wpc, key, value, size);
+ }
+
+ return value;
+}
+
+static ReplayGainInfo *wavpack_replaygain(WavpackContext *wpc)
+{
+ ReplayGainInfo *replayGainInfo;
+ int found = 0;
+ char *value;
+
+ replayGainInfo = newReplayGainInfo();
+
+ value = wavpack_tag(wpc, "replaygain_track_gain");
+ if (value) {
+ replayGainInfo->trackGain = atof(value);
+ free(value);
+ found = 1;
+ }
+
+ value = wavpack_tag(wpc, "replaygain_album_gain");
+ if (value) {
+ replayGainInfo->albumGain = atof(value);
+ free(value);
+ found = 1;
+ }
+
+ value = wavpack_tag(wpc, "replaygain_track_peak");
+ if (value) {
+ replayGainInfo->trackPeak = atof(value);
+ free(value);
+ found = 1;
+ }
+
+ value = wavpack_tag(wpc, "replaygain_album_peak");
+ if (value) {
+ replayGainInfo->albumPeak = atof(value);
+ free(value);
+ found = 1;
+ }
+
+
+ if (found)
+ return replayGainInfo;
+
+ freeReplayGainInfo(replayGainInfo);
+
+ return NULL;
+}
+#endif
+
+/*
* Reads metainfo from the specified file.
*/
static MpdTag *wavpack_tagdup(char *fname)
@@ -367,7 +435,7 @@ static int wavpack_streamdecode(OutputBuffer *cb, DecoderControl *dc,
return -1;
}
- wavpack_decode(cb, dc, wpc, can_seek(is));
+ wavpack_decode(cb, dc, wpc, can_seek(is), NULL);
WavpackCloseFile(wpc);
closeInputStream(is); /* calling side doesn't do this in mpd 0.13.0 */
@@ -383,6 +451,7 @@ static int wavpack_filedecode(OutputBuffer *cb, DecoderControl *dc, char *fname)
{
char error[ERRORLEN];
WavpackContext *wpc;
+ ReplayGainInfo *replayGainInfo;
wpc = WavpackOpenFileInput(fname, error,
OPEN_WVC | OPEN_2CH_MAX | OPEN_NORMALIZE,
@@ -392,7 +461,18 @@ static int wavpack_filedecode(OutputBuffer *cb, DecoderControl *dc, char *fname)
return -1;
}
- wavpack_decode(cb, dc, wpc, 1);
+ /*
+ * ReplayGain support is currently disabled, because WavpackGetTagItem
+ * can't seem to find the replaygain_* fields in APEv2 tags.
+ */
+
+ /* replayGainInfo = wavpack_replaygain(wpc); */
+ replayGainInfo = NULL;
+
+ wavpack_decode(cb, dc, wpc, 1, replayGainInfo);
+
+ if (replayGainInfo)
+ freeReplayGainInfo(replayGainInfo);
WavpackCloseFile(wpc);