From b633f3fa0c33a20e82b94e9127b5a31ea0a206a0 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sat, 20 Dec 2014 12:05:22 -0500 Subject: [PATCH] gst: Update the "now playing" fields through the GST driver This lets me remove the on_track_loaded() callback function by handling this event directly. Signed-off-by: Anna Schumaker --- core/audio.cpp | 1 - core/callback.cpp | 2 -- gui/gst.cpp | 3 +++ gui/gui.cpp | 3 +-- include/core/callback.h | 7 ------- include/gui/ocarina.h | 1 + 6 files changed, 5 insertions(+), 12 deletions(-) diff --git a/core/audio.cpp b/core/audio.cpp index 31ac8cf3..b4e559bf 100644 --- a/core/audio.cpp +++ b/core/audio.cpp @@ -58,7 +58,6 @@ static void _load_track(Track *track, bool start_playback) return; cur_driver->load(track); - get_callbacks()->on_track_loaded(track); if (start_playback) audio :: play(); else diff --git a/core/callback.cpp b/core/callback.cpp index 1b4bf0c7..956457ec 100644 --- a/core/callback.cpp +++ b/core/callback.cpp @@ -8,11 +8,9 @@ static void no_op(bool, unsigned int) {} static void no_op(Queue *, unsigned int) {} static void no_op(Queue *) {} -static void no_op(Track *) {} static struct Callbacks callbacks = { - .on_track_loaded = no_op, .on_pause_count_changed = no_op, .on_pq_removed = no_op, diff --git a/gui/gst.cpp b/gui/gst.cpp index b92e2a2e..b7a2fae7 100644 --- a/gui/gst.cpp +++ b/gui/gst.cpp @@ -7,6 +7,7 @@ */ #include #include +#include #include @@ -37,6 +38,8 @@ public: gst_change_state(GST_STATE_NULL); g_object_set(G_OBJECT(gst_player), "uri", uri, NULL); g_free(uri); + + on_track_loaded(track); } bool play() { return gst_change_state(GST_STATE_PLAYING); } diff --git a/gui/gui.cpp b/gui/gui.cpp index 2f6177cd..fec0d712 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -37,7 +37,7 @@ static void set_label_text(Gtk::Label *label, const std::string &size, Glib::Markup::escape_text(text) + ""); } -static void on_track_loaded(Track *track) +void on_track_loaded(Track *track) { Gtk::ToggleButton *ban = lib :: get_widget("o_ban"); Gtk::ToggleButton *fav = lib :: get_widget("o_favorite"); @@ -114,7 +114,6 @@ Gtk::Window *setup_gui() Gtk::SpinButton *count = lib :: get_widget("o_pause_count"); Gtk::CheckButton *enabled = lib :: get_widget("o_pause_enabled"); - cb->on_track_loaded = on_track_loaded; cb->on_pause_count_changed = on_pause_count_changed; count->signal_changed().connect(sigc::ptr_fun(on_config_pause)); diff --git a/include/core/callback.h b/include/core/callback.h index 6c0f57cf..270bd40d 100644 --- a/include/core/callback.h +++ b/include/core/callback.h @@ -15,13 +15,6 @@ struct Callbacks { /* Audio callbacks */ - /** - * Called when the audio layer loads a track. - * - * @param track The track that was just loaded. - */ - void (*on_track_loaded)(Track *); - /** * Called when the audio layer's pause count changes. * diff --git a/include/gui/ocarina.h b/include/gui/ocarina.h index 018c5f69..6b4f18db 100644 --- a/include/gui/ocarina.h +++ b/include/gui/ocarina.h @@ -21,6 +21,7 @@ void connect_button(const std::string &, void (*func)()); Gtk::Window *setup_gui(); void on_pq_created(Queue *, unsigned int); +void on_track_loaded(Track *); void post_init_queue_tabs();