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
c2c34f78
Commit
c2c34f78
authored
Jun 05, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new command, plchanges, and also add Num: to songinfo of playlistinfo
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1339
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
744c0fa2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
137 additions
and
66 deletions
+137
-66
TODO
TODO
+6
-11
command.c
src/command.c
+48
-32
command.h
src/command.h
+1
-1
conf.c
src/conf.c
+1
-1
directory.c
src/directory.c
+1
-1
playlist.c
src/playlist.c
+75
-18
playlist.h
src/playlist.h
+4
-1
sig_handlers.c
src/sig_handlers.c
+1
-1
No files found.
TODO
View file @
c2c34f78
1)
add song# to metadata when printing songs
1)
Parse icymetadata
2) add updated songs command, to output list of updated songs:
updatesongs <since-playlist-version>
2) Put a new metadata entry for icyName for Song's
3) Parse icymetadata
4) Put a new metadata entry for icyName for Song's
5) Add a list_OK options for command_lists, to get a list_OK after each
3) Add a list_OK options for command_lists, to get a list_OK after each
command
6
) put some sort of error reporting for streaming/inputStream!
4
) put some sort of error reporting for streaming/inputStream!
7
) Fix charset errors so they don't goto stderr/out
5
) Fix charset errors so they don't goto stderr/out
8
) Add a timeout for streams (how long? 1 minutes?)
6
) Add a timeout for streams (how long? 1 minutes?)
Post-1.0
...
...
src/command.c
View file @
c2c34f78
...
...
@@ -37,43 +37,44 @@
#include <string.h>
#include <unistd.h>
#define COMMAND_PLAY
"play"
#define COMMAND_STOP
"stop"
#define COMMAND_PAUSE
"pause"
#define COMMAND_STATUS
"status"
#define COMMAND_KILL
"kill"
#define COMMAND_CLOSE
"close"
#define COMMAND_ADD
"add"
#define COMMAND_DELETE
"delete"
#define COMMAND_PLAYLIST
"playlist"
#define COMMAND_SHUFFLE
"shuffle"
#define COMMAND_CLEAR
"clear"
#define COMMAND_SAVE
"save"
#define COMMAND_LOAD
"load"
#define COMMAND_LSINFO
"lsinfo"
#define COMMAND_RM
"rm"
#define COMMAND_PLAYLISTINFO
"playlistinfo"
#define COMMAND_FIND
"find"
#define COMMAND_SEARCH
"search"
#define COMMAND_UPDATE
"update"
#define COMMAND_NEXT
"next"
#define COMMAND_PREVIOUS
"previous"
#define COMMAND_LISTALL
"listall"
#define COMMAND_VOLUME
"volume"
#define COMMAND_REPEAT
"repeat"
#define COMMAND_RANDOM
"random"
#define COMMAND_STATS
"stats"
#define COMMAND_CLEAR_ERROR
"clearerror"
#define COMMAND_LIST
"list"
#define COMMAND_MOVE
"move"
#define COMMAND_SWAP
"swap"
#define COMMAND_SEEK
"seek"
#define COMMAND_PLAY
"play"
#define COMMAND_STOP
"stop"
#define COMMAND_PAUSE
"pause"
#define COMMAND_STATUS
"status"
#define COMMAND_KILL
"kill"
#define COMMAND_CLOSE
"close"
#define COMMAND_ADD
"add"
#define COMMAND_DELETE
"delete"
#define COMMAND_PLAYLIST
"playlist"
#define COMMAND_SHUFFLE
"shuffle"
#define COMMAND_CLEAR
"clear"
#define COMMAND_SAVE
"save"
#define COMMAND_LOAD
"load"
#define COMMAND_LSINFO
"lsinfo"
#define COMMAND_RM
"rm"
#define COMMAND_PLAYLISTINFO
"playlistinfo"
#define COMMAND_FIND
"find"
#define COMMAND_SEARCH
"search"
#define COMMAND_UPDATE
"update"
#define COMMAND_NEXT
"next"
#define COMMAND_PREVIOUS
"previous"
#define COMMAND_LISTALL
"listall"
#define COMMAND_VOLUME
"volume"
#define COMMAND_REPEAT
"repeat"
#define COMMAND_RANDOM
"random"
#define COMMAND_STATS
"stats"
#define COMMAND_CLEAR_ERROR
"clearerror"
#define COMMAND_LIST
"list"
#define COMMAND_MOVE
"move"
#define COMMAND_SWAP
"swap"
#define COMMAND_SEEK
"seek"
#define COMMAND_LISTALLINFO "listallinfo"
#define COMMAND_PING "ping"
#define COMMAND_SETVOL "setvol"
#define COMMAND_PASSWORD "password"
#define COMMAND_CROSSFADE "crossfade"
#define COMMAND_URL_HANDLERS "urlhandlers"
#define COMMAND_URL_HANDLERS "urlhandlers"
#define COMMAND_PLCHANGES "plchanges"
#define COMMAND_STATUS_VOLUME "volume"
#define COMMAND_STATUS_STATE "state"
...
...
@@ -322,6 +323,20 @@ int handleRm(FILE * fp, unsigned int * permission, int argArrayLength,
return
deletePlaylist
(
fp
,
argArray
[
1
]);
}
int
handlePlaylistChanges
(
FILE
*
fp
,
unsigned
int
*
permission
,
int
argArrayLength
,
char
**
argArray
)
{
unsigned
long
version
;
char
*
test
;
version
=
strtoul
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
commandError
(
fp
,
ACK_ERROR_ARG
,
"need a positive integer"
);
return
-
1
;
}
return
playlistChanges
(
fp
,
version
);
}
int
handlePlaylistInfo
(
FILE
*
fp
,
unsigned
int
*
permission
,
int
argArrayLength
,
char
**
argArray
)
{
...
...
@@ -641,6 +656,7 @@ void initCommands() {
addCommand
(
COMMAND_PASSWORD
,
0
,
1
,
1
,
handlePassword
,
NULL
);
addCommand
(
COMMAND_CROSSFADE
,
PERMISSION_CONTROL
,
1
,
1
,
handleCrossfade
,
NULL
);
addCommand
(
COMMAND_URL_HANDLERS
,
PERMISSION_READ
,
0
,
0
,
handleUrlHandlers
,
NULL
);
addCommand
(
COMMAND_PLCHANGES
,
PERMISSION_READ
,
1
,
1
,
handlePlaylistChanges
,
NULL
);
sortList
(
commandList
);
}
...
...
src/command.h
View file @
c2c34f78
...
...
@@ -54,7 +54,7 @@ void finishCommands();
current_command = NULL; \
} \
else { \
myfprintf(
fp
, "ACK [%i@%i] " format "\n", \
myfprintf(
stderr
, "ACK [%i@%i] " format "\n", \
(int)error, command_listNum, \
##__VA_ARGS__); \
} \
...
...
src/conf.c
View file @
c2c34f78
...
...
@@ -69,7 +69,7 @@
#endif
#endif
char
*
conf_params
[
CONF_NUMBER_OF_PARAMS
];
static
char
*
conf_params
[
CONF_NUMBER_OF_PARAMS
];
void
initConf
()
{
int
i
;
...
...
src/directory.c
View file @
c2c34f78
...
...
@@ -159,7 +159,7 @@ void readDirectoryDBIfUpdateIsFinished() {
if
(
directory_reReadDB
&&
0
==
directory_updatePid
)
{
DEBUG
(
"readDirectoryDB since update finished successfully
\n
"
);
readDirectoryDB
();
incrPlaylistVersion
();
playlistVersionChange
();
directory_reReadDB
=
0
;
}
}
...
...
src/playlist.c
View file @
c2c34f78
...
...
@@ -36,8 +36,6 @@
#include <unistd.h>
#include <time.h>
#define BITS_FOR_VERSION 31
#define PLAYLIST_COMMENT '#'
#define PLAYLIST_STATE_STOP 0
...
...
@@ -62,13 +60,15 @@
typedef
struct
_Playlist
{
Song
**
songs
;
/* holds version a song was modified on */
mpd_uint32
*
songMod
;
int
*
order
;
int
length
;
int
current
;
int
queued
;
int
repeat
;
int
random
;
unsigned
long
version
;
mpd_uint32
version
;
}
Playlist
;
static
Playlist
playlist
;
...
...
@@ -87,10 +87,28 @@ static void swapOrder(int a, int b);
static
int
playPlaylistOrderNumber
(
FILE
*
fp
,
int
orderNum
);
static
void
randomizeOrder
(
int
start
,
int
end
);
void
incrPlaylistVersion
()
{
static
unsigned
long
max
=
((
unsigned
long
)
1
<<
BITS_FOR_VERSION
)
-
1
;
static
void
incrPlaylistVersion
()
{
static
unsigned
long
max
=
((
mpd_uint32
)
1
<<
31
)
-
1
;
playlist
.
version
++
;
if
(
playlist
.
version
>=
max
)
playlist
.
version
=
0
;
if
(
playlist
.
version
>=
max
)
{
int
i
;
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
playlist
.
songMod
[
i
]
=
0
;
}
playlist
.
version
=
1
;
}
}
void
playlistVersionChange
()
{
int
i
=
0
;
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
playlist
.
songMod
[
i
]
=
playlist
.
version
;
}
incrPlaylistVersion
();
}
static
void
incrPlaylistCurrent
()
{
...
...
@@ -108,7 +126,7 @@ void initPlaylist() {
playlist
.
length
=
0
;
playlist
.
repeat
=
0
;
playlist
.
version
=
0
;
playlist
.
version
=
1
;
playlist
.
random
=
0
;
playlist
.
queued
=
-
1
;
playlist
.
current
=
-
1
;
...
...
@@ -136,7 +154,8 @@ void initPlaylist() {
}
playlist
.
songs
=
malloc
(
sizeof
(
Song
*
)
*
playlist_max_length
);
playlist
.
order
=
malloc
(
sizeof
(
Song
*
)
*
playlist_max_length
);
playlist
.
songMod
=
malloc
(
sizeof
(
mpd_uint32
)
*
playlist_max_length
);
playlist
.
order
=
malloc
(
sizeof
(
int
)
*
playlist_max_length
);
memset
(
playlist
.
songs
,
0
,
sizeof
(
char
*
)
*
playlist_max_length
);
...
...
@@ -155,8 +174,13 @@ void finishPlaylist() {
freeJustSong
(
playlist
.
songs
[
i
]);
}
}
playlist
.
length
=
0
;
free
(
playlist
.
songs
);
playlist
.
songs
=
NULL
;
free
(
playlist
.
songMod
);
playlist
.
songMod
=
NULL
;
free
(
playlist
.
order
);
playlist
.
order
=
NULL
;
}
...
...
@@ -364,8 +388,32 @@ void readPlaylistState() {
}
}
int
playlistInfo
(
FILE
*
fp
,
int
song
)
{
void
printPlaylistSongInfo
(
FILE
*
fp
,
int
song
)
{
MpdTag
*
tag
;
myfprintf
(
fp
,
"file: %s
\n
"
,
(
playlist
.
songs
[
song
])
->
utf8url
);
if
((
tag
=
(
playlist
.
songs
[
song
])
->
tag
))
{
printMpdTag
(
fp
,
tag
);
}
myfprintf
(
fp
,
"Num: %i
\n
"
,
song
);
}
int
playlistChanges
(
FILE
*
fp
,
mpd_uint32
version
)
{
int
i
;
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
if
(
version
>
playlist
.
version
||
playlist
.
songMod
[
i
]
>=
version
||
playlist
.
songMod
[
i
]
==
0
)
{
printPlaylistSongInfo
(
fp
,
i
);
}
}
return
0
;
}
int
playlistInfo
(
FILE
*
fp
,
int
song
)
{
int
i
;
int
begin
=
0
;
int
end
=
playlist
.
length
;
...
...
@@ -380,12 +428,7 @@ int playlistInfo(FILE * fp,int song) {
return
-
1
;
}
for
(
i
=
begin
;
i
<
end
;
i
++
)
{
myfprintf
(
fp
,
"file: %s
\n
"
,(
playlist
.
songs
[
i
])
->
utf8url
);
if
((
tag
=
(
playlist
.
songs
[
i
])
->
tag
))
{
printMpdTag
(
fp
,
tag
);
}
}
for
(
i
=
begin
;
i
<
end
;
i
++
)
printPlaylistSongInfo
(
fp
,
i
);
return
0
;
}
...
...
@@ -396,6 +439,8 @@ void swapSongs(int song1, int song2) {
temp
=
playlist
.
songs
[
song1
];
playlist
.
songs
[
song1
]
=
playlist
.
songs
[
song2
];
playlist
.
songs
[
song2
]
=
temp
;
playlist
.
songMod
[
song1
]
=
playlist
.
version
;
playlist
.
songMod
[
song2
]
=
playlist
.
version
;
}
void
queueNextSongInPlaylist
()
{
...
...
@@ -512,6 +557,7 @@ int addSongToPlaylist(FILE * fp, Song * song) {
}
playlist
.
songs
[
playlist
.
length
]
=
song
;
playlist
.
songMod
[
playlist
.
length
]
=
playlist
.
version
;
playlist
.
order
[
playlist
.
length
]
=
playlist
.
length
;
playlist
.
length
++
;
...
...
@@ -613,6 +659,7 @@ int deleteFromPlaylist(FILE * fp, int song) {
/* delete song from songs array */
for
(
i
=
song
;
i
<
playlist
.
length
-
1
;
i
++
)
{
playlist
.
songs
[
i
]
=
playlist
.
songs
[
i
+
1
];
playlist
.
songMod
[
i
]
=
playlist
.
version
;
}
/* now find it in the order array */
for
(
i
=
0
;
i
<
playlist
.
length
-
1
;
i
++
)
{
...
...
@@ -746,12 +793,14 @@ int playPlaylist(FILE * fp, int song, int stopOnError) {
void
syncCurrentPlayerDecodeMetadata
()
{
Song
*
songPlayer
=
playerCurrentDecodeSong
();
Song
*
song
;
int
songNum
;
if
(
!
songPlayer
)
return
;
if
(
playlist_state
!=
PLAYLIST_STATE_PLAY
)
return
;
song
=
playlist
.
songs
[
playlist
.
order
[
playlist
.
current
]];
songNum
=
playlist
.
order
[
playlist
.
current
];
song
=
playlist
.
songs
[
songNum
];
if
(
song
->
type
==
SONG_TYPE_URL
&&
0
==
strcmp
(
song
->
utf8url
,
songPlayer
->
utf8url
)
&&
...
...
@@ -759,6 +808,7 @@ void syncCurrentPlayerDecodeMetadata() {
{
if
(
song
->
tag
)
freeMpdTag
(
song
->
tag
);
song
->
tag
=
mpdTagDup
(
songPlayer
->
tag
);
playlist
.
songMod
[
songNum
]
=
playlist
.
version
;
incrPlaylistVersion
();
}
}
...
...
@@ -891,11 +941,18 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
tmpSong
=
playlist
.
songs
[
from
];
/* move songs to one less in from->to */
for
(
i
=
from
;
i
<
to
;
i
++
)
playlist
.
songs
[
i
]
=
playlist
.
songs
[
i
+
1
];
for
(
i
=
from
;
i
<
to
;
i
++
)
{
playlist
.
songs
[
i
]
=
playlist
.
songs
[
i
+
1
];
playlist
.
songMod
[
i
]
=
playlist
.
version
;
}
/* move songs to one more in to->from */
for
(
i
=
from
;
i
>
to
;
i
--
)
playlist
.
songs
[
i
]
=
playlist
.
songs
[
i
-
1
];
for
(
i
=
from
;
i
>
to
;
i
--
)
{
playlist
.
songs
[
i
]
=
playlist
.
songs
[
i
-
1
];
playlist
.
songMod
[
i
]
=
playlist
.
version
;
}
/* put song at _to_ */
playlist
.
songs
[
to
]
=
tmpSong
;
playlist
.
songMod
[
to
]
=
playlist
.
version
;
/* now deal with order */
if
(
playlist
.
random
)
{
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
...
...
src/playlist.h
View file @
c2c34f78
...
...
@@ -22,6 +22,7 @@
#include "../config.h"
#include "song.h"
#include "mpd_types.h"
#include <stdio.h>
#include <sys/param.h>
...
...
@@ -93,7 +94,9 @@ void playPlaylistIfPlayerStopped();
int
seekSongInPlaylist
(
FILE
*
fp
,
int
song
,
float
time
);
void
incrPlaylistVersion
();
void
playlistVersionChange
();
int
playlistChanges
(
FILE
*
fp
,
mpd_uint32
version
);
#endif
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
src/sig_handlers.c
View file @
c2c34f78
...
...
@@ -44,7 +44,7 @@ int handlePendingSignals() {
signal_clear
(
SIGHUP
);
if
(
!
isUpdatingDB
())
{
readDirectoryDB
();
incrPlaylistVersion
();
playlistVersionChange
();
}
if
(
myfprintfCloseAndOpenLogFile
()
<
0
)
return
COMMAND_RETURN_KILL
;
playerCycleLogFiles
();
...
...
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