aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-16 19:11:39 +0200
committerMax Kellermann <max@duempel.org>2008-09-16 19:11:39 +0200
commit3ac0e9238308d8acea506fc95679fe8d5ae44f45 (patch)
tree189238754a1c09e66dcdd811efb32aef9c5dfe1a /src/playlist.c
parenta6858acfdead6285a010a31b1fc7c8a730e91788 (diff)
downloadmpd-3ac0e9238308d8acea506fc95679fe8d5ae44f45.tar.gz
mpd-3ac0e9238308d8acea506fc95679fe8d5ae44f45.tar.xz
mpd-3ac0e9238308d8acea506fc95679fe8d5ae44f45.zip
playlist: hide direct accesses in inline functions
Added functions like playlist_length(), playlist_get(), playlist_replace(), playlist_remove(). Don't access the mpdclient_playlist struct directly.
Diffstat (limited to '')
-rw-r--r--src/playlist.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/playlist.c b/src/playlist.c
index b600343d7..d14f870b0 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -44,7 +44,8 @@ playlist_clear(struct mpdclient_playlist *playlist)
guint i;
for (i = 0; i < playlist->list->len; ++i) {
- struct mpd_song *song = g_array_index(playlist->list, struct mpd_song *, i);
+ struct mpd_song *song = playlist_get(playlist, i);
+
mpd_freeSong(song);
}
@@ -69,7 +70,7 @@ playlist_get_song(mpdclient_t *c, gint idx)
if (idx < 0 || (guint)idx >= c->playlist.list->len)
return NULL;
- return g_array_index(c->playlist.list, struct mpd_song *, idx);
+ return playlist_get(&c->playlist, idx);
}
struct mpd_song *
@@ -78,8 +79,7 @@ playlist_lookup_song(mpdclient_t *c, gint id)
guint i;
for (i = 0; i < c->playlist.list->len; ++i) {
- struct mpd_song *song = g_array_index(c->playlist.list,
- struct mpd_song *, i);
+ struct mpd_song *song = playlist_get(&c->playlist, i);
if (song->id == id)
return song;
}
@@ -93,8 +93,7 @@ playlist_get_index(mpdclient_t *c, struct mpd_song *song)
guint i;
for (i = 0; i < c->playlist.list->len; ++i) {
- if (g_array_index(c->playlist.list, struct mpd_song *, i)
- == song)
+ if (playlist_get(&c->playlist, i) == song)
return (gint)i;
}
@@ -107,8 +106,7 @@ playlist_get_index_from_id(mpdclient_t *c, gint id)
guint i;
for (i = 0; i < c->playlist.list->len; ++i) {
- struct mpd_song *song = g_array_index(c->playlist.list,
- struct mpd_song *, i);
+ struct mpd_song *song = playlist_get(&c->playlist, i);
if (song->id == id)
return (gint)i;
}
@@ -122,8 +120,7 @@ playlist_get_index_from_file(mpdclient_t *c, gchar *filename)
guint i;
for (i = 0; i < c->playlist.list->len; ++i) {
- struct mpd_song *song = g_array_index(c->playlist.list,
- struct mpd_song *, i);
+ struct mpd_song *song = playlist_get(&c->playlist, i);
if(strcmp(song->file, filename) == 0)
return (gint)i;
}