aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-12-28 02:56:25 +0000
committerEric Wong <normalperson@yhbt.net>2007-12-28 02:56:25 +0000
commitb79f6b882a70526ec2e9fc231e0baeebdfef1e52 (patch)
tree719912135d059476070834c3c62ae940955e9e20 /src/playlist.c
parent0d26248a0d8cb2e5cf6be5a438a18b16793bbb63 (diff)
downloadmpd-b79f6b882a70526ec2e9fc231e0baeebdfef1e52.tar.gz
mpd-b79f6b882a70526ec2e9fc231e0baeebdfef1e52.tar.xz
mpd-b79f6b882a70526ec2e9fc231e0baeebdfef1e52.zip
Merge branches/ew r7104
thread-safety work in preparation for rewrite to use pthreads Expect no regressions against trunk (r7078), possibly minor performance improvements in update (due to fewer heap allocations), but increased stack usage. Applied the following patches: * maxpath_str for reentrancy (temporary fix, reverted) * path: start working on thread-safe variants of these methods * Re-entrancy work on path/character-set conversions * directory.c: exploreDirectory() use reentrant functions here * directory/update: more use of reentrant functions + cleanups * string_toupper: a strdup-less version of strDupToUpper * get_song_url: a static-variable-free version of getSongUrl() * Use reentrant/thread-safe get_song_url everywhere * replace rmp2amp with the reentrant version, rmp2amp_r * Get rid of the non-reentrant/non-thread-safe rpp2app, too. * buffer2array: assert strdup() returns a usable value in unit tests * replace utf8ToFsCharset and fsCharsetToUtf8 with thread-safe variants * fix storing playlists w/o absolute paths * parent_path(), a reentrant version of parentPath() * parentPath => parent_path for reentrancy and thread-safety * allow "make test" to automatically run embedded unit tests * remove convStrDup() and maxpath_str() * use MPD_PATH_MAX everywhere instead of MAXPATHLEN * path: get rid of appendSlash, pfx_path and just use pfx_dir * get_song_url: fix the ability to play songs in the top-level music_directory git-svn-id: https://svn.musicpd.org/mpd/trunk@7106 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/playlist.c')
-rw-r--r--src/playlist.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/playlist.c b/src/playlist.c
index ce2748930..6d47bdb8f 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -56,7 +56,7 @@
#define PLAYLIST_STATE_FILE_STATE_PAUSE "pause"
#define PLAYLIST_STATE_FILE_STATE_STOP "stop"
-#define PLAYLIST_BUFFER_SIZE 2*MAXPATHLEN
+#define PLAYLIST_BUFFER_SIZE 2*MPD_PATH_MAX
#define PLAYLIST_HASH_MULT 4
@@ -244,9 +244,11 @@ int clearStoredPlaylist(int fd, char *utf8file)
int showPlaylist(int fd)
{
int i;
+ char path_max_tmp[MPD_PATH_MAX];
for (i = 0; i < playlist.length; i++) {
- fdprintf(fd, "%i:%s\n", i, getSongUrl(playlist.songs[i]));
+ fdprintf(fd, "%i:%s\n", i,
+ get_song_url(path_max_tmp, playlist.songs[i]));
}
return 0;
@@ -499,6 +501,8 @@ static void swapSongs(int song1, int song2)
static void queueNextSongInPlaylist(void)
{
+ char path_max_tmp[MPD_PATH_MAX];
+
if (playlistQueue->numberOfNodes != 0) {
int i;
/* we need to find where in order[] is first song from queue */
@@ -511,8 +515,9 @@ static void queueNextSongInPlaylist(void)
playlist.queued = i;
DEBUG("playlist: queue song %i:\"%s\"\n",
playlist.queued,
- getSongUrl(playlist.
- songs[playlist.order[playlist.queued]]));
+ get_song_url(path_max_tmp,
+ playlist.
+ songs[playlist.order[playlist.queued]]));
if (queueSong(playlist.songs[playlist.order[playlist.queued]]) <
0) {
@@ -524,8 +529,9 @@ static void queueNextSongInPlaylist(void)
playlist.queued = playlist.current + 1;
DEBUG("playlist: queue song %i:\"%s\"\n",
playlist.queued,
- getSongUrl(playlist.
- songs[playlist.order[playlist.queued]]));
+ get_song_url(path_max_tmp,
+ playlist.
+ songs[playlist.order[playlist.queued]]));
if (queueSong(playlist.songs[playlist.order[playlist.queued]]) <
0) {
playlist.queued = -1;
@@ -539,8 +545,9 @@ static void queueNextSongInPlaylist(void)
playlist.queued = 0;
DEBUG("playlist: queue song %i:\"%s\"\n",
playlist.queued,
- getSongUrl(playlist.
- songs[playlist.order[playlist.queued]]));
+ get_song_url(path_max_tmp,
+ playlist.
+ songs[playlist.order[playlist.queued]]));
if (queueSong(playlist.songs[playlist.order[playlist.queued]]) <
0) {
playlist.queued = -1;
@@ -897,6 +904,8 @@ int stopPlaylist(int fd)
static int playPlaylistOrderNumber(int fd, int orderNum)
{
+ char path_max_tmp[MPD_PATH_MAX];
+
if (playerStop(fd) < 0)
return -1;
@@ -906,7 +915,8 @@ static int playPlaylistOrderNumber(int fd, int orderNum)
playlist_queueError = 0;
DEBUG("playlist: play %i:\"%s\"\n", orderNum,
- getSongUrl(playlist.songs[playlist.order[orderNum]]));
+ get_song_url(path_max_tmp,
+ playlist.songs[playlist.order[orderNum]]));
if (playerPlay(fd, (playlist.songs[playlist.order[orderNum]])) < 0) {
stopPlaylist(fd);
@@ -1003,6 +1013,7 @@ static void syncCurrentPlayerDecodeMetadata(void)
Song *songPlayer = playerCurrentDecodeSong();
Song *song;
int songNum;
+ char path_max_tmp[MPD_PATH_MAX];
if (!songPlayer)
return;
@@ -1014,7 +1025,7 @@ static void syncCurrentPlayerDecodeMetadata(void)
song = playlist.songs[songNum];
if (song->type == SONG_TYPE_URL &&
- 0 == strcmp(getSongUrl(song), songPlayer->url) &&
+ 0 == strcmp(get_song_url(path_max_tmp, song), songPlayer->url) &&
!mpdTagsAreEqual(song->tag, songPlayer->tag)) {
if (song->tag)
freeMpdTag(song->tag);
@@ -1376,16 +1387,18 @@ int shufflePlaylist(int fd)
int deletePlaylist(int fd, char *utf8file)
{
- char *file = utf8ToFsCharset(utf8file);
+ char path_max_tmp[MPD_PATH_MAX];
+ char *file = utf8_to_fs_charset(path_max_tmp, utf8file);
char *rfile = xmalloc(strlen(file) + strlen(".") +
- strlen(PLAYLIST_FILE_SUFFIX) + 1);
+ strlen(PLAYLIST_FILE_SUFFIX) + 1);
char *actualFile;
strcpy(rfile, file);
strcat(rfile, ".");
strcat(rfile, PLAYLIST_FILE_SUFFIX);
- if ((actualFile = rpp2app(rfile)) && isPlaylist(actualFile))
+ actualFile = rpp2app_r(path_max_tmp, rfile);
+ if (isPlaylist(actualFile))
free(rfile);
else {
free(rfile);