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

Added gapless_mp3_playback option. Setting to "no" will disable gapless

MP3 playback, thus allowing songs that run longer than the Xing frame claims (f.e., an MP3 created by catting two MP3s together) to continue playing past the end. git-svn-id: https://svn.musicpd.org/mpd/trunk@5157 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent d4be2276
...@@ -173,6 +173,7 @@ void initConf(void) ...@@ -173,6 +173,7 @@ void initConf(void)
registerConfigParam(CONF_ID3V1_ENCODING, 0, 0); registerConfigParam(CONF_ID3V1_ENCODING, 0, 0);
registerConfigParam(CONF_METADATA_TO_USE, 0, 0); registerConfigParam(CONF_METADATA_TO_USE, 0, 0);
registerConfigParam(CONF_SAVE_ABSOLUTE_PATHS, 0, 0); registerConfigParam(CONF_SAVE_ABSOLUTE_PATHS, 0, 0);
registerConfigParam(CONF_GAPLESS_MP3_PLAYBACK, 0, 0);
} }
static void addBlockParam(ConfigParam * param, char *name, char *value, static void addBlockParam(ConfigParam * param, char *name, char *value,
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#define CONF_ID3V1_ENCODING "id3v1_encoding" #define CONF_ID3V1_ENCODING "id3v1_encoding"
#define CONF_METADATA_TO_USE "metadata_to_use" #define CONF_METADATA_TO_USE "metadata_to_use"
#define CONF_SAVE_ABSOLUTE_PATHS "save_absolute_paths_in_playlists" #define CONF_SAVE_ABSOLUTE_PATHS "save_absolute_paths_in_playlists"
#define CONF_GAPLESS_MP3_PLAYBACK "gapless_mp3_playback"
typedef struct _BlockParam { typedef struct _BlockParam {
char *name; char *name;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "../utils.h" #include "../utils.h"
#include "../replayGain.h" #include "../replayGain.h"
#include "../tag.h" #include "../tag.h"
#include "../conf.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -55,6 +56,10 @@ ...@@ -55,6 +56,10 @@
/* the number of samples of silence the decoder inserts at start */ /* the number of samples of silence the decoder inserts at start */
#define DECODERDELAY 529 #define DECODERDELAY 529
#define DEFAULT_GAPLESS_MP3_PLAYBACK 1
static int gaplessPlayback;
/* this is stolen from mpg321! */ /* this is stolen from mpg321! */
struct audio_dither { struct audio_dither {
mad_fixed_t error[3]; mad_fixed_t error[3];
...@@ -113,6 +118,14 @@ static signed long audio_linear_dither(unsigned int bits, mad_fixed_t sample, ...@@ -113,6 +118,14 @@ static signed long audio_linear_dither(unsigned int bits, mad_fixed_t sample,
/* end of stolen stuff from mpg321 */ /* end of stolen stuff from mpg321 */
static int mp3_plugin_init(void)
{
gaplessPlayback = getBoolConfigParam(CONF_GAPLESS_MP3_PLAYBACK);
if (gaplessPlayback == -1) gaplessPlayback = DEFAULT_GAPLESS_MP3_PLAYBACK;
else if (gaplessPlayback < 0) exit(EXIT_FAILURE);
return 1;
}
/* decoder stuff is based on madlld */ /* decoder stuff is based on madlld */
#define MP3_DATA_OUTPUT_BUFFER_SIZE 4096 #define MP3_DATA_OUTPUT_BUFFER_SIZE 4096
...@@ -679,7 +692,7 @@ static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc, ...@@ -679,7 +692,7 @@ static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc,
data->foundXing = 1; data->foundXing = 1;
data->muteFrame = MUTEFRAME_SKIP; data->muteFrame = MUTEFRAME_SKIP;
if (data->inStream->seekable && if (gaplessPlayback && data->inStream->seekable &&
parse_lame(&lame, &ptr, &bitlen)) { parse_lame(&lame, &ptr, &bitlen)) {
data->dropSamplesAtStart = lame.encoderDelay + DECODERDELAY; data->dropSamplesAtStart = lame.encoderDelay + DECODERDELAY;
data->dropSamplesAtEnd = lame.encoderPadding; data->dropSamplesAtEnd = lame.encoderPadding;
...@@ -1063,7 +1076,7 @@ static char *mp3_mimeTypes[] = { "audio/mpeg", NULL }; ...@@ -1063,7 +1076,7 @@ static char *mp3_mimeTypes[] = { "audio/mpeg", NULL };
InputPlugin mp3Plugin = { InputPlugin mp3Plugin = {
"mp3", "mp3",
NULL, mp3_plugin_init,
NULL, NULL,
NULL, NULL,
mp3_decode, mp3_decode,
......
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