ingore mp3 CRC's for files and not streams
git-svn-id: https://svn.musicpd.org/mpd/trunk@1161 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
2a76d4c8cf
commit
90c75b1107
@ -291,7 +291,7 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
|
|||||||
/*if(fileSuffix == DECODE_SUFFIX_MP3 || (inStream.mime &&
|
/*if(fileSuffix == DECODE_SUFFIX_MP3 || (inStream.mime &&
|
||||||
0 == strcmp(inStream.mime, "audio/mpeg")))*/
|
0 == strcmp(inStream.mime, "audio/mpeg")))*/
|
||||||
{
|
{
|
||||||
ret = mp3_decode(cb,dc,&inStream);
|
ret = mp3_decode(cb, dc, &inStream, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = DECODE_ERROR_UNKTYPE;
|
ret = DECODE_ERROR_UNKTYPE;
|
||||||
@ -299,7 +299,7 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
|
|||||||
case DECODE_TYPE_FILE:
|
case DECODE_TYPE_FILE:
|
||||||
#ifdef HAVE_MAD
|
#ifdef HAVE_MAD
|
||||||
if(suffix == DECODE_SUFFIX_MP3) {
|
if(suffix == DECODE_SUFFIX_MP3) {
|
||||||
ret = mp3_decode(cb, dc, &inStream);
|
ret = mp3_decode(cb, dc, &inStream, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -152,7 +152,6 @@ void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) {
|
|||||||
data->inStream = inStream;
|
data->inStream = inStream;
|
||||||
|
|
||||||
mad_stream_init(&data->stream);
|
mad_stream_init(&data->stream);
|
||||||
data->stream.options |= MAD_OPTION_IGNORECRC;
|
|
||||||
mad_frame_init(&data->frame);
|
mad_frame_init(&data->frame);
|
||||||
mad_synth_init(&data->synth);
|
mad_synth_init(&data->synth);
|
||||||
mad_timer_reset(&data->timer);
|
mad_timer_reset(&data->timer);
|
||||||
@ -411,6 +410,7 @@ int getMp3TotalTime(char * file) {
|
|||||||
|
|
||||||
if(openInputStream(&inStream, file) < 0) return -1;
|
if(openInputStream(&inStream, file) < 0) return -1;
|
||||||
initMp3DecodeData(&data,&inStream);
|
initMp3DecodeData(&data,&inStream);
|
||||||
|
data.stream.options |= MAD_OPTION_IGNORECRC;
|
||||||
if(decodeFirstFrame(&data, NULL)<0) ret = -1;
|
if(decodeFirstFrame(&data, NULL)<0) ret = -1;
|
||||||
else ret = data.totalTime+0.5;
|
else ret = data.totalTime+0.5;
|
||||||
mp3DecodeDataFinalize(&data);
|
mp3DecodeDataFinalize(&data);
|
||||||
@ -419,9 +419,10 @@ int getMp3TotalTime(char * file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data,
|
int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data,
|
||||||
DecoderControl * dc)
|
DecoderControl * dc, int ignoreCrc)
|
||||||
{
|
{
|
||||||
initMp3DecodeData(data, inStream);
|
initMp3DecodeData(data, inStream);
|
||||||
|
if(ignoreCrc) data->stream.options |= MAD_OPTION_IGNORECRC;
|
||||||
if(decodeFirstFrame(data, dc)<0) {
|
if(decodeFirstFrame(data, dc)<0) {
|
||||||
mp3DecodeDataFinalize(data);
|
mp3DecodeDataFinalize(data);
|
||||||
return -1;
|
return -1;
|
||||||
@ -561,10 +562,12 @@ void initAudioFormatFromMp3DecodeData(mp3DecodeData * data, AudioFormat * af) {
|
|||||||
af->channels = MAD_NCHANNELS(&(data->frame).header);
|
af->channels = MAD_NCHANNELS(&(data->frame).header);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) {
|
int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream,
|
||||||
|
int ignoreCrc)
|
||||||
|
{
|
||||||
mp3DecodeData data;
|
mp3DecodeData data;
|
||||||
|
|
||||||
if(openMp3FromInputStream(inStream, &data, dc) < 0) {
|
if(openMp3FromInputStream(inStream, &data, dc, ignoreCrc) < 0) {
|
||||||
closeInputStream(inStream);
|
closeInputStream(inStream);
|
||||||
if(!dc->stop) {
|
if(!dc->stop) {
|
||||||
ERROR("Input does not appear to be a mp3 bit stream.\n");
|
ERROR("Input does not appear to be a mp3 bit stream.\n");
|
||||||
|
@ -29,7 +29,8 @@
|
|||||||
/* this is primarily used in tag.c */
|
/* this is primarily used in tag.c */
|
||||||
int getMp3TotalTime(char * file);
|
int getMp3TotalTime(char * file);
|
||||||
|
|
||||||
int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream);
|
int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream,
|
||||||
|
int ignoreCrc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user