Commit 22e8abfa authored by Led's avatar Led

0.11.2

parent 521703d6
ver 0.11.2 (2004/7/5)
1) Work around in computing total time for mp3's whose first valid mpeg frame is not layer III
2) Fix mp3 and mp4 decoders when seeking past the end of the file
3) Fix replaygain for flac and vorbis
4) Fix memory leaks in flac decoder (from normalperson)
5) Fix Several other bugs in playlist.c and directory.c (from normalperson)
ver 0.11.1 (2004/6/24) ver 0.11.1 (2004/6/24)
1) Fix a bug that caused "popping" at the beginning of mp3's 1) Fix a bug that caused "popping" at the beginning of mp3's
2) Fix playlistid command 2) Fix playlistid command
......
0.12
----
*) Optimize read() on cleints *) Optimize read() on cleints
*) directory.c needs some serious cleanup *) Add libshout && vorbis encoding support
0.12
----
*) add command that only takes file's or url's (no directory's) and returns the songid of the added song *) add command that only takes file's or url's (no directory's) and returns the songid of the added song
*) allow add commands to specify position to be inserted *) allow add commands to specify position to be inserted
*) saved playlist commands for getting the contents of a playlist and appending to a playlist *) saved playlist commands for getting the contents of a playlist and appending to a playlist
*) have listallinfo return directories
*) allow find/search commands take arbitrary search pairs
Post-1.0 Post-1.0
-------- --------
1) crosslink "list" stuff, for example, artists are crosslinked to alubms and 1) crosslink "list" stuff, for example, artists are crosslinked to alubms and
......
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for mpd 0.11.1. # Generated by GNU Autoconf 2.59 for mpd 0.11.2.
# #
# Report bugs to <shank@mercury.chem.pitt.edu>. # Report bugs to <shank@mercury.chem.pitt.edu>.
# #
...@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} ...@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package. # Identity of this package.
PACKAGE_NAME='mpd' PACKAGE_NAME='mpd'
PACKAGE_TARNAME='mpd' PACKAGE_TARNAME='mpd'
PACKAGE_VERSION='0.11.1' PACKAGE_VERSION='0.11.2'
PACKAGE_STRING='mpd 0.11.1' PACKAGE_STRING='mpd 0.11.2'
PACKAGE_BUGREPORT='shank@mercury.chem.pitt.edu' PACKAGE_BUGREPORT='shank@mercury.chem.pitt.edu'
# Factoring default headers for most tests. # Factoring default headers for most tests.
...@@ -955,7 +955,7 @@ if test "$ac_init_help" = "long"; then ...@@ -955,7 +955,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures mpd 0.11.1 to adapt to many kinds of systems. \`configure' configures mpd 0.11.2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
...@@ -1021,7 +1021,7 @@ fi ...@@ -1021,7 +1021,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of mpd 0.11.1:";; short | recursive ) echo "Configuration of mpd 0.11.2:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
...@@ -1207,7 +1207,7 @@ fi ...@@ -1207,7 +1207,7 @@ fi
test -n "$ac_init_help" && exit 0 test -n "$ac_init_help" && exit 0
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
mpd configure 0.11.1 mpd configure 0.11.2
generated by GNU Autoconf 2.59 generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc. Copyright (C) 2003 Free Software Foundation, Inc.
...@@ -1221,7 +1221,7 @@ cat >&5 <<_ACEOF ...@@ -1221,7 +1221,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by mpd $as_me 0.11.1, which was It was created by mpd $as_me 0.11.2, which was
generated by GNU Autoconf 2.59. Invocation command line was generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@ $ $0 $@
...@@ -26085,7 +26085,7 @@ _ASBOX ...@@ -26085,7 +26085,7 @@ _ASBOX
} >&5 } >&5
cat >&5 <<_CSEOF cat >&5 <<_CSEOF
This file was extended by mpd $as_me 0.11.1, which was This file was extended by mpd $as_me 0.11.2, which was
generated by GNU Autoconf 2.59. Invocation command line was generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
...@@ -26148,7 +26148,7 @@ _ACEOF ...@@ -26148,7 +26148,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\ ac_cs_version="\\
mpd config.status 0.11.1 mpd config.status 0.11.2
configured by $0, generated by GNU Autoconf 2.59, configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
......
...@@ -2,7 +2,7 @@ dnl AC_INIT(src/main.c) ...@@ -2,7 +2,7 @@ dnl AC_INIT(src/main.c)
dnl AM_INIT_AUTOMAKE(mpd, 0.10.0) dnl AM_INIT_AUTOMAKE(mpd, 0.10.0)
AC_PREREQ(2.52) AC_PREREQ(2.52)
AC_INIT(mpd, 0.11.1, shank@mercury.chem.pitt.edu) AC_INIT(mpd, 0.11.2, shank@mercury.chem.pitt.edu)
AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION) AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
dnl MAD wants this stuff dnl MAD wants this stuff
......
...@@ -136,7 +136,7 @@ playlistinfo <int song> ...@@ -136,7 +136,7 @@ playlistinfo <int song>
displays list of songs in the playlist displays list of songs in the playlist
_song_ is optional and species a single song to displa info for _song_ is optional and species a single song to displa info for
playlistiid <int songid> playlistid <int songid>
displays list of songs in the playlist displays list of songs in the playlist
_songid_ is optional and species a single song to display info for _songid_ is optional and species a single song to display info for
......
bin_PROGRAMS = mpd bin_PROGRAMS = mpd
SUBDIRS = $(ID3_SUBDIR) $(MAD_SUBDIR) $(MP4FF_SUBDIR) SUBDIRS = $(ID3_SUBDIR) $(MAD_SUBDIR) $(MP4FF_SUBDIR)
mpd_inputPlugins = inputPlugins/mp3_plugin.c inputPlugins/ogg_plugin.c \ mpd_inputPlugins = \
inputPlugins/flac_plugin.c inputPlugins/audiofile_plugin.c \ inputPlugins/aac_plugin.c \
inputPlugins/mp4_plugin.c inputPlugins/aac_plugin.c \ inputPlugins/audiofile_plugin.c \
inputPlugins/mod_plugin.c inputPlugins/flac_plugin.c \
inputPlugins/mod_plugin.c \
mpd_headers = buffer2array.h interface.h command.h playlist.h ls.h \ inputPlugins/mp3_plugin.c \
song.h list.h directory.h tables.h utils.h path.h \ inputPlugins/mp4_plugin.c \
tag.h player.h listen.h conf.h volume.h \ inputPlugins/ogg_plugin.c
audio.h playerData.h stats.h myfprintf.h sig_handlers.h decode.h log.h \
charConv.h permission.h mpd_types.h pcm_utils.h \
signal_check.h utf8.h inputStream.h \ mpd_headers = \
outputBuffer.h replayGain.h inputStream_file.h inputStream_http.h \ ack.h \
inputPlugin.h metadataChunk.h ack.h audio.h \
mpd_SOURCES = main.c buffer2array.c interface.c command.c playlist.c ls.c \ buffer2array.h \
song.c list.c directory.c tables.c utils.c path.c \ charConv.h \
tag.c player.c listen.c conf.c volume.c \ command.h \
audio.c playerData.c stats.c myfprintf.c sig_handlers.c decode.c log.c \ conf.h \
charConv.c permission.c pcm_utils.c \ decode.h \
signal_check.c utf8.c inputStream.c outputBuffer.c \ directory.h \
replayGain.c inputStream_file.c inputStream_http.c inputPlugin.c \ inputPlugin.h \
metadataChunk.c $(mpd_headers) $(mpd_inputPlugins) inputStream.h \
inputStream_file.h \
inputStream_http.h \
interface.h \
list.h \
listen.h \
log.h \
ls.h \
metadataChunk.h \
mpd_types.h \
myfprintf.h \
outputBuffer.h \
path.h \
pcm_utils.h \
permission.h \
player.h \
playerData.h \
playlist.h \
replayGain.h \
signal_check.h \
sig_handlers.h \
song.h \
stats.h \
tag.h \
tables.h \
utf8.h \
utils.h \
volume.h
mpd_SOURCES = \
$(mpd_headers) \
$(mpd_inputPlugins) \
audio.c \
buffer2array.c \
charConv.c \
command.c \
conf.c \
decode.c \
directory.c \
inputPlugin.c \
inputStream.c \
inputStream_file.c \
inputStream_http.c \
interface.c \
list.c \
listen.c \
log.c \
ls.c \
main.c \
metadataChunk.c \
myfprintf.c \
outputBuffer.c \
path.c \
pcm_utils.c \
permission.c \
player.c \
playerData.c \
playlist.c \
replayGain.c \
sig_handlers.c \
signal_check.c \
song.c \
stats.c \
tables.c \
tag.c \
utils.c \
volume.c \
utf8.c
mpd_CFLAGS = $(MPD_CFLAGS) mpd_CFLAGS = $(MPD_CFLAGS)
mpd_LDADD = $(MPD_LIBS) $(ID3_LIB) $(MAD_LIB) $(MP4FF_LIB) mpd_LDADD = $(MPD_LIBS) $(ID3_LIB) $(MAD_LIB) $(MP4FF_LIB)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -151,11 +151,11 @@ void directory_sigChldHandler(int pid, int status) { ...@@ -151,11 +151,11 @@ void directory_sigChldHandler(int pid, int status) {
{ {
case DIRECTORY_UPDATE_EXIT_UPDATE: case DIRECTORY_UPDATE_EXIT_UPDATE:
directory_reReadDB = 1; directory_reReadDB = 1;
DEBUG("direcotry_sigChldHandler: " DEBUG("directory_sigChldHandler: "
"updated db\n"); "updated db\n");
case DIRECTORY_UPDATE_EXIT_NOUPDATE: case DIRECTORY_UPDATE_EXIT_NOUPDATE:
DEBUG("direcotry_sigChldHandler: " DEBUG("directory_sigChldHandler: "
"update exitted succesffully\n"); "update exited succesffully\n");
break; break;
default: default:
ERROR("error updating db\n"); ERROR("error updating db\n");
......
...@@ -70,9 +70,11 @@ FLAC__SeekableStreamDecoderLengthStatus flacLength( ...@@ -70,9 +70,11 @@ FLAC__SeekableStreamDecoderLengthStatus flacLength(
FLAC__bool flacEOF(const FLAC__SeekableStreamDecoder *, void *); FLAC__bool flacEOF(const FLAC__SeekableStreamDecoder *, void *);
int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) { int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
FLAC__SeekableStreamDecoder * flacDec; FLAC__SeekableStreamDecoder * flacDec = NULL;
FlacData data; FlacData data;
int status = 1; int status = 1;
int ret =0;
int streamOpen = 0;
data.chunk_length = 0; data.chunk_length = 0;
data.time = 0; data.time = 0;
...@@ -85,10 +87,15 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) { ...@@ -85,10 +87,15 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
if(openInputStream(&(data.inStream), path)<0) { if(openInputStream(&(data.inStream), path)<0) {
ERROR("unable to open flac: %s\n", path); ERROR("unable to open flac: %s\n", path);
return -1; ret = -1;
goto fail;
} }
streamOpen = 1;
if(!(flacDec = FLAC__seekable_stream_decoder_new())) return -1; if(!(flacDec = FLAC__seekable_stream_decoder_new())) {
ret = -1;
goto fail;
}
/*status&=FLAC__file_decoder_set_md5_checking(flacDec,1);*/ /*status&=FLAC__file_decoder_set_md5_checking(flacDec,1);*/
status&=FLAC__seekable_stream_decoder_set_read_callback(flacDec, status&=FLAC__seekable_stream_decoder_set_read_callback(flacDec,
flacRead); flacRead);
...@@ -103,6 +110,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) { ...@@ -103,6 +110,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
flacWrite); flacWrite);
status&=FLAC__seekable_stream_decoder_set_metadata_callback(flacDec, status&=FLAC__seekable_stream_decoder_set_metadata_callback(flacDec,
flacMetadata); flacMetadata);
status&=FLAC__seekable_stream_decoder_set_metadata_respond(flacDec,
FLAC__METADATA_TYPE_VORBIS_COMMENT);
status&=FLAC__seekable_stream_decoder_set_error_callback(flacDec, status&=FLAC__seekable_stream_decoder_set_error_callback(flacDec,
flacError); flacError);
status&=FLAC__seekable_stream_decoder_set_client_data(flacDec, status&=FLAC__seekable_stream_decoder_set_client_data(flacDec,
...@@ -112,8 +121,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) { ...@@ -112,8 +121,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
flacPrintErroredState( flacPrintErroredState(
FLAC__seekable_stream_decoder_get_state(flacDec), FLAC__seekable_stream_decoder_get_state(flacDec),
path); path);
FLAC__seekable_stream_decoder_delete(flacDec); ret = -1;
return -1; goto fail;
} }
if(FLAC__seekable_stream_decoder_init(flacDec)!= if(FLAC__seekable_stream_decoder_init(flacDec)!=
...@@ -123,8 +132,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) { ...@@ -123,8 +132,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
flacPrintErroredState( flacPrintErroredState(
FLAC__seekable_stream_decoder_get_state(flacDec), FLAC__seekable_stream_decoder_get_state(flacDec),
path); path);
FLAC__seekable_stream_decoder_delete(flacDec); ret = -1;
return -1; goto fail;
} }
if(!FLAC__seekable_stream_decoder_process_until_end_of_metadata(flacDec)) { if(!FLAC__seekable_stream_decoder_process_until_end_of_metadata(flacDec)) {
...@@ -132,8 +141,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) { ...@@ -132,8 +141,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
flacPrintErroredState( flacPrintErroredState(
FLAC__seekable_stream_decoder_get_state(flacDec), FLAC__seekable_stream_decoder_get_state(flacDec),
path); path);
FLAC__seekable_stream_decoder_delete(flacDec); ret = -1;
return -1; goto fail;
} }
dc->state = DECODE_STATE_DECODE; dc->state = DECODE_STATE_DECODE;
...@@ -168,7 +177,6 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) { ...@@ -168,7 +177,6 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
path); path);
FLAC__seekable_stream_decoder_finish(flacDec); FLAC__seekable_stream_decoder_finish(flacDec);
} }
FLAC__seekable_stream_decoder_delete(flacDec);
/* send last little bit */ /* send last little bit */
if(data.chunk_length>0 && !dc->stop) { if(data.chunk_length>0 && !dc->stop) {
flacSendChunk(&data); flacSendChunk(&data);
...@@ -186,7 +194,12 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) { ...@@ -186,7 +194,12 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
} }
else dc->state = DECODE_STATE_STOP; else dc->state = DECODE_STATE_STOP;
return 0; fail:
if(streamOpen) closeInputStream(&(data.inStream));
if(flacDec) FLAC__seekable_stream_decoder_delete(flacDec);
return ret;
} }
FLAC__SeekableStreamDecoderReadStatus flacRead( FLAC__SeekableStreamDecoderReadStatus flacRead(
...@@ -576,4 +589,3 @@ InputPlugin flacPlugin = ...@@ -576,4 +589,3 @@ InputPlugin flacPlugin =
}; };
#endif #endif
/* vim:set shiftwidth=8 tabstop=8 expandtab: */
...@@ -238,7 +238,7 @@ char * modSuffixes[] = {"amf", ...@@ -238,7 +238,7 @@ char * modSuffixes[] = {"amf",
InputPlugin modPlugin = InputPlugin modPlugin =
{ {
"audiofile", "mod",
NULL, NULL,
mod_finishMikMod, mod_finishMikMod,
NULL, NULL,
......
...@@ -297,6 +297,9 @@ int decodeNextFrameHeader(mp3DecodeData * data, MpdTag ** tag) { ...@@ -297,6 +297,9 @@ int decodeNextFrameHeader(mp3DecodeData * data, MpdTag ** tag) {
} }
} }
} }
if(data->frame.header.layer != MAD_LAYER_III) {
return DECODE_SKIP;
}
return DECODE_OK; return DECODE_OK;
} }
...@@ -706,14 +709,15 @@ int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) { ...@@ -706,14 +709,15 @@ int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) {
data.elapsedTime,data.bitRate/1000); data.elapsedTime,data.bitRate/1000);
} }
flushOutputBuffer(cb);
mp3DecodeDataFinalize(&data);
closeInputStream(inStream); closeInputStream(inStream);
/*if(dc->seek) { if(dc->seek && data.muteFrame == MUTEFRAME_SEEK) {
dc->seekError = 1; clearOutputBuffer(cb);
dc->seek = 0; dc->seek = 0;
}*/ }
flushOutputBuffer(cb);
mp3DecodeDataFinalize(&data);
if(dc->stop) { if(dc->stop) {
dc->state = DECODE_STATE_STOP; dc->state = DECODE_STATE_STOP;
......
...@@ -112,6 +112,7 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) { ...@@ -112,6 +112,7 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) {
long offset; long offset;
mpd_uint16 bitRate = 0; mpd_uint16 bitRate = 0;
InputStream inStream; InputStream inStream;
int seeking = 0;
if(openInputStream(&inStream, path) < 0) { if(openInputStream(&inStream, path) < 0) {
ERROR("failed to open %s\n", path); ERROR("failed to open %s\n", path);
...@@ -193,7 +194,9 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) { ...@@ -193,7 +194,9 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) {
seekTable = malloc(sizeof(float)*numSamples); seekTable = malloc(sizeof(float)*numSamples);
for(sampleId=0; sampleId<numSamples && !eof; sampleId++) { for(sampleId=0; sampleId<numSamples && !eof; sampleId++) {
if(dc->seek && seekTableEnd>1 && if(dc->seek) seeking = 1;
if(seeking && seekTableEnd>1 &&
seekTable[seekTableEnd]>=dc->seekWhere) seekTable[seekTableEnd]>=dc->seekWhere)
{ {
int i = 2; int i = 2;
...@@ -215,15 +218,16 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) { ...@@ -215,15 +218,16 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) {
else dur-=offset; else dur-=offset;
time+=((float)dur)/scale; time+=((float)dur)/scale;
if(dc->seek && time>dc->seekWhere) seekPositionFound = 1; if(seeking && time>dc->seekWhere) seekPositionFound = 1;
if(dc->seek && seekPositionFound) { if(seeking && seekPositionFound) {
seekPositionFound = 0; seekPositionFound = 0;
clearOutputBuffer(cb); clearOutputBuffer(cb);
seeking = 0;
dc->seek = 0; dc->seek = 0;
} }
if(dc->seek) continue; if(seeking) continue;
if(mp4ff_read_sample(mp4fh,track,sampleId,&mp4Buffer, if(mp4ff_read_sample(mp4fh,track,sampleId,&mp4Buffer,
&mp4BufferSize) == 0) &mp4BufferSize) == 0)
...@@ -287,8 +291,6 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) { ...@@ -287,8 +291,6 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) {
} }
} }
flushOutputBuffer(cb);
free(seekTable); free(seekTable);
faacDecClose(decoder); faacDecClose(decoder);
mp4ff_close(mp4fh); mp4ff_close(mp4fh);
...@@ -297,10 +299,11 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) { ...@@ -297,10 +299,11 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) {
if(dc->state != DECODE_STATE_DECODE) return -1; if(dc->state != DECODE_STATE_DECODE) return -1;
/*if(dc->seek) { if(dc->seek && seeking) {
dc->seekError = 1; clearOutputBuffer(cb);
dc->seek = 0; dc->seek = 0;
}*/ }
flushOutputBuffer(cb);
if(dc->stop) { if(dc->stop) {
dc->state = DECODE_STATE_STOP; dc->state = DECODE_STATE_STOP;
......
...@@ -157,8 +157,12 @@ float ogg_getReplayGainScale(char ** comments) { ...@@ -157,8 +157,12 @@ float ogg_getReplayGainScale(char ** comments) {
if(albumGainFound) { if(albumGainFound) {
return computeReplayGainScale(albumGain,albumPeak); return computeReplayGainScale(albumGain,albumPeak);
} }
default:
return computeReplayGainScale(trackGain,trackPeak); return computeReplayGainScale(trackGain,trackPeak);
case REPLAYGAIN_TRACK:
if(trackGainFound) {
return computeReplayGainScale(trackGain,trackPeak);
}
return computeReplayGainScale(albumGain,albumPeak);
} }
return 1.0; return 1.0;
...@@ -313,7 +317,7 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) ...@@ -313,7 +317,7 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
if((test = ov_bitrate_instant(&vf))>0) { if((test = ov_bitrate_instant(&vf))>0) {
bitRate = test/1000; bitRate = test/1000;
} }
doReplayGain(chunk,ret,&(dc->audioFormat), doReplayGain(chunk,chunkpos,&(dc->audioFormat),
replayGainScale); replayGainScale);
sendDataToOutputBuffer(cb, inStream, dc, sendDataToOutputBuffer(cb, inStream, dc,
inStream->seekable, inStream->seekable,
......
...@@ -168,11 +168,14 @@ int lsPlaylists(FILE * fp, char * utf8path) { ...@@ -168,11 +168,14 @@ int lsPlaylists(FILE * fp, char * utf8path) {
free(path); free(path);
if(list) { if(list) {
int i;
sortList(list); sortList(list);
dup = malloc(strlen(utf8path)+2); dup = malloc(strlen(utf8path)+2);
strcpy(dup,utf8path); strcpy(dup,utf8path);
while(dup[strlen(dup)-1]=='/') dup[strlen(dup)-1] = '\0'; for(i = strlen(dup)-1; i >= 0 && dup[i]=='/'; i--) {
dup[i] = '\0';
}
if(strlen(dup)) strcat(dup,"/"); if(strlen(dup)) strcat(dup,"/");
node = list->firstNode; node = list->firstNode;
......
...@@ -31,11 +31,7 @@ static mpd_sint8 currentMetaChunk = -1; ...@@ -31,11 +31,7 @@ static mpd_sint8 currentMetaChunk = -1;
static mpd_sint8 sendMetaChunk = 0; static mpd_sint8 sendMetaChunk = 0;
void clearAllMetaChunkSets(OutputBuffer * cb) { void clearAllMetaChunkSets(OutputBuffer * cb) {
int i; memset(cb->metaChunkSet, 0, BUFFERED_METACHUNKS);
for(i=0; i<BUFFERED_METACHUNKS; i++) {
cb->metaChunkSet[i] = 0;
}
} }
void clearOutputBuffer(OutputBuffer * cb) { void clearOutputBuffer(OutputBuffer * cb) {
......
...@@ -480,7 +480,6 @@ Song * playerCurrentDecodeSong() { ...@@ -480,7 +480,6 @@ Song * playerCurrentDecodeSong() {
memcpy(prev, &(pc->metadataChunk), sizeof(MetadataChunk)); memcpy(prev, &(pc->metadataChunk), sizeof(MetadataChunk));
if(song) freeJustSong(song); if(song) freeJustSong(song);
song = newNullSong(); song = newNullSong();
if(song->utf8url) free(song->utf8url);
song->utf8url = strdup(pc->currentUrl); song->utf8url = strdup(pc->currentUrl);
song->tag = metadataChunkToMpdTagDup(prev); song->tag = metadataChunkToMpdTagDup(prev);
validateUtf8Tag(song->tag); validateUtf8Tag(song->tag);
......
...@@ -65,8 +65,8 @@ typedef struct _Playlist { ...@@ -65,8 +65,8 @@ typedef struct _Playlist {
/* holds version a song was modified on */ /* holds version a song was modified on */
mpd_uint32 * songMod; mpd_uint32 * songMod;
int * order; int * order;
int * numToId; int * positionToId;
int * idToNum; int * idToPosition;
int length; int length;
int current; int current;
int queued; int queued;
...@@ -161,9 +161,9 @@ void initPlaylist() { ...@@ -161,9 +161,9 @@ void initPlaylist() {
playlist.songs = malloc(sizeof(Song *)*playlist_max_length); playlist.songs = malloc(sizeof(Song *)*playlist_max_length);
playlist.songMod = malloc(sizeof(mpd_uint32)*playlist_max_length); playlist.songMod = malloc(sizeof(mpd_uint32)*playlist_max_length);
playlist.order = malloc(sizeof(int)*playlist_max_length); playlist.order = malloc(sizeof(int)*playlist_max_length);
playlist.idToNum = malloc(sizeof(int)*playlist_max_length* playlist.idToPosition = malloc(sizeof(int)*playlist_max_length*
PLAYLIST_HASH_MULT); PLAYLIST_HASH_MULT);
playlist.numToId = malloc(sizeof(int)*playlist_max_length); playlist.positionToId = malloc(sizeof(int)*playlist_max_length);
memset(playlist.songs,0,sizeof(char *)*playlist_max_length); memset(playlist.songs,0,sizeof(char *)*playlist_max_length);
...@@ -174,14 +174,14 @@ void initPlaylist() { ...@@ -174,14 +174,14 @@ void initPlaylist() {
} }
for(i=0; i<playlist_max_length*PLAYLIST_HASH_MULT; i++) { for(i=0; i<playlist_max_length*PLAYLIST_HASH_MULT; i++) {
playlist.idToNum[i] = -1; playlist.idToPosition[i] = -1;
} }
} }
static int getNextId() { static int getNextId() {
static int cur = 0; static int cur = 0;
while(playlist.idToNum[cur] != -1) { while(playlist.idToPosition[cur] != -1) {
cur++; cur++;
if(cur >= playlist_max_length*PLAYLIST_HASH_MULT) { if(cur >= playlist_max_length*PLAYLIST_HASH_MULT) {
cur = 0; cur = 0;
...@@ -207,10 +207,10 @@ void finishPlaylist() { ...@@ -207,10 +207,10 @@ void finishPlaylist() {
playlist.songMod = NULL; playlist.songMod = NULL;
free(playlist.order); free(playlist.order);
playlist.order = NULL; playlist.order = NULL;
free(playlist.idToNum); free(playlist.idToPosition);
playlist.idToNum = NULL; playlist.idToPosition = NULL;
free(playlist.numToId); free(playlist.positionToId);
playlist.numToId = NULL; playlist.positionToId = NULL;
} }
int clearPlaylist(FILE * fp) { int clearPlaylist(FILE * fp) {
...@@ -222,7 +222,7 @@ int clearPlaylist(FILE * fp) { ...@@ -222,7 +222,7 @@ int clearPlaylist(FILE * fp) {
if(playlist.songs[i]->type == SONG_TYPE_URL) { if(playlist.songs[i]->type == SONG_TYPE_URL) {
freeJustSong(playlist.songs[i]); freeJustSong(playlist.songs[i]);
} }
playlist.idToNum[playlist.numToId[i]] = -1; playlist.idToPosition[playlist.positionToId[i]] = -1;
playlist.songs[i] = NULL; playlist.songs[i] = NULL;
} }
playlist.length = 0; playlist.length = 0;
...@@ -425,7 +425,7 @@ void printPlaylistSongInfo(FILE * fp, int song) { ...@@ -425,7 +425,7 @@ void printPlaylistSongInfo(FILE * fp, int song) {
printMpdTag(fp, tag); printMpdTag(fp, tag);
} }
myfprintf(fp, "Pos: %i\n", song); myfprintf(fp, "Pos: %i\n", song);
myfprintf(fp, "Id: %i\n", playlist.numToId[song]); myfprintf(fp, "Id: %i\n", playlist.positionToId[song]);
} }
int playlistChanges(FILE * fp, mpd_uint32 version) { int playlistChanges(FILE * fp, mpd_uint32 version) {
...@@ -465,7 +465,7 @@ int playlistInfo(FILE * fp, int song) { ...@@ -465,7 +465,7 @@ int playlistInfo(FILE * fp, int song) {
# define checkSongId(id) { \ # define checkSongId(id) { \
if(id < 0 || id >= PLAYLIST_HASH_MULT*playlist_max_length || \ if(id < 0 || id >= PLAYLIST_HASH_MULT*playlist_max_length || \
playlist.idToNum[id] == -1 ) \ playlist.idToPosition[id] == -1 ) \
{ \ { \
commandError(fp, ACK_ERROR_NO_EXIST, \ commandError(fp, ACK_ERROR_NO_EXIST, \
"song id doesn't exist: \"%i\"", id); \ "song id doesn't exist: \"%i\"", id); \
...@@ -480,7 +480,7 @@ int playlistId(FILE * fp, int id) { ...@@ -480,7 +480,7 @@ int playlistId(FILE * fp, int id) {
if(id>=0) { if(id>=0) {
checkSongId(id); checkSongId(id);
begin = playlist.idToNum[id]; begin = playlist.idToPosition[id];
end = begin+1; end = begin+1;
} }
...@@ -500,12 +500,12 @@ void swapSongs(int song1, int song2) { ...@@ -500,12 +500,12 @@ void swapSongs(int song1, int song2) {
playlist.songMod[song1] = playlist.version; playlist.songMod[song1] = playlist.version;
playlist.songMod[song2] = playlist.version; playlist.songMod[song2] = playlist.version;
playlist.idToNum[playlist.numToId[song1]] = song2; playlist.idToPosition[playlist.positionToId[song1]] = song2;
playlist.idToNum[playlist.numToId[song2]] = song1; playlist.idToPosition[playlist.positionToId[song2]] = song1;
iTemp = playlist.numToId[song1]; iTemp = playlist.positionToId[song1];
playlist.numToId[song1] = playlist.numToId[song2]; playlist.positionToId[song1] = playlist.positionToId[song2];
playlist.numToId[song2] = iTemp; playlist.positionToId[song2] = iTemp;
} }
void queueNextSongInPlaylist() { void queueNextSongInPlaylist() {
...@@ -624,8 +624,8 @@ int addSongToPlaylist(FILE * fp, Song * song) { ...@@ -624,8 +624,8 @@ int addSongToPlaylist(FILE * fp, Song * song) {
playlist.songs[playlist.length] = song; playlist.songs[playlist.length] = song;
playlist.songMod[playlist.length] = playlist.version; playlist.songMod[playlist.length] = playlist.version;
playlist.order[playlist.length] = playlist.length; playlist.order[playlist.length] = playlist.length;
playlist.numToId[playlist.length] = getNextId(); playlist.positionToId[playlist.length] = getNextId();
playlist.idToNum[playlist.numToId[playlist.length]] = playlist.length; playlist.idToPosition[playlist.positionToId[playlist.length]] = playlist.length;
playlist.length++; playlist.length++;
if(playlist.random) { if(playlist.random) {
...@@ -702,13 +702,13 @@ int swapSongsInPlaylistById(FILE * fp, int id1, int id2) { ...@@ -702,13 +702,13 @@ int swapSongsInPlaylistById(FILE * fp, int id1, int id2) {
checkSongId(id1); checkSongId(id1);
checkSongId(id2); checkSongId(id2);
return swapSongsInPlaylist(fp, playlist.idToNum[id1], return swapSongsInPlaylist(fp, playlist.idToPosition[id1],
playlist.idToNum[id2]); playlist.idToPosition[id2]);
} }
#define moveSongFromTo(from, to) { \ #define moveSongFromTo(from, to) { \
playlist.idToNum[playlist.numToId[from]] = to; \ playlist.idToPosition[playlist.positionToId[from]] = to; \
playlist.numToId[to] = playlist.numToId[from]; \ playlist.positionToId[to] = playlist.positionToId[from]; \
playlist.songs[to] = playlist.songs[from]; \ playlist.songs[to] = playlist.songs[from]; \
playlist.songMod[to] = playlist.version; \ playlist.songMod[to] = playlist.version; \
} }
...@@ -737,7 +737,7 @@ int deleteFromPlaylist(FILE * fp, int song) { ...@@ -737,7 +737,7 @@ int deleteFromPlaylist(FILE * fp, int song) {
freeJustSong(playlist.songs[song]); freeJustSong(playlist.songs[song]);
} }
playlist.idToNum[playlist.numToId[song]] = -1; playlist.idToPosition[playlist.positionToId[song]] = -1;
/* delete song from songs array */ /* delete song from songs array */
for(i=song;i<playlist.length-1;i++) { for(i=song;i<playlist.length-1;i++) {
...@@ -784,7 +784,7 @@ int deleteFromPlaylist(FILE * fp, int song) { ...@@ -784,7 +784,7 @@ int deleteFromPlaylist(FILE * fp, int song) {
int deleteFromPlaylistById(FILE * fp, int id) { int deleteFromPlaylistById(FILE * fp, int id) {
checkSongId(id); checkSongId(id);
return deleteFromPlaylist(fp, playlist.idToNum[id]); return deleteFromPlaylist(fp, playlist.idToPosition[id]);
} }
void deleteASongFromPlaylist(Song * song) { void deleteASongFromPlaylist(Song * song) {
...@@ -885,7 +885,7 @@ int playPlaylistById(FILE * fp, int id, int stopOnError) { ...@@ -885,7 +885,7 @@ int playPlaylistById(FILE * fp, int id, int stopOnError) {
checkSongId(id); checkSongId(id);
return playPlaylist(fp, playlist.idToNum[id], stopOnError); return playPlaylist(fp, playlist.idToPosition[id], stopOnError);
} }
void syncCurrentPlayerDecodeMetadata() { void syncCurrentPlayerDecodeMetadata() {
...@@ -1039,7 +1039,7 @@ int moveSongInPlaylist(FILE * fp, int from, int to) { ...@@ -1039,7 +1039,7 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
} }
tmpSong = playlist.songs[from]; tmpSong = playlist.songs[from];
tmpId = playlist.numToId[from]; tmpId = playlist.positionToId[from];
/* move songs to one less in from->to */ /* move songs to one less in from->to */
for(i=from;i<to;i++) { for(i=from;i<to;i++) {
moveSongFromTo(i+1, i); moveSongFromTo(i+1, i);
...@@ -1049,8 +1049,8 @@ int moveSongInPlaylist(FILE * fp, int from, int to) { ...@@ -1049,8 +1049,8 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
moveSongFromTo(i-1, i); moveSongFromTo(i-1, i);
} }
/* put song at _to_ */ /* put song at _to_ */
playlist.idToNum[tmpId] = to; playlist.idToPosition[tmpId] = to;
playlist.numToId[to] = tmpId; playlist.positionToId[to] = tmpId;
playlist.songs[to] = tmpSong; playlist.songs[to] = tmpSong;
playlist.songMod[to] = playlist.version; playlist.songMod[to] = playlist.version;
/* now deal with order */ /* now deal with order */
...@@ -1084,13 +1084,15 @@ int moveSongInPlaylist(FILE * fp, int from, int to) { ...@@ -1084,13 +1084,15 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
int moveSongInPlaylistById(FILE * fp, int id1, int to) { int moveSongInPlaylistById(FILE * fp, int id1, int to) {
checkSongId(id1); checkSongId(id1);
return moveSongInPlaylist(fp, playlist.idToNum[id1], to); return moveSongInPlaylist(fp, playlist.idToPosition[id1], to);
} }
void orderPlaylist() { void orderPlaylist() {
int i; int i;
playlist.current = playlist.order[playlist.current]; if(playlist.current >= 0 && playlist.current < playlist.length) {
playlist.current = playlist.order[playlist.current];
}
if(playlist_state==PLAYLIST_STATE_PLAY) { if(playlist_state==PLAYLIST_STATE_PLAY) {
if(playlist.queued>=0) { if(playlist.queued>=0) {
...@@ -1461,9 +1463,9 @@ int seekSongInPlaylist(FILE * fp, int song, float time) { ...@@ -1461,9 +1463,9 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
int seekSongInPlaylistById(FILE * fp, int id, float time) { int seekSongInPlaylistById(FILE * fp, int id, float time) {
checkSongId(id); checkSongId(id);
return seekSongInPlaylist(fp, playlist.idToNum[id], time); return seekSongInPlaylist(fp, playlist.idToPosition[id], time);
} }
int getPlaylistSongId(int song) { int getPlaylistSongId(int song) {
return playlist.numToId[song]; return playlist.positionToId[song];
} }
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