aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-12-12 19:59:40 +0100
committerMax Kellermann <max@duempel.org>2008-12-12 19:59:40 +0100
commitdf9c61571a6f18bf410bab23d442cfc85cbced17 (patch)
tree9162d29467145f924586f7054affa617432e787c
parent196c22ca88fbe005aba1fdf6dffe2343231757eb (diff)
downloadmpd-df9c61571a6f18bf410bab23d442cfc85cbced17.tar.gz
mpd-df9c61571a6f18bf410bab23d442cfc85cbced17.tar.xz
mpd-df9c61571a6f18bf410bab23d442cfc85cbced17.zip
lyrics: return plugin_cycle struct
Eliminated the lyrics_loader struct. Instead of lyrics_free(), callers should use plugin_stop().
-rw-r--r--src/lyrics.c19
-rw-r--r--src/lyrics.h7
-rw-r--r--src/screen_lyrics.c6
3 files changed, 6 insertions, 26 deletions
diff --git a/src/lyrics.c b/src/lyrics.c
index 052af4e8a..1b33542d4 100644
--- a/src/lyrics.c
+++ b/src/lyrics.c
@@ -23,10 +23,6 @@
static struct plugin_list plugins;
-struct lyrics_loader {
- struct plugin_cycle *plugin;
-};
-
void lyrics_init(void)
{
plugin_list_init(&plugins);
@@ -38,25 +34,14 @@ void lyrics_deinit(void)
plugin_list_deinit(&plugins);
}
-struct lyrics_loader *
+struct plugin_cycle *
lyrics_load(const char *artist, const char *title,
plugin_callback_t callback, void *data)
{
- struct lyrics_loader *loader = g_new(struct lyrics_loader, 1);
const char *args[3] = { artist, title, NULL };
assert(artist != NULL);
assert(title != NULL);
- loader->plugin = plugin_run(&plugins, args,
- callback, data);
-
- return loader;
-}
-
-void
-lyrics_free(struct lyrics_loader *loader)
-{
- plugin_stop(loader->plugin);
- g_free(loader);
+ return plugin_run(&plugins, args, callback, data);
}
diff --git a/src/lyrics.h b/src/lyrics.h
index d8bbe734d..ca831982e 100644
--- a/src/lyrics.h
+++ b/src/lyrics.h
@@ -21,17 +21,12 @@
#include "plugin.h"
-struct lyrics_loader;
-
void lyrics_init(void);
void lyrics_deinit(void);
-struct lyrics_loader *
+struct plugin_cycle *
lyrics_load(const char *artist, const char *title,
plugin_callback_t callback, void *callback_data);
-void
-lyrics_free(struct lyrics_loader *loader);
-
#endif
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index e5635bd32..b59f6bdfb 100644
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
@@ -44,7 +44,7 @@ static struct {
char *artist, *title;
- struct lyrics_loader *loader;
+ struct plugin_cycle *loader;
GPtrArray *lines;
} current;
@@ -53,7 +53,7 @@ static void
screen_lyrics_abort(void)
{
if (current.loader != NULL) {
- lyrics_free(current.loader);
+ plugin_stop(current.loader);
current.loader = NULL;
}
@@ -165,7 +165,7 @@ screen_lyrics_callback(const GString *result, G_GNUC_UNUSED void *data)
else
screen_status_message (_("No lyrics"));
- lyrics_free(current.loader);
+ plugin_stop(current.loader);
current.loader = NULL;
}