Commit f83d1aa4 authored by J. Alexander Treuman's avatar J. Alexander Treuman

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
parent ac5a7c2d
...@@ -120,7 +120,8 @@ static void format_samples_float(int Bps, void *buffer, uint32_t samcnt) ...@@ -120,7 +120,8 @@ static void format_samples_float(int Bps, void *buffer, uint32_t samcnt)
* Requires an already opened WavpackContext. * Requires an already opened WavpackContext.
*/ */
static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc, 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); void (*format_samples)(int Bps, void *buffer, uint32_t samcnt);
char chunk[CHUNK_SIZE]; char chunk[CHUNK_SIZE];
...@@ -195,7 +196,7 @@ static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc, ...@@ -195,7 +196,7 @@ static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc,
sendDataToOutputBuffer(cb, NULL, dc, 0, chunk, sendDataToOutputBuffer(cb, NULL, dc, 0, chunk,
samplesgot * outsamplesize, samplesgot * outsamplesize,
time, bitrate, NULL); time, bitrate, replayGainInfo);
} }
} while (samplesgot == samplesreq); } while (samplesgot == samplesreq);
...@@ -206,6 +207,73 @@ static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc, ...@@ -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. * Reads metainfo from the specified file.
*/ */
static MpdTag *wavpack_tagdup(char *fname) static MpdTag *wavpack_tagdup(char *fname)
...@@ -367,7 +435,7 @@ static int wavpack_streamdecode(OutputBuffer *cb, DecoderControl *dc, ...@@ -367,7 +435,7 @@ static int wavpack_streamdecode(OutputBuffer *cb, DecoderControl *dc,
return -1; return -1;
} }
wavpack_decode(cb, dc, wpc, can_seek(is)); wavpack_decode(cb, dc, wpc, can_seek(is), NULL);
WavpackCloseFile(wpc); WavpackCloseFile(wpc);
closeInputStream(is); /* calling side doesn't do this in mpd 0.13.0 */ 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) ...@@ -383,6 +451,7 @@ static int wavpack_filedecode(OutputBuffer *cb, DecoderControl *dc, char *fname)
{ {
char error[ERRORLEN]; char error[ERRORLEN];
WavpackContext *wpc; WavpackContext *wpc;
ReplayGainInfo *replayGainInfo;
wpc = WavpackOpenFileInput(fname, error, wpc = WavpackOpenFileInput(fname, error,
OPEN_WVC | OPEN_2CH_MAX | OPEN_NORMALIZE, OPEN_WVC | OPEN_2CH_MAX | OPEN_NORMALIZE,
...@@ -392,7 +461,18 @@ static int wavpack_filedecode(OutputBuffer *cb, DecoderControl *dc, char *fname) ...@@ -392,7 +461,18 @@ static int wavpack_filedecode(OutputBuffer *cb, DecoderControl *dc, char *fname)
return -1; 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); WavpackCloseFile(wpc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment