From: Max Kellermann Date: Fri, 12 Dec 2008 18:59:40 +0000 (+0100) Subject: lyrics: return plugin_cycle struct X-Git-Tag: release-0.13~66 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=df9c61571a6f18bf410bab23d442cfc85cbced17;p=ncmpc.git lyrics: return plugin_cycle struct Eliminated the lyrics_loader struct. Instead of lyrics_free(), callers should use plugin_stop(). --- diff --git a/src/lyrics.c b/src/lyrics.c index 052af4e..1b33542 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 d8bbe73..ca83198 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 e5635bd..b59f6bd 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; }