finish adding AliasMrJones replayGain stuff
git-svn-id: https://svn.musicpd.org/mpd/trunk@953 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
04fdc209d9
commit
822be0375e
16
TODO
16
TODO
|
@ -10,9 +10,7 @@ common function and abstrct dealing with DecoderControl * and put
|
||||||
cycleLogFiles in there, so we cycleLogFiles while decoding, not just when
|
cycleLogFiles in there, so we cycleLogFiles while decoding, not just when
|
||||||
decoding has stopped.
|
decoding has stopped.
|
||||||
|
|
||||||
3) reaplygain
|
3) streaming and playing in general
|
||||||
|
|
||||||
4) streaming and playing in general
|
|
||||||
a) determine a clever interface to play, so that play doesn't block
|
a) determine a clever interface to play, so that play doesn't block
|
||||||
until the file is opened, but just returns when the command
|
until the file is opened, but just returns when the command
|
||||||
is accepted.
|
is accepted.
|
||||||
|
@ -21,17 +19,19 @@ decoding has stopped.
|
||||||
c) this will help streaming from blocking indefinetly or waiting
|
c) this will help streaming from blocking indefinetly or waiting
|
||||||
on a response
|
on a response
|
||||||
|
|
||||||
5) play streams
|
4) play streams
|
||||||
|
|
||||||
6) ACK error codes
|
5) ACK error codes
|
||||||
|
|
||||||
7) cleanup main()
|
6) cleanup main()
|
||||||
|
|
||||||
8) handle '\n' in filenames
|
7) handle '\n' in filenames
|
||||||
|
|
||||||
9) allow "add" command to load playlists, then depricate "load" command, this
|
8) allow "add" command to load playlists, then depricate "load" command, this
|
||||||
will be benneficial for adding m3u url's
|
will be benneficial for adding m3u url's
|
||||||
|
|
||||||
|
9) compute average replaygain to use for non-replaygain songs
|
||||||
|
|
||||||
|
|
||||||
Post-1.0
|
Post-1.0
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "volume.h"
|
#include "volume.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "permission.h"
|
#include "permission.h"
|
||||||
|
#include "replayGain.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -322,6 +323,7 @@ int main(int argc, char * argv[]) {
|
||||||
|
|
||||||
initPaths(options.playlistDirArg,options.musicDirArg);
|
initPaths(options.playlistDirArg,options.musicDirArg);
|
||||||
initPermissions();
|
initPermissions();
|
||||||
|
initReplayGainState();
|
||||||
|
|
||||||
initTables();
|
initTables();
|
||||||
initPlaylist();
|
initPlaylist();
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "pcm_utils.h"
|
#include "pcm_utils.h"
|
||||||
#include "inputStream.h"
|
#include "inputStream.h"
|
||||||
#include "outputBuffer.h"
|
#include "outputBuffer.h"
|
||||||
|
#include "replayGain.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -83,12 +84,71 @@ long ogg_tell_cb(void * inStream) {
|
||||||
return ((InputStream *)inStream)->offset;
|
return ((InputStream *)inStream)->offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char * ogg_parseComment(char * comment, char * needle) {
|
||||||
|
int len = strlen(needle);
|
||||||
|
|
||||||
|
if(strncasecmp(comment,needle,len)) return comment+len;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
float ogg_getReplayGainScale(char ** comments) {
|
||||||
|
int trackGainFound = 0;
|
||||||
|
int albumGainFound = 0;
|
||||||
|
float trackGain = 1.0;
|
||||||
|
float albumGain = 1.0;
|
||||||
|
float trackPeak = 0.0;
|
||||||
|
float albumPeak = 0.0;
|
||||||
|
char * temp;
|
||||||
|
int replayGainState = getReplayGainState();
|
||||||
|
|
||||||
|
if(replayGainState == REPLAYGAIN_OFF) return 1.0;
|
||||||
|
|
||||||
|
while(*comments) {
|
||||||
|
if((temp = ogg_parseComment(*comments,"replaygain_track_gain")))
|
||||||
|
{
|
||||||
|
trackGain = atof(temp);
|
||||||
|
trackGainFound = 1;
|
||||||
|
}
|
||||||
|
else if((temp = ogg_parseComment(*comments,
|
||||||
|
"replaygain_album_gain")))
|
||||||
|
{
|
||||||
|
albumGain = atof(temp);
|
||||||
|
albumGainFound = 1;
|
||||||
|
}
|
||||||
|
else if((temp = ogg_parseComment(*comments,
|
||||||
|
"replaygain_track_peak")))
|
||||||
|
{
|
||||||
|
trackPeak = atof(temp);
|
||||||
|
}
|
||||||
|
else if((temp = ogg_parseComment(*comments,
|
||||||
|
"replaygain_album_peak")))
|
||||||
|
{
|
||||||
|
albumPeak = atof(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
comments++;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(replayGainState) {
|
||||||
|
case REPLAYGAIN_ALBUM:
|
||||||
|
if(albumGainFound) {
|
||||||
|
return computeReplayGainScale(albumGain,albumPeak);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return computeReplayGainScale(trackGain,trackPeak);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
int ogg_decode(OutputBuffer * cb, AudioFormat * af, DecoderControl * dc)
|
int ogg_decode(OutputBuffer * cb, AudioFormat * af, DecoderControl * dc)
|
||||||
{
|
{
|
||||||
OggVorbis_File vf;
|
OggVorbis_File vf;
|
||||||
ov_callbacks callbacks;
|
ov_callbacks callbacks;
|
||||||
InputStream inStream;
|
InputStream inStream;
|
||||||
|
|
||||||
|
|
||||||
callbacks.read_func = ogg_read_cb;
|
callbacks.read_func = ogg_read_cb;
|
||||||
callbacks.seek_func = ogg_seek_cb;
|
callbacks.seek_func = ogg_seek_cb;
|
||||||
callbacks.close_func = ogg_close_cb;
|
callbacks.close_func = ogg_close_cb;
|
||||||
|
@ -124,6 +184,8 @@ int ogg_decode(OutputBuffer * cb, AudioFormat * af, DecoderControl * dc)
|
||||||
int chunkpos = 0;
|
int chunkpos = 0;
|
||||||
long bitRate = 0;
|
long bitRate = 0;
|
||||||
long test;
|
long test;
|
||||||
|
float replayGainScale = ogg_getReplayGainScale(
|
||||||
|
ov_comment(&vf,-1)->user_comments);
|
||||||
|
|
||||||
while(!eof) {
|
while(!eof) {
|
||||||
if(dc->seek) {
|
if(dc->seek) {
|
||||||
|
@ -141,6 +203,7 @@ int ogg_decode(OutputBuffer * cb, AudioFormat * af, DecoderControl * dc)
|
||||||
if((test = ov_bitrate_instant(&vf))>0) {
|
if((test = ov_bitrate_instant(&vf))>0) {
|
||||||
bitRate = test/1000;
|
bitRate = test/1000;
|
||||||
}
|
}
|
||||||
|
doReplayGain(chunk,ret,af,replayGainScale);
|
||||||
sendDataToOutputBuffer(cb,dc,chunk,ret,
|
sendDataToOutputBuffer(cb,dc,chunk,ret,
|
||||||
ov_time_tell(&vf),bitRate);
|
ov_time_tell(&vf),bitRate);
|
||||||
if(dc->stop) break;
|
if(dc->stop) break;
|
||||||
|
|
Loading…
Reference in New Issue