summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eddd033)
raw | patch | inline | side by side (parent: eddd033)
author | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 20:11:23 +0000 (22:11 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 20:11:23 +0000 (22:11 +0200) |
Passing a mpdclient object doesn't make sense in this library.
src/mpdclient.c | patch | blob | history | |
src/playlist.c | patch | blob | history | |
src/playlist.h | patch | blob | history | |
src/screen_browser.c | patch | blob | history | |
src/screen_play.c | patch | blob | history |
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 933a14874772a6890e7cf8b44dde5407c4ebe6c4..ac7fce93d045b16540a6b8f309b88f30cc18994c 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
/* update the current song */
if (!c->song || mpd_status_get_song_id(c->status)) {
- c->song = playlist_get_song(c, mpd_status_get_song_pos(c->status));
+ c->song = playlist_get_song(&c->playlist,
+ mpd_status_get_song_pos(c->status));
}
return retval;
gint
mpdclient_cmd_play(struct mpdclient *c, gint idx)
{
- struct mpd_song *song = playlist_get_song(c, idx);
+ struct mpd_song *song = playlist_get_song(&c->playlist, idx);
if (MPD_ERROR(c))
return -1;
diff --git a/src/playlist.c b/src/playlist.c
index 713d3c69fc4b7902c17a45b32d1dc152778f8a00..562fde69e7b40932b8a1d98740578e9ff30e1886 100644 (file)
--- a/src/playlist.c
+++ b/src/playlist.c
*/
#include "playlist.h"
-#include "mpdclient.h"
#include <string.h>
}
struct mpd_song *
-playlist_get_song(struct mpdclient *c, gint idx)
+playlist_get_song(struct mpdclient_playlist *playlist, gint idx)
{
- if (idx < 0 || (guint)idx >= c->playlist.list->len)
+ if (idx < 0 || (guint)idx >= playlist_length(playlist))
return NULL;
- return playlist_get(&c->playlist, idx);
+ return playlist_get(playlist, idx);
}
struct mpd_song *
-playlist_lookup_song(struct mpdclient *c, unsigned id)
+playlist_lookup_song(struct mpdclient_playlist *playlist, unsigned id)
{
- guint i;
-
- for (i = 0; i < c->playlist.list->len; ++i) {
- struct mpd_song *song = playlist_get(&c->playlist, i);
+ for (guint i = 0; i < playlist_length(playlist); ++i) {
+ struct mpd_song *song = playlist_get(playlist, i);
if (mpd_song_get_id(song) == id)
return song;
}
}
gint
-playlist_get_index(const struct mpdclient *c, const struct mpd_song *song)
+playlist_get_index(const struct mpdclient_playlist *playlist,
+ const struct mpd_song *song)
{
- guint i;
-
- for (i = 0; i < c->playlist.list->len; ++i) {
- if (playlist_get(&c->playlist, i) == song)
+ for (guint i = 0; i < playlist_length(playlist); ++i) {
+ if (playlist_get(playlist, i) == song)
return (gint)i;
}
}
gint
-playlist_get_index_from_id(const struct mpdclient *c, unsigned id)
+playlist_get_index_from_id(const struct mpdclient_playlist *playlist,
+ unsigned id)
{
- guint i;
-
- for (i = 0; i < c->playlist.list->len; ++i) {
- const struct mpd_song *song = playlist_get(&c->playlist, i);
+ for (guint i = 0; i < playlist_length(playlist); ++i) {
+ const struct mpd_song *song = playlist_get(playlist, i);
if (mpd_song_get_id(song) == id)
return (gint)i;
}
}
gint
-playlist_get_index_from_file(const struct mpdclient *c, const gchar *filename)
+playlist_get_index_from_file(const struct mpdclient_playlist *playlist,
+ const gchar *filename)
{
- guint i;
-
- for (i = 0; i < c->playlist.list->len; ++i) {
- const struct mpd_song *song = playlist_get(&c->playlist, i);
+ for (guint i = 0; i < playlist_length(playlist); ++i) {
+ const struct mpd_song *song = playlist_get(playlist, i);
if (strcmp(mpd_song_get_uri(song), filename) == 0)
return (gint)i;
diff --git a/src/playlist.h b/src/playlist.h
index b94893681aff5af70b7586fabdd452577d05cc04..580b1c98069d8fca9809c6cc5da1a35daf0a4644 100644 (file)
--- a/src/playlist.h
+++ b/src/playlist.h
#include <assert.h>
#include <glib.h>
-struct mpdclient;
-
struct mpdclient_playlist {
/* playlist id */
unsigned id;
g_ptr_array_index(playlist->list, idx2) = song1;
}
-struct mpd_song *playlist_lookup_song(struct mpdclient *c, unsigned id);
+struct mpd_song *
+playlist_lookup_song(struct mpdclient_playlist *playlist, unsigned id);
-struct mpd_song *playlist_get_song(struct mpdclient *c, gint index);
+struct mpd_song *
+playlist_get_song(struct mpdclient_playlist *playlist, gint index);
gint
-playlist_get_index(const struct mpdclient *c, const struct mpd_song *song);
+playlist_get_index(const struct mpdclient_playlist *playlist,
+ const struct mpd_song *song);
gint
-playlist_get_index_from_id(const struct mpdclient *c, unsigned id);
+playlist_get_index_from_id(const struct mpdclient_playlist *playlist,
+ unsigned id);
gint
-playlist_get_index_from_file(const struct mpdclient *c, const gchar *filename);
+playlist_get_index_from_file(const struct mpdclient_playlist *playlist,
+ const gchar *filename);
static inline gint
-playlist_get_index_from_same_song(const struct mpdclient *c,
+playlist_get_index_from_same_song(const struct mpdclient_playlist *playlist,
const struct mpd_song *song)
{
- return playlist_get_index_from_file(c, mpd_song_get_uri(song));
+ return playlist_get_index_from_file(playlist, mpd_song_get_uri(song));
}
#endif
diff --git a/src/screen_browser.c b/src/screen_browser.c
index efa2a387de144d43df5f94e1681a75cb51005ec5..3b80bdbccdb9343224bad7a6ab2e027cbe15bb4b 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
const struct mpd_song *song =
mpd_entity_get_song(entity);
- if (playlist_get_index_from_same_song(c, song) >= 0)
+ if (playlist_get_index_from_same_song(&c->playlist,
+ song) >= 0)
entry->flags |= HIGHLIGHT;
else
entry->flags &= ~HIGHLIGHT;
}
#endif
- idx = playlist_get_index_from_same_song(c, song);
+ idx = playlist_get_index_from_same_song(&c->playlist, song);
mpdclient_cmd_play(c, idx);
return true;
}
entry->flags &= ~HIGHLIGHT;
- while ((idx = playlist_get_index_from_same_song(c, song)) >= 0)
+ while ((idx = playlist_get_index_from_same_song(&c->playlist,
+ song)) >= 0)
mpdclient_cmd_delete(c, idx);
#endif
}
diff --git a/src/screen_play.c b/src/screen_play.c
index ed17499164d0f5bca8a4636e5372129127ab4d8d..6872b139110b9e9741001351d7d0a1842e3868bb 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
return;
/* try to center the song that are playing */
- idx = playlist_get_index(c, c->song);
+ idx = playlist_get_index(&c->playlist, c->song);
if (idx < 0)
return;
playlist_repaint();
return false;
case CMD_SELECT_PLAYING:
- list_window_set_selected(lw, playlist_get_index(c, c->song));
+ list_window_set_selected(lw, playlist_get_index(&c->playlist,
+ c->song));
return true;
case CMD_SHUFFLE:
{