aboutsummaryrefslogtreecommitdiffstats
path: root/src/player.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-04-12 04:08:29 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:08:29 +0000
commitefa464235613c6f3bfd40179d3676dd913feeafe (patch)
treedd1399ff950fff7be918a0487da95896c2819868 /src/player.c
parentb3230404892539192be974e632c63a5d5548f735 (diff)
downloadmpd-efa464235613c6f3bfd40179d3676dd913feeafe.tar.gz
mpd-efa464235613c6f3bfd40179d3676dd913feeafe.tar.xz
mpd-efa464235613c6f3bfd40179d3676dd913feeafe.zip
Start using song pointers in core data structures
Instead of copying URLs everywhere... [merged r7186 from branches/ew] git-svn-id: https://svn.musicpd.org/mpd/trunk@7244 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/player.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/player.c b/src/player.c
index 109cbe936..f9aedcd20 100644
--- a/src/player.c
+++ b/src/player.c
@@ -121,7 +121,7 @@ static void set_current_song(Song *song)
PlayerControl *pc = &(getPlayerData()->playerControl);
pc->fileTime = song->tag ? song->tag->time : 0;
- get_song_url(pc->utf8url, song);
+ pc->current_song = song;
}
int playerPlay(int fd, Song * song)
@@ -222,43 +222,34 @@ int getPlayerError(void)
char *getPlayerErrorStr(void)
{
- static char *error;
- int errorlen = MPD_PATH_MAX + 1024;
+ /* static OK here, only one user in main task */
+ static char error[MPD_PATH_MAX + 64]; /* still too much */
+ static const size_t errorlen = sizeof(error);
+ char path_max_tmp[MPD_PATH_MAX];
PlayerControl *pc = &(getPlayerData()->playerControl);
-
- error = xrealloc(error, errorlen);
- error[0] = '\0';
+ *error = '\0'; /* likely */
switch (pc->error) {
case PLAYER_ERROR_FILENOTFOUND:
snprintf(error, errorlen,
"file \"%s\" does not exist or is inaccessible",
- pc->erroredUrl);
+ get_song_url(path_max_tmp, pc->errored_song));
break;
case PLAYER_ERROR_FILE:
snprintf(error, errorlen, "problems decoding \"%s\"",
- pc->erroredUrl);
+ get_song_url(path_max_tmp, pc->errored_song));
break;
case PLAYER_ERROR_AUDIO:
- snprintf(error, errorlen, "problems opening audio device");
+ strcpy(error, "problems opening audio device");
break;
case PLAYER_ERROR_SYSTEM:
- snprintf(error, errorlen, "system error occured");
+ strcpy(error, "system error occured");
break;
case PLAYER_ERROR_UNKTYPE:
- snprintf(error, errorlen, "file type of \"%s\" is unknown",
- pc->erroredUrl);
- default:
- break;
+ snprintf(error, errorlen, "file type of \"%s\" is unknown",
+ get_song_url(path_max_tmp, pc->errored_song));
}
-
- errorlen = strlen(error);
- error = xrealloc(error, errorlen + 1);
-
- if (errorlen)
- return error;
-
- return NULL;
+ return *error ? error : NULL;
}
static void playerCloseAudio(void)
@@ -321,7 +312,6 @@ void playerQueueUnlock(void)
int playerSeek(int fd, Song * song, float seek_time)
{
PlayerControl *pc = &(getPlayerData()->playerControl);
- char path_max_tmp[MPD_PATH_MAX];
assert(song != NULL);
@@ -331,7 +321,7 @@ int playerSeek(int fd, Song * song, float seek_time)
return -1;
}
- if (strcmp(pc->utf8url, get_song_url(path_max_tmp, song)) != 0)
+ if (pc->current_song != song)
set_current_song(song);
if (pc->error == PLAYER_ERROR_NOERROR) {