summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0947e90)
raw | patch | inline | side by side (parent: 0947e90)
author | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 20:14:20 +0000 (22:14 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 20:14:20 +0000 (22:14 +0200) |
And return const mpd_song objects.
src/main.c | patch | blob | history | |
src/mpdclient.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history | |
src/playlist.c | patch | blob | history | |
src/playlist.h | patch | blob | history | |
src/screen_lyrics.c | patch | blob | history |
diff --git a/src/main.c b/src/main.c
index 10706a55456b5e4dfc914d7c1dca3bbfcbe2b57d..fb5de59652f7eaed0ec40888ebbaffd37f0d7897 100644 (file)
--- a/src/main.c
+++ b/src/main.c
static char title[BUFSIZE];
char tmp[BUFSIZE];
struct mpd_status *status = NULL;
- struct mpd_song *song = NULL;
+ const struct mpd_song *song = NULL;
if (mpd) {
status = mpd->status;
diff --git a/src/mpdclient.c b/src/mpdclient.c
index ac7fce93d045b16540a6b8f309b88f30cc18994c..cbc6a91fb0cc77d991aafd3858a4d329b1404588 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
gint
mpdclient_cmd_play(struct mpdclient *c, gint idx)
{
- struct mpd_song *song = playlist_get_song(&c->playlist, idx);
+ const struct mpd_song *song = playlist_get_song(&c->playlist, idx);
if (MPD_ERROR(c))
return -1;
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 52fcdb45eb9be8030abbb5e0300ecadc412f649f..e2b81c8212b9cb7d8789893b8003fd16320862ef 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
struct mpd_connection *connection;
struct mpd_status *status;
- struct mpd_song *song;
+ const struct mpd_song *song;
int volume;
unsigned updatingdb;
diff --git a/src/playlist.c b/src/playlist.c
index 562fde69e7b40932b8a1d98740578e9ff30e1886..5fced75f0c7c1041eb7d7280fb5a1e8f34676c62 100644 (file)
--- a/src/playlist.c
+++ b/src/playlist.c
return 0;
}
-struct mpd_song *
-playlist_get_song(struct mpdclient_playlist *playlist, gint idx)
+const struct mpd_song *
+playlist_get_song(const struct mpdclient_playlist *playlist, gint idx)
{
if (idx < 0 || (guint)idx >= playlist_length(playlist))
return NULL;
return playlist_get(playlist, idx);
}
-struct mpd_song *
-playlist_lookup_song(struct mpdclient_playlist *playlist, unsigned id)
+const struct mpd_song *
+playlist_lookup_song(const struct mpdclient_playlist *playlist, unsigned id)
{
for (guint i = 0; i < playlist_length(playlist); ++i) {
struct mpd_song *song = playlist_get(playlist, i);
diff --git a/src/playlist.h b/src/playlist.h
index 580b1c98069d8fca9809c6cc5da1a35daf0a4644..cee91002f840f288d92602888958896fa7b549de 100644 (file)
--- a/src/playlist.h
+++ b/src/playlist.h
g_ptr_array_index(playlist->list, idx2) = song1;
}
-struct mpd_song *
-playlist_lookup_song(struct mpdclient_playlist *playlist, unsigned id);
+const struct mpd_song *
+playlist_lookup_song(const struct mpdclient_playlist *playlist, unsigned id);
-struct mpd_song *
-playlist_get_song(struct mpdclient_playlist *playlist, gint index);
+const struct mpd_song *
+playlist_get_song(const struct mpdclient_playlist *playlist, gint index);
gint
playlist_get_index(const struct mpdclient_playlist *playlist,
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index f9fdb81b643f76cab222c7a4d72b4005d9e483cc..abf1055661e827c8577c66bd65f2a9141873e97d 100644 (file)
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
static void
lyrics_open(struct mpdclient *c)
{
- if (next_song == NULL)
- next_song = c->song;
+ const struct mpd_song *next_song_c =
+ next_song != NULL ? next_song : c->song;
- if (next_song != NULL &&
+ if (next_song_c != NULL &&
(current.song == NULL ||
- strcmp(mpd_song_get_uri(next_song),
+ strcmp(mpd_song_get_uri(next_song_c),
mpd_song_get_uri(current.song)) != 0))
- screen_lyrics_load(next_song);
+ screen_lyrics_load(next_song_c);
- if (next_song != c->song)
+ if (next_song != NULL)
mpd_song_free(next_song);
next_song = NULL;
}
if (!follow)
return;
- next_song = c->song;
-
- if (next_song != NULL &&
+ if (c->song != NULL &&
(current.song == NULL ||
- strcmp(mpd_song_get_uri(next_song),
+ strcmp(mpd_song_get_uri(c->song),
mpd_song_get_uri(current.song)) != 0))
- screen_lyrics_load(next_song);
-
- next_song = NULL;
+ screen_lyrics_load(c->song);
}
static const char *