Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
22e8abfa
Commit
22e8abfa
authored
Nov 10, 2008
by
Led
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0.11.2
parent
521703d6
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
212 additions
and
109 deletions
+212
-109
ChangeLog
ChangeLog
+7
-0
TODO
TODO
+7
-3
configure
configure
+9
-9
configure.ac
configure.ac
+1
-1
COMMANDS
doc/COMMANDS
+1
-1
Makefile.am
src/Makefile.am
+90
-21
Makefile.in
src/Makefile.in
+0
-0
directory.c
src/directory.c
+3
-3
flac_plugin.c
src/inputPlugins/flac_plugin.c
+24
-12
mod_plugin.c
src/inputPlugins/mod_plugin.c
+1
-1
mp3_plugin.c
src/inputPlugins/mp3_plugin.c
+9
-5
mp4_plugin.c
src/inputPlugins/mp4_plugin.c
+12
-9
ogg_plugin.c
src/inputPlugins/ogg_plugin.c
+6
-2
ls.c
src/ls.c
+4
-1
outputBuffer.c
src/outputBuffer.c
+1
-5
player.c
src/player.c
+0
-1
playlist.c
src/playlist.c
+37
-35
No files found.
ChangeLog
View file @
22e8abfa
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)
1) Fix a bug that caused "popping" at the beginning of mp3's
2) Fix playlistid command
...
...
TODO
View file @
22e8abfa
0.12
----
*) 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
*) allow add commands to specify position to be inserted
*) 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
--------
1) crosslink "list" stuff, for example, artists are crosslinked to alubms and
...
...
configure
View file @
22e8abfa
#! /bin/sh
# 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>.
#
...
...
@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME
=
'mpd'
PACKAGE_TARNAME
=
'mpd'
PACKAGE_VERSION
=
'0.11.
1
'
PACKAGE_STRING
=
'mpd 0.11.
1
'
PACKAGE_VERSION
=
'0.11.
2
'
PACKAGE_STRING
=
'mpd 0.11.
2
'
PACKAGE_BUGREPORT
=
'shank@mercury.chem.pitt.edu'
# Factoring default headers for most tests.
...
...
@@ -955,7 +955,7 @@ if test "$ac_init_help" = "long"; then
# 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.
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]...
...
...
@@ -1021,7 +1021,7 @@ fi
if
test
-n
"
$ac_init_help
"
;
then
case
$ac_init_help
in
short
|
recursive
)
echo
"Configuration of mpd 0.11.
1
:"
;;
short
|
recursive
)
echo
"Configuration of mpd 0.11.
2
:"
;;
esac
cat
<<
\
_ACEOF
...
...
@@ -1207,7 +1207,7 @@ fi
test
-n
"
$ac_init_help
"
&&
exit
0
if
$ac_init_version
;
then
cat
<<
\
_ACEOF
mpd configure 0.11.
1
mpd configure 0.11.
2
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
...
...
@@ -1221,7 +1221,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
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
$ $0
$@
...
...
@@ -26085,7 +26085,7 @@ _ASBOX
} >&5
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
CONFIG_FILES =
$CONFIG_FILES
...
...
@@ -26148,7 +26148,7 @@ _ACEOF
cat
>>
$CONFIG_STATUS
<<
_ACEOF
ac_cs_version="\\
mpd config.status 0.11.
1
mpd config.status 0.11.
2
configured by
$0
, generated by GNU Autoconf 2.59,
with options \\"`echo "
$ac_configure_args
" | sed 's/[\\""\`\
$]
/\\\\&/g'`\\"
...
...
configure.ac
View file @
22e8abfa
...
...
@@ -2,7 +2,7 @@ dnl AC_INIT(src/main.c)
dnl AM_INIT_AUTOMAKE(mpd, 0.10.0)
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)
dnl MAD wants this stuff
...
...
doc/COMMANDS
View file @
22e8abfa
...
...
@@ -136,7 +136,7 @@ playlistinfo <int song>
displays list of songs in the playlist
_song_ is optional and species a single song to displa info for
playlisti
i
d <int songid>
playlistid <int songid>
displays list of songs in the playlist
_songid_ is optional and species a single song to display info for
...
...
src/Makefile.am
View file @
22e8abfa
bin_PROGRAMS
=
mpd
SUBDIRS
=
$(ID3_SUBDIR)
$(MAD_SUBDIR)
$(MP4FF_SUBDIR)
mpd_inputPlugins
=
inputPlugins/mp3_plugin.c inputPlugins/ogg_plugin.c
\
inputPlugins/flac_plugin.c inputPlugins/audiofile_plugin.c
\
inputPlugins/mp4_plugin.c inputPlugins/aac_plugin.c
\
inputPlugins/mod_plugin.c
mpd_headers
=
buffer2array.h interface.h command.h playlist.h ls.h
\
song.h list.h directory.h tables.h utils.h path.h
\
tag.h player.h listen.h conf.h volume.h
\
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
\
outputBuffer.h replayGain.h inputStream_file.h inputStream_http.h
\
inputPlugin.h metadataChunk.h ack.h
mpd_SOURCES
=
main.c buffer2array.c interface.c command.c playlist.c ls.c
\
song.c list.c directory.c tables.c utils.c path.c
\
tag.c player.c listen.c conf.c volume.c
\
audio.c playerData.c stats.c myfprintf.c sig_handlers.c decode.c log.c
\
charConv.c permission.c pcm_utils.c
\
signal_check.c utf8.c inputStream.c outputBuffer.c
\
replayGain.c inputStream_file.c inputStream_http.c inputPlugin.c
\
metadataChunk.c
$(mpd_headers)
$(mpd_inputPlugins)
mpd_inputPlugins
=
\
inputPlugins/aac_plugin.c
\
inputPlugins/audiofile_plugin.c
\
inputPlugins/flac_plugin.c
\
inputPlugins/mod_plugin.c
\
inputPlugins/mp3_plugin.c
\
inputPlugins/mp4_plugin.c
\
inputPlugins/ogg_plugin.c
mpd_headers
=
\
ack.h
\
audio.h
\
buffer2array.h
\
charConv.h
\
command.h
\
conf.h
\
decode.h
\
directory.h
\
inputPlugin.h
\
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_LDADD
=
$(MPD_LIBS)
$(ID3_LIB)
$(MAD_LIB)
$(MP4FF_LIB)
...
...
src/Makefile.in
View file @
22e8abfa
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/directory.c
View file @
22e8abfa
...
...
@@ -151,11 +151,11 @@ void directory_sigChldHandler(int pid, int status) {
{
case
DIRECTORY_UPDATE_EXIT_UPDATE
:
directory_reReadDB
=
1
;
DEBUG
(
"direc
ot
ry_sigChldHandler: "
DEBUG
(
"direc
to
ry_sigChldHandler: "
"updated db
\n
"
);
case
DIRECTORY_UPDATE_EXIT_NOUPDATE
:
DEBUG
(
"direc
ot
ry_sigChldHandler: "
"update exit
t
ed succesffully
\n
"
);
DEBUG
(
"direc
to
ry_sigChldHandler: "
"update exited succesffully
\n
"
);
break
;
default:
ERROR
(
"error updating db
\n
"
);
...
...
src/inputPlugins/flac_plugin.c
View file @
22e8abfa
...
...
@@ -70,9 +70,11 @@ FLAC__SeekableStreamDecoderLengthStatus flacLength(
FLAC__bool
flacEOF
(
const
FLAC__SeekableStreamDecoder
*
,
void
*
);
int
flac_decode
(
OutputBuffer
*
cb
,
DecoderControl
*
dc
,
char
*
path
)
{
FLAC__SeekableStreamDecoder
*
flacDec
;
FLAC__SeekableStreamDecoder
*
flacDec
=
NULL
;
FlacData
data
;
int
status
=
1
;
int
ret
=
0
;
int
streamOpen
=
0
;
data
.
chunk_length
=
0
;
data
.
time
=
0
;
...
...
@@ -85,10 +87,15 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
if
(
openInputStream
(
&
(
data
.
inStream
),
path
)
<
0
)
{
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__seekable_stream_decoder_set_read_callback
(
flacDec
,
flacRead
);
...
...
@@ -103,6 +110,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
flacWrite
);
status
&=
FLAC__seekable_stream_decoder_set_metadata_callback
(
flacDec
,
flacMetadata
);
status
&=
FLAC__seekable_stream_decoder_set_metadata_respond
(
flacDec
,
FLAC__METADATA_TYPE_VORBIS_COMMENT
);
status
&=
FLAC__seekable_stream_decoder_set_error_callback
(
flacDec
,
flacError
);
status
&=
FLAC__seekable_stream_decoder_set_client_data
(
flacDec
,
...
...
@@ -112,8 +121,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
flacPrintErroredState
(
FLAC__seekable_stream_decoder_get_state
(
flacDec
),
path
);
FLAC__seekable_stream_decoder_delete
(
flacDec
)
;
return
-
1
;
ret
=
-
1
;
goto
fail
;
}
if
(
FLAC__seekable_stream_decoder_init
(
flacDec
)
!=
...
...
@@ -123,8 +132,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
flacPrintErroredState
(
FLAC__seekable_stream_decoder_get_state
(
flacDec
),
path
);
FLAC__seekable_stream_decoder_delete
(
flacDec
)
;
return
-
1
;
ret
=
-
1
;
goto
fail
;
}
if
(
!
FLAC__seekable_stream_decoder_process_until_end_of_metadata
(
flacDec
))
{
...
...
@@ -132,8 +141,8 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
flacPrintErroredState
(
FLAC__seekable_stream_decoder_get_state
(
flacDec
),
path
);
FLAC__seekable_stream_decoder_delete
(
flacDec
)
;
return
-
1
;
ret
=
-
1
;
goto
fail
;
}
dc
->
state
=
DECODE_STATE_DECODE
;
...
...
@@ -168,7 +177,6 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
path
);
FLAC__seekable_stream_decoder_finish
(
flacDec
);
}
FLAC__seekable_stream_decoder_delete
(
flacDec
);
/* send last little bit */
if
(
data
.
chunk_length
>
0
&&
!
dc
->
stop
)
{
flacSendChunk
(
&
data
);
...
...
@@ -186,7 +194,12 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc, char * path) {
}
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
(
...
...
@@ -576,4 +589,3 @@ InputPlugin flacPlugin =
};
#endif
/* vim:set shiftwidth=8 tabstop=8 expandtab: */
src/inputPlugins/mod_plugin.c
View file @
22e8abfa
...
...
@@ -238,7 +238,7 @@ char * modSuffixes[] = {"amf",
InputPlugin
modPlugin
=
{
"
audiofile
"
,
"
mod
"
,
NULL
,
mod_finishMikMod
,
NULL
,
...
...
src/inputPlugins/mp3_plugin.c
View file @
22e8abfa
...
...
@@ -297,6 +297,9 @@ int decodeNextFrameHeader(mp3DecodeData * data, MpdTag ** tag) {
}
}
}
if
(
data
->
frame
.
header
.
layer
!=
MAD_LAYER_III
)
{
return
DECODE_SKIP
;
}
return
DECODE_OK
;
}
...
...
@@ -706,14 +709,15 @@ int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) {
data
.
elapsedTime
,
data
.
bitRate
/
1000
);
}
flushOutputBuffer
(
cb
);
mp3DecodeDataFinalize
(
&
data
);
closeInputStream
(
inStream
);
/*if(dc->seek
) {
dc->seekError = 1
;
if
(
dc
->
seek
&&
data
.
muteFrame
==
MUTEFRAME_SEEK
)
{
clearOutputBuffer
(
cb
)
;
dc
->
seek
=
0
;
}*/
}
flushOutputBuffer
(
cb
);
mp3DecodeDataFinalize
(
&
data
);
if
(
dc
->
stop
)
{
dc
->
state
=
DECODE_STATE_STOP
;
...
...
src/inputPlugins/mp4_plugin.c
View file @
22e8abfa
...
...
@@ -112,6 +112,7 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) {
long
offset
;
mpd_uint16
bitRate
=
0
;
InputStream
inStream
;
int
seeking
=
0
;
if
(
openInputStream
(
&
inStream
,
path
)
<
0
)
{
ERROR
(
"failed to open %s
\n
"
,
path
);
...
...
@@ -193,7 +194,9 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) {
seekTable
=
malloc
(
sizeof
(
float
)
*
numSamples
);
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
)
{
int
i
=
2
;
...
...
@@ -215,15 +218,16 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) {
else
dur
-=
offset
;
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
;
clearOutputBuffer
(
cb
);
seeking
=
0
;
dc
->
seek
=
0
;
}
if
(
dc
->
seek
)
continue
;
if
(
seeking
)
continue
;
if
(
mp4ff_read_sample
(
mp4fh
,
track
,
sampleId
,
&
mp4Buffer
,
&
mp4BufferSize
)
==
0
)
...
...
@@ -287,8 +291,6 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) {
}
}
flushOutputBuffer
(
cb
);
free
(
seekTable
);
faacDecClose
(
decoder
);
mp4ff_close
(
mp4fh
);
...
...
@@ -297,10 +299,11 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc, char * path) {
if
(
dc
->
state
!=
DECODE_STATE_DECODE
)
return
-
1
;
/*if(dc->seek
) {
dc->seekError = 1
;
if
(
dc
->
seek
&&
seeking
)
{
clearOutputBuffer
(
cb
)
;
dc
->
seek
=
0
;
}*/
}
flushOutputBuffer
(
cb
);
if
(
dc
->
stop
)
{
dc
->
state
=
DECODE_STATE_STOP
;
...
...
src/inputPlugins/ogg_plugin.c
View file @
22e8abfa
...
...
@@ -157,8 +157,12 @@ float ogg_getReplayGainScale(char ** comments) {
if
(
albumGainFound
)
{
return
computeReplayGainScale
(
albumGain
,
albumPeak
);
}
default:
return
computeReplayGainScale
(
trackGain
,
trackPeak
);
case
REPLAYGAIN_TRACK
:
if
(
trackGainFound
)
{
return
computeReplayGainScale
(
trackGain
,
trackPeak
);
}
return
computeReplayGainScale
(
albumGain
,
albumPeak
);
}
return
1
.
0
;
...
...
@@ -313,7 +317,7 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
if
((
test
=
ov_bitrate_instant
(
&
vf
))
>
0
)
{
bitRate
=
test
/
1000
;
}
doReplayGain
(
chunk
,
ret
,
&
(
dc
->
audioFormat
),
doReplayGain
(
chunk
,
chunkpos
,
&
(
dc
->
audioFormat
),
replayGainScale
);
sendDataToOutputBuffer
(
cb
,
inStream
,
dc
,
inStream
->
seekable
,
...
...
src/ls.c
View file @
22e8abfa
...
...
@@ -168,11 +168,14 @@ int lsPlaylists(FILE * fp, char * utf8path) {
free
(
path
);
if
(
list
)
{
int
i
;
sortList
(
list
);
dup
=
malloc
(
strlen
(
utf8path
)
+
2
);
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
,
"/"
);
node
=
list
->
firstNode
;
...
...
src/outputBuffer.c
View file @
22e8abfa
...
...
@@ -31,11 +31,7 @@ static mpd_sint8 currentMetaChunk = -1;
static
mpd_sint8
sendMetaChunk
=
0
;
void
clearAllMetaChunkSets
(
OutputBuffer
*
cb
)
{
int
i
;
for
(
i
=
0
;
i
<
BUFFERED_METACHUNKS
;
i
++
)
{
cb
->
metaChunkSet
[
i
]
=
0
;
}
memset
(
cb
->
metaChunkSet
,
0
,
BUFFERED_METACHUNKS
);
}
void
clearOutputBuffer
(
OutputBuffer
*
cb
)
{
...
...
src/player.c
View file @
22e8abfa
...
...
@@ -480,7 +480,6 @@ Song * playerCurrentDecodeSong() {
memcpy
(
prev
,
&
(
pc
->
metadataChunk
),
sizeof
(
MetadataChunk
));
if
(
song
)
freeJustSong
(
song
);
song
=
newNullSong
();
if
(
song
->
utf8url
)
free
(
song
->
utf8url
);
song
->
utf8url
=
strdup
(
pc
->
currentUrl
);
song
->
tag
=
metadataChunkToMpdTagDup
(
prev
);
validateUtf8Tag
(
song
->
tag
);
...
...
src/playlist.c
View file @
22e8abfa
...
...
@@ -65,8 +65,8 @@ typedef struct _Playlist {
/* holds version a song was modified on */
mpd_uint32
*
songMod
;
int
*
order
;
int
*
num
ToId
;
int
*
idTo
Num
;
int
*
position
ToId
;
int
*
idTo
Position
;
int
length
;
int
current
;
int
queued
;
...
...
@@ -161,9 +161,9 @@ void initPlaylist() {
playlist
.
songs
=
malloc
(
sizeof
(
Song
*
)
*
playlist_max_length
);
playlist
.
songMod
=
malloc
(
sizeof
(
mpd_uint32
)
*
playlist_max_length
);
playlist
.
order
=
malloc
(
sizeof
(
int
)
*
playlist_max_length
);
playlist
.
idTo
Num
=
malloc
(
sizeof
(
int
)
*
playlist_max_length
*
playlist
.
idTo
Position
=
malloc
(
sizeof
(
int
)
*
playlist_max_length
*
PLAYLIST_HASH_MULT
);
playlist
.
num
ToId
=
malloc
(
sizeof
(
int
)
*
playlist_max_length
);
playlist
.
position
ToId
=
malloc
(
sizeof
(
int
)
*
playlist_max_length
);
memset
(
playlist
.
songs
,
0
,
sizeof
(
char
*
)
*
playlist_max_length
);
...
...
@@ -174,14 +174,14 @@ void initPlaylist() {
}
for
(
i
=
0
;
i
<
playlist_max_length
*
PLAYLIST_HASH_MULT
;
i
++
)
{
playlist
.
idTo
Num
[
i
]
=
-
1
;
playlist
.
idTo
Position
[
i
]
=
-
1
;
}
}
static
int
getNextId
()
{
static
int
cur
=
0
;
while
(
playlist
.
idTo
Num
[
cur
]
!=
-
1
)
{
while
(
playlist
.
idTo
Position
[
cur
]
!=
-
1
)
{
cur
++
;
if
(
cur
>=
playlist_max_length
*
PLAYLIST_HASH_MULT
)
{
cur
=
0
;
...
...
@@ -207,10 +207,10 @@ void finishPlaylist() {
playlist
.
songMod
=
NULL
;
free
(
playlist
.
order
);
playlist
.
order
=
NULL
;
free
(
playlist
.
idTo
Num
);
playlist
.
idTo
Num
=
NULL
;
free
(
playlist
.
num
ToId
);
playlist
.
num
ToId
=
NULL
;
free
(
playlist
.
idTo
Position
);
playlist
.
idTo
Position
=
NULL
;
free
(
playlist
.
position
ToId
);
playlist
.
position
ToId
=
NULL
;
}
int
clearPlaylist
(
FILE
*
fp
)
{
...
...
@@ -222,7 +222,7 @@ int clearPlaylist(FILE * fp) {
if
(
playlist
.
songs
[
i
]
->
type
==
SONG_TYPE_URL
)
{
freeJustSong
(
playlist
.
songs
[
i
]);
}
playlist
.
idTo
Num
[
playlist
.
num
ToId
[
i
]]
=
-
1
;
playlist
.
idTo
Position
[
playlist
.
position
ToId
[
i
]]
=
-
1
;
playlist
.
songs
[
i
]
=
NULL
;
}
playlist
.
length
=
0
;
...
...
@@ -425,7 +425,7 @@ void printPlaylistSongInfo(FILE * fp, int song) {
printMpdTag
(
fp
,
tag
);
}
myfprintf
(
fp
,
"Pos: %i
\n
"
,
song
);
myfprintf
(
fp
,
"Id: %i
\n
"
,
playlist
.
num
ToId
[
song
]);
myfprintf
(
fp
,
"Id: %i
\n
"
,
playlist
.
position
ToId
[
song
]);
}
int
playlistChanges
(
FILE
*
fp
,
mpd_uint32
version
)
{
...
...
@@ -465,7 +465,7 @@ int playlistInfo(FILE * fp, int song) {
# define checkSongId(id) { \
if(id < 0 || id >= PLAYLIST_HASH_MULT*playlist_max_length || \
playlist.idTo
Num
[id] == -1 ) \
playlist.idTo
Position
[id] == -1 ) \
{ \
commandError(fp, ACK_ERROR_NO_EXIST, \
"song id doesn't exist: \"%i\"", id); \
...
...
@@ -480,7 +480,7 @@ int playlistId(FILE * fp, int id) {
if
(
id
>=
0
)
{
checkSongId
(
id
);
begin
=
playlist
.
idTo
Num
[
id
];
begin
=
playlist
.
idTo
Position
[
id
];
end
=
begin
+
1
;
}
...
...
@@ -500,12 +500,12 @@ void swapSongs(int song1, int song2) {
playlist
.
songMod
[
song1
]
=
playlist
.
version
;
playlist
.
songMod
[
song2
]
=
playlist
.
version
;
playlist
.
idTo
Num
[
playlist
.
num
ToId
[
song1
]]
=
song2
;
playlist
.
idTo
Num
[
playlist
.
num
ToId
[
song2
]]
=
song1
;
playlist
.
idTo
Position
[
playlist
.
position
ToId
[
song1
]]
=
song2
;
playlist
.
idTo
Position
[
playlist
.
position
ToId
[
song2
]]
=
song1
;
iTemp
=
playlist
.
num
ToId
[
song1
];
playlist
.
numToId
[
song1
]
=
playlist
.
num
ToId
[
song2
];
playlist
.
num
ToId
[
song2
]
=
iTemp
;
iTemp
=
playlist
.
position
ToId
[
song1
];
playlist
.
positionToId
[
song1
]
=
playlist
.
position
ToId
[
song2
];
playlist
.
position
ToId
[
song2
]
=
iTemp
;
}
void
queueNextSongInPlaylist
()
{
...
...
@@ -624,8 +624,8 @@ int addSongToPlaylist(FILE * fp, Song * song) {
playlist
.
songs
[
playlist
.
length
]
=
song
;
playlist
.
songMod
[
playlist
.
length
]
=
playlist
.
version
;
playlist
.
order
[
playlist
.
length
]
=
playlist
.
length
;
playlist
.
num
ToId
[
playlist
.
length
]
=
getNextId
();
playlist
.
idTo
Num
[
playlist
.
num
ToId
[
playlist
.
length
]]
=
playlist
.
length
;
playlist
.
position
ToId
[
playlist
.
length
]
=
getNextId
();
playlist
.
idTo
Position
[
playlist
.
position
ToId
[
playlist
.
length
]]
=
playlist
.
length
;
playlist
.
length
++
;
if
(
playlist
.
random
)
{
...
...
@@ -702,13 +702,13 @@ int swapSongsInPlaylistById(FILE * fp, int id1, int id2) {
checkSongId
(
id1
);
checkSongId
(
id2
);
return
swapSongsInPlaylist
(
fp
,
playlist
.
idTo
Num
[
id1
],
playlist
.
idTo
Num
[
id2
]);
return
swapSongsInPlaylist
(
fp
,
playlist
.
idTo
Position
[
id1
],
playlist
.
idTo
Position
[
id2
]);
}
#define moveSongFromTo(from, to) { \
playlist.idTo
Num[playlist.num
ToId[from]] = to; \
playlist.
numToId[to] = playlist.num
ToId[from]; \
playlist.idTo
Position[playlist.position
ToId[from]] = to; \
playlist.
positionToId[to] = playlist.position
ToId[from]; \
playlist.songs[to] = playlist.songs[from]; \
playlist.songMod[to] = playlist.version; \
}
...
...
@@ -737,7 +737,7 @@ int deleteFromPlaylist(FILE * fp, int song) {
freeJustSong
(
playlist
.
songs
[
song
]);
}
playlist
.
idTo
Num
[
playlist
.
num
ToId
[
song
]]
=
-
1
;
playlist
.
idTo
Position
[
playlist
.
position
ToId
[
song
]]
=
-
1
;
/* delete song from songs array */
for
(
i
=
song
;
i
<
playlist
.
length
-
1
;
i
++
)
{
...
...
@@ -784,7 +784,7 @@ int deleteFromPlaylist(FILE * fp, int song) {
int
deleteFromPlaylistById
(
FILE
*
fp
,
int
id
)
{
checkSongId
(
id
);
return
deleteFromPlaylist
(
fp
,
playlist
.
idTo
Num
[
id
]);
return
deleteFromPlaylist
(
fp
,
playlist
.
idTo
Position
[
id
]);
}
void
deleteASongFromPlaylist
(
Song
*
song
)
{
...
...
@@ -885,7 +885,7 @@ int playPlaylistById(FILE * fp, int id, int stopOnError) {
checkSongId
(
id
);
return
playPlaylist
(
fp
,
playlist
.
idTo
Num
[
id
],
stopOnError
);
return
playPlaylist
(
fp
,
playlist
.
idTo
Position
[
id
],
stopOnError
);
}
void
syncCurrentPlayerDecodeMetadata
()
{
...
...
@@ -1039,7 +1039,7 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
}
tmpSong
=
playlist
.
songs
[
from
];
tmpId
=
playlist
.
num
ToId
[
from
];
tmpId
=
playlist
.
position
ToId
[
from
];
/* move songs to one less in from->to */
for
(
i
=
from
;
i
<
to
;
i
++
)
{
moveSongFromTo
(
i
+
1
,
i
);
...
...
@@ -1049,8 +1049,8 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
moveSongFromTo
(
i
-
1
,
i
);
}
/* put song at _to_ */
playlist
.
idTo
Num
[
tmpId
]
=
to
;
playlist
.
num
ToId
[
to
]
=
tmpId
;
playlist
.
idTo
Position
[
tmpId
]
=
to
;
playlist
.
position
ToId
[
to
]
=
tmpId
;
playlist
.
songs
[
to
]
=
tmpSong
;
playlist
.
songMod
[
to
]
=
playlist
.
version
;
/* now deal with order */
...
...
@@ -1084,13 +1084,15 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
int
moveSongInPlaylistById
(
FILE
*
fp
,
int
id1
,
int
to
)
{
checkSongId
(
id1
);
return
moveSongInPlaylist
(
fp
,
playlist
.
idTo
Num
[
id1
],
to
);
return
moveSongInPlaylist
(
fp
,
playlist
.
idTo
Position
[
id1
],
to
);
}
void
orderPlaylist
()
{
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
.
queued
>=
0
)
{
...
...
@@ -1461,9 +1463,9 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
int
seekSongInPlaylistById
(
FILE
*
fp
,
int
id
,
float
time
)
{
checkSongId
(
id
);
return
seekSongInPlaylist
(
fp
,
playlist
.
idTo
Num
[
id
],
time
);
return
seekSongInPlaylist
(
fp
,
playlist
.
idTo
Position
[
id
],
time
);
}
int
getPlaylistSongId
(
int
song
)
{
return
playlist
.
num
ToId
[
song
];
return
playlist
.
position
ToId
[
song
];
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment