diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2009-11-11 22:10:55 +0100 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2009-11-11 22:10:55 +0100 |
commit | 692ceb95e184f15a91f67bae4dbde565b1287f36 (patch) | |
tree | 08300d4f15620ab89cca4b2d50f8c831357a138f | |
parent | 76b5d753192aba0ed20e8eaff81a3c22a7f7025f (diff) |
finished moving gtk-related code to plugin
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | deadbeef.h | 21 | ||||
-rw-r--r-- | main.c | 100 | ||||
-rw-r--r-- | playlist.c | 2 | ||||
-rw-r--r-- | plugins.c | 89 | ||||
-rw-r--r-- | plugins.h | 14 | ||||
-rw-r--r-- | plugins/gtkui/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/gtkui/gtkplaylist.c | 10 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 141 | ||||
-rw-r--r-- | plugins/gtkui/progress.c (renamed from progress.c) | 0 | ||||
-rw-r--r-- | plugins/gtkui/progress.h (renamed from progress.h) | 0 | ||||
-rw-r--r-- | plugins/gtkui/search.c (renamed from search.c) | 0 | ||||
-rw-r--r-- | plugins/gtkui/search.h (renamed from search.h) | 0 | ||||
-rw-r--r-- | plugins/lastfm/lastfm.c | 24 | ||||
-rw-r--r-- | plugins/vorbis/vorbis.c | 4 | ||||
-rw-r--r-- | streamer.c | 4 |
16 files changed, 226 insertions, 187 deletions
diff --git a/Makefile.am b/Makefile.am index b1e67241..3cded06c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,11 +30,9 @@ deadbeef_SOURCES =\ plugins.c plugins.h moduleconf.h\ playlist.c playlist.h \ streamer.c streamer.h\ - progress.c progress.h\ codec.c codec.h\ messagepump.c messagepump.h\ conf.c conf.h\ - search.c search.h\ cgme.c cdumb.c csid.cpp\ palsa.c palsa.h playback.h\ threading_pthread.c threading.h\ @@ -97,19 +97,25 @@ enum { typedef struct { int event; - double time; + time_t time; } DB_event_t; typedef struct { DB_event_t ev; - DB_playItem_t *song; -} DB_event_song_t; + int index; + DB_playItem_t *track; +} DB_event_track_t; typedef struct { DB_event_t ev; int from; int to; -} DB_event_songchange_t; +} DB_event_trackchange_t; + +typedef struct { + DB_event_t ev; + int state; +} DB_event_state_t; typedef struct DB_conf_item_s { char *key; @@ -129,6 +135,10 @@ enum { DB_EV_TRACKDELETED = 4, // triggers when track is to be deleted from playlist DB_EV_CONFIGCHANGED = 5, // configuration option changed DB_EV_ACTIVATE = 6, // will be fired every time player is activated + DB_EV_TRACKINFOCHANGED = 7, // notify plugins that trackinfo was changed + DB_EV_PAUSED = 8, // player was paused or unpaused + DB_EV_PLAYLISTCHANGED = 9, // playlist contents were changed + DB_EV_VOLUMECHANGED = 10, // volume was changed DB_EV_MAX }; @@ -262,9 +272,6 @@ typedef struct { int (*conf_get_int) (const char *key, int def); void (*conf_set_str) (const char *key, const char *val); DB_conf_item_t * (*conf_find) (const char *group, DB_conf_item_t *prev); - // gui locking - void (*gui_lock) (void); - void (*gui_unlock) (void); // exporting plugin conf options for gui // all exported options are grouped by plugin, and will be available to user // from gui @@ -227,7 +227,6 @@ player_thread (uintptr_t ctx) { messagepump_push (M_TERMINATE, 0, 0, 0); } } - plug_trigger_event (DB_EV_FRAMEUPDATE, 0); uint32_t msg; uintptr_t ctx; uint32_t p1; @@ -259,22 +258,17 @@ player_thread (uintptr_t ctx) { #endif return; case M_SONGCHANGED: - plug_trigger_event_songchanged (p1, p2); + plug_trigger_event_trackchange (p1, p2); break; case M_PLAYSONG: - // <placeholder> - // start a track - guiplug_start_current_track (); + streamer_play_current_track (); break; case M_TRACKCHANGED: - // <placeholder> - // notify gui that track information was changed - guiplug_track_changed (p1); + plug_trigger_event_trackinfochanged (p1); break; case M_PLAYSONGNUM: - // <placeholder> - // start track by number in p1 - guiplug_start_track (p1); + p_stop (); + streamer_set_nextsong (p1, 1); break; case M_STOPSONG: streamer_set_nextsong (-2, 0); @@ -290,54 +284,48 @@ player_thread (uintptr_t ctx) { case M_PAUSESONG: if (p_ispaused ()) { p_unpause (); + plug_trigger_event_paused (0); } else { p_pause (); - } - // <placeholder> - // notify that current track was paused - if (playlist_current_ptr) { - guiplug_track_paused (pl_get_idx_of (playlist_current_ptr)); + plug_trigger_event_paused (1); } break; case M_PLAYRANDOM: - // <placeholder> - // play random song - guiplug_start_random (); + p_stop (); + pl_randomsong (); break; case M_ADDDIR: // <placeholder> // * let guiplug know that addition is in progress // * call it back on every file // * let guiplug know that addition is done - guiplug_add_dir ((char *)ctx); + // guiplug_add_dir ((char *)ctx); break; case M_ADDDIRS: // <placeholder> // same as above, but for many folders - guiplug_add_dirs ((GSList *)ctx); + // guiplug_add_dirs ((GSList *)ctx); break; case M_ADDFILES: // <placeholder> // same as above but for many files - guiplug_add_files ((GSList *)ctx); + // guiplug_add_files ((GSList *)ctx); break; case M_OPENFILES: p_stop (); // <placeholder> // open many files and start 1st of them - guiplug_open_files ((GSList *)ctx); + // guiplug_open_files ((GSList *)ctx); break; case M_FMDRAGDROP: // <placeholder> // handle drag-n-drop from filemanager // that should be handled internally in ui plugin - guiplug_add_fm_dropped_files ((char *)ctx, p1, p2) + // guiplug_add_fm_dropped_files ((char *)ctx, p1, p2) break; case M_PLAYLISTREFRESH: - // <placeholder> - // refresh all playlist windows - guiplug_refresh_playlist (); + plug_trigger_event_playlistchanged (); break; case M_CONFIGCHANGED: palsa_configchanged (); @@ -347,7 +335,7 @@ player_thread (uintptr_t ctx) { } } usleep(50000); - guiplug_frameupdate (); + plug_trigger_event (DB_EV_FRAMEUPDATE, 0); } } @@ -474,58 +462,7 @@ main (int argc, char *argv[]) { // p_init (); thread_start (player_thread, 0); - g_thread_init (NULL); - add_pixmap_directory (PREFIX "/share/deadbeef/pixmaps"); - gdk_threads_init (); - gdk_threads_enter (); - gtk_set_locale (); - gtk_init (&argc, &argv); - - // system tray icon - traymenu = create_traymenu (); - GdkPixbuf *trayicon_pixbuf = create_pixbuf ("play_24.png"); - trayicon = gtk_status_icon_new_from_pixbuf (trayicon_pixbuf); - set_tray_tooltip ("DeaDBeeF"); - //gtk_status_icon_set_title (GTK_STATUS_ICON (trayicon), "DeaDBeeF"); -#if GTK_MINOR_VERSION <= 14 - g_signal_connect ((gpointer)trayicon, "activate", G_CALLBACK (on_trayicon_activate), NULL); -#else - g_signal_connect ((gpointer)trayicon, "scroll_event", G_CALLBACK (on_trayicon_scroll_event), NULL); - g_signal_connect ((gpointer)trayicon, "button_press_event", G_CALLBACK (on_trayicon_button_press_event), NULL); -#endif - g_signal_connect ((gpointer)trayicon, "popup_menu", G_CALLBACK (on_trayicon_popup_menu), NULL); - - gtkpl_init (); - - mainwin = create_mainwin (); - GdkPixbuf *mainwin_icon_pixbuf; - mainwin_icon_pixbuf = create_pixbuf ("play_24.png"); - if (mainwin_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (mainwin), mainwin_icon_pixbuf); - gdk_pixbuf_unref (mainwin_icon_pixbuf); - } - session_restore_window_attrs ((uintptr_t)mainwin); volume_set_db (conf_get_float ("playback.volume", 0)); - // order and looping - const char *orderwidgets[3] = { "order_linear", "order_shuffle", "order_random" }; - const char *loopingwidgets[3] = { "loop_all", "loop_disable", "loop_single" }; - const char *w; - w = orderwidgets[conf_get_int ("playback.order", 0)]; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, w)), TRUE); - w = loopingwidgets[conf_get_int ("playback.loop", 0)]; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, w)), TRUE); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, "scroll_follows_playback")), conf_get_int ("playlist.scroll.followplayback", 0) ? TRUE : FALSE); - - searchwin = create_searchwin (); - gtk_window_set_transient_for (GTK_WINDOW (searchwin), GTK_WINDOW (mainwin)); - extern void main_playlist_init (GtkWidget *widget); - main_playlist_init (lookup_widget (mainwin, "playlist")); - extern void search_playlist_init (GtkWidget *widget); - search_playlist_init (lookup_widget (searchwin, "searchlist")); - - progress_init (); - if (argc > 1) { int res = exec_command_line (cmdline, size, 0); if (res == -1) { @@ -537,17 +474,12 @@ main (int argc, char *argv[]) { } } - gtk_widget_show (mainwin); - gtk_main (); // save config pl_save (defpl); conf_save (); // stop receiving messages from outside server_close (); // at this point we can simply do exit(0), but let's clean up for debugging - gtkpl_free (&main_playlist); - gtkpl_free (&search_playlist); - gdk_threads_leave (); messagepump_free (); p_free (); streamer_free (); @@ -50,6 +50,8 @@ playItem_t *playlist_head[PL_MAX_ITERATORS]; playItem_t *playlist_tail[PL_MAX_ITERATORS]; +int playlist_current_row[PL_MAX_ITERATORS]; + playItem_t *playlist_current_ptr; int pl_count = 0; float pl_totaltime = 0; @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <gtk/gtk.h> #ifdef HAVE_CONFIG_H # include <config.h> #endif @@ -30,7 +29,6 @@ #include "md5/md5.h" #include "messagepump.h" #include "threading.h" -#include "progress.h" #include "playlist.h" #include "volume.h" #include "streamer.h" @@ -122,8 +120,6 @@ static DB_functions_t deadbeef_api = { .conf_get_int = conf_get_int, .conf_set_str = conf_set_str, .conf_find = conf_find, - .gui_lock = plug_gui_lock, - .gui_unlock = plug_gui_unlock, }; DB_functions_t *deadbeef = &deadbeef_api; @@ -134,18 +130,15 @@ plug_get_config_dir (void) { } void -volumebar_notify_changed (void); - -void plug_volume_set_db (float db) { volume_set_db (db); - volumebar_notify_changed (); + plug_trigger_event_volumechanged (); } void plug_volume_set_amp (float amp) { volume_set_amp (amp); - volumebar_notify_changed (); + plug_trigger_event_volumechanged (); } #define MAX_PLUGINS 100 @@ -158,16 +151,6 @@ DB_decoder_t *g_decoder_plugins[MAX_DECODER_PLUGINS+1]; DB_vfs_t *g_vfs_plugins[MAX_VFS_PLUGINS+1]; void -plug_gui_lock (void) { - gdk_threads_enter (); -} - -void -plug_gui_unlock (void) { - gdk_threads_leave (); -} - -void plug_md5 (uint8_t sig[16], const char *in, int len) { md5_buffer (in, len, sig); } @@ -277,66 +260,90 @@ plug_playback_set_pos (float pos) { void plug_quit (void) { - progress_abort (); + // FIXME progress_abort (); messagepump_push (M_TERMINATE, 0, 0, 0); } /////// non-api functions (plugin support) void plug_event_call (DB_event_t *ev) { + ev->time = time (NULL); + mutex_lock (mutex); for (int i = 0; i < MAX_HANDLERS; i++) { - if (handlers[ev->event][i].plugin && !handlers[ev][i].plugin->inactive) { - handlers[ev->event][i].callback (event, handlers[ev->event][i].data); + if (handlers[ev->event][i].plugin && !handlers[ev->event][i].plugin->inactive) { + handlers[ev->event][i].callback (ev, handlers[ev->event][i].data); } } + mutex_unlock (mutex); } void plug_trigger_event (int ev, uintptr_t param) { - mutex_lock (mutex); DB_event_t *event; switch (ev) { case DB_EV_SONGSTARTED: case DB_EV_SONGFINISHED: { - DB_event_song_t *pev = _alloca (sizeof (DB_event_song_t)); - pev->song = DB_PLAYITEM (&str_playing_song); + DB_event_track_t *pev = alloca (sizeof (DB_event_track_t)); + pev->index = -1; + pev->track = DB_PLAYITEM (&str_playing_song); event = DB_EVENT (pev); } break; case DB_EV_TRACKDELETED: { - DB_event_song_t *pev = _alloca (sizeof (DB_event_song_t)); - pev->song = DB_PLAYITEM (param); + DB_event_track_t *pev = alloca (sizeof (DB_event_track_t)); + pev->index = -1; // FIXME + pev->track = DB_PLAYITEM (param); event = DB_EVENT (pev); } break; default: - event = _alloca (sizeof (DB_event_t)); + event = alloca (sizeof (DB_event_t)); } event->event = ev; - event->time = (double)clock () / CLOCKS_PER_SEC; plug_event_call (event); - mutex_unlock (mutex); } void -plug_trigger_event_songchanged (int from, int to) { - mutex_lock (mutex); - DB_event_songchange_t event; +plug_trigger_event_trackchange (int from, int to) { + DB_event_trackchange_t event; event.ev.event = DB_EV_SONGCHANGED; - event.ev.time = (double)clock () / CLOCKS_PER_SEC; event.from = from; event.to = to; + plug_event_call (DB_EVENT (&event)); +} +void +plug_trigger_event_trackinfochanged (int trk) { + DB_event_track_t event; + event.ev.event = DB_EV_SONGCHANGED; + event.index = trk; + event.track = DB_PLAYITEM (pl_get_for_idx (trk)); + plug_event_call (DB_EVENT (&event)); +} - for (int i = 0; i < MAX_HANDLERS; i++) { - if (handlers[ev][i].plugin && !handlers[ev][i].plugin->inactive) { - handlers[ev][i].callback (event.ev.event, handlers[ev][i].data); - } - } - free (event); - mutex_unlock (mutex); +void +plug_trigger_event_paused (int paused) { + DB_event_state_t event; + event.ev.event = DB_EV_PAUSED; + event.state = paused; + plug_event_call (DB_EVENT (&event)); } + +void +plug_trigger_event_playlistchanged (void) { + DB_event_t event; + event.event = DB_EV_PLAYLISTCHANGED; + plug_event_call (DB_EVENT (&event)); +} + +void +plug_trigger_event_volumechanged (void) { + DB_event_t event; + event.event = DB_EV_VOLUMECHANGED; + plug_event_call (DB_EVENT (&event)); +} + int plug_init_plugin (DB_plugin_t* (*loadfunc)(DB_functions_t *), void *handle) { DB_plugin_t *plugin_api = loadfunc (&deadbeef_api); @@ -38,7 +38,19 @@ void plug_trigger_event (int ev, uintptr_t param); void -plug_trigger_event_songchanged (int from, int to); +plug_trigger_event_trackchange (int from, int to); + +void +plug_trigger_event_trackinfochanged (int trk); + +void +plug_trigger_event_paused (int paused); + +void +plug_trigger_event_playlistchanged (void); + +void +plug_trigger_event_volumechanged (void); void plug_md5 (uint8_t sig[16], const char *in, int len); diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am index 13ace983..9eba3da8 100644 --- a/plugins/gtkui/Makefile.am +++ b/plugins/gtkui/Makefile.am @@ -5,6 +5,8 @@ # callbacks.c interface.c support.c callbacks.h interface.h support.h\ # gtkplaylist.c gtkplaylist.h\ # drawing.h gdkdrawing.c\ +# progress.c progress.h\ +# search.c search.h\ # gtksession.c # # diff --git a/plugins/gtkui/gtkplaylist.c b/plugins/gtkui/gtkplaylist.c index 65334248..62cfe610 100644 --- a/plugins/gtkui/gtkplaylist.c +++ b/plugins/gtkui/gtkplaylist.c @@ -932,14 +932,16 @@ gtkpl_hscroll (gtkplaylist_t *ps, int newscroll) { void gtkpl_randomsong (void) { - p_stop (); - pl_randomsong (); +// <deprecated> +// p_stop (); +// pl_randomsong (); } void gtkpl_playsongnum (int idx) { - p_stop (); - streamer_set_nextsong (idx, 1); +// <deprecated> +// p_stop (); +// streamer_set_nextsong (idx, 1); } void diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 32c58e95..ab849882 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -235,18 +235,6 @@ guiplug_start_current_track (void) { GDK_THREADS_LEAVE(); } } -void -guiplug_track_changed (int idx) { - playItem_t *it = pl_get_for_idx (idx); - if (it) { - GDK_THREADS_ENTER(); - gtkpl_redraw_pl_row (&main_playlist, idx, it); - if (it == playlist_current_ptr) { - gtkpl_current_track_changed (it); - } - GDK_THREADS_LEAVE(); - } -} void guiplug_start_track (int idx) { @@ -256,17 +244,9 @@ guiplug_start_track (int idx) { } void -guiplug_track_paused (int idx) { - GDK_THREADS_ENTER(); - gtkpl_redraw_pl_row (&main_playlist, idx, pl_get_for_idx (idx)); - GDK_THREADS_LEAVE(); -} - -void guiplug_start_random (void) { - GDK_THREADS_ENTER(); - gtkpl_randomsong (); - GDK_THREADS_LEAVE(); + // <deprecated> + assert (0); } void @@ -300,10 +280,8 @@ guiplug_open_files (GSList *files) { void guiplug_refresh_playlist (void) { - GDK_THREADS_ENTER(); - playlist_refresh (); - search_refresh (); - GDK_THREADS_LEAVE(); + // <deprecated> + assert (0); } void @@ -311,11 +289,6 @@ guiplug_add_fm_dropped_files (char *files, int p1, int p2) { gtkpl_add_fm_dropped_files (&main_playlist, (char *)ctx, p1, p2); } -void -guiplug_frameupdate (void) { - update_songinfo (); -} - static int gtkui_on_activate (DB_event_t *ev, uintptr_t data) { GDK_THREADS_ENTER(); @@ -325,14 +298,110 @@ gtkui_on_activate (DB_event_t *ev, uintptr_t data) { } static int -gtkui_on_songchanged (DB_event_song_t *ev, uintptr_t data) { +gtkui_on_songchanged (DB_event_songchange_t *ev, uintptr_t data) { gtkpl_songchanged_wrapper (from, to); } static int +gtkui_on_trackinfochanged (DB_event_track_t *ev, uintptr_t data) { + GDK_THREADS_ENTER(); + gtkpl_redraw_pl_row (&main_playlist, ev->index, ev->track); + if (ev->track == playlist_current_ptr) { + gtkpl_current_track_changed (ev->track); + } + GDK_THREADS_LEAVE(); +} + +static int +gtkui_on_paused (DB_event_state_t *ev, uintptr_t data) { + GDK_THREADS_ENTER(); + gtkpl_redraw_pl_row (&main_playlist, pl_get_idx_of (playlist_current_ptr), playlist_current_ptr); + GDK_THREADS_LEAVE(); +} + +static int +gtkui_on_playlistchanged (DB_event_t *ev, uintptr_t data) { + GDK_THREADS_ENTER(); + playlist_refresh (); + search_refresh (); + GDK_THREADS_LEAVE(); +} + +static int +gtkui_on_frameupdate (DB_event_t *ev, uintptr_t data) { + update_songinfo (); +} + +static int +gtkui_on_volumechanged (DB_event_t *ev, uintptr_t data) { + void volumebar_notify_changed (void); // FIXME: do it properly + volumebar_notify_changed (); +} + +static int gtkui_start (void) { + // let's start some gtk + g_thread_init (NULL); + add_pixmap_directory (PREFIX "/share/deadbeef/pixmaps"); + gdk_threads_init (); + gdk_threads_enter (); + gtk_set_locale (); + gtk_init (&argc, &argv); + + // system tray icon + traymenu = create_traymenu (); + GdkPixbuf *trayicon_pixbuf = create_pixbuf ("play_24.png"); + trayicon = gtk_status_icon_new_from_pixbuf (trayicon_pixbuf); + set_tray_tooltip ("DeaDBeeF"); + //gtk_status_icon_set_title (GTK_STATUS_ICON (trayicon), "DeaDBeeF"); +#if GTK_MINOR_VERSION <= 14 + g_signal_connect ((gpointer)trayicon, "activate", G_CALLBACK (on_trayicon_activate), NULL); +#else + g_signal_connect ((gpointer)trayicon, "scroll_event", G_CALLBACK (on_trayicon_scroll_event), NULL); + g_signal_connect ((gpointer)trayicon, "button_press_event", G_CALLBACK (on_trayicon_button_press_event), NULL); +#endif + g_signal_connect ((gpointer)trayicon, "popup_menu", G_CALLBACK (on_trayicon_popup_menu), NULL); + + gtkpl_init (); + + mainwin = create_mainwin (); + GdkPixbuf *mainwin_icon_pixbuf; + mainwin_icon_pixbuf = create_pixbuf ("play_24.png"); + if (mainwin_icon_pixbuf) + { + gtk_window_set_icon (GTK_WINDOW (mainwin), mainwin_icon_pixbuf); + gdk_pixbuf_unref (mainwin_icon_pixbuf); + } + session_restore_window_attrs ((uintptr_t)mainwin); + // order and looping + const char *orderwidgets[3] = { "order_linear", "order_shuffle", "order_random" }; + const char *loopingwidgets[3] = { "loop_all", "loop_disable", "loop_single" }; + const char *w; + w = orderwidgets[conf_get_int ("playback.order", 0)]; + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, w)), TRUE); + w = loopingwidgets[conf_get_int ("playback.loop", 0)]; + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, w)), TRUE); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, "scroll_follows_playback")), conf_get_int ("playlist.scroll.followplayback", 0) ? TRUE : FALSE); + + searchwin = create_searchwin (); + gtk_window_set_transient_for (GTK_WINDOW (searchwin), GTK_WINDOW (mainwin)); + extern void main_playlist_init (GtkWidget *widget); + main_playlist_init (lookup_widget (mainwin, "playlist")); + extern void search_playlist_init (GtkWidget *widget); + search_playlist_init (lookup_widget (searchwin, "searchlist")); + + progress_init (); + gtk_widget_show (mainwin); + deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_ACTIVATE, DB_CALLBACK (gtkui_on_activate), 0); deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_SONGCHANGED, DB_CALLBACK (gtkui_on_songchanged), 0); + deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_TRACKINFOCHANGED, DB_CALLBACK (gtkui_on_trackinfochanged), 0); + deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_PAUSED, DB_CALLBACK (gtkui_on_paused), 0); + deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_PLAYLISTCHANGED, DB_CALLBACK (gtkui_on_playlistchanged), 0); + deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_FRAMEUPDATE, DB_CALLBACK (gtkui_on_frameupdate), 0); + deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_VOLUMECHANGED, DB_CALLBACK (gtkui_on_volumechanged), 0); + gtk_main (); + return 0; } @@ -340,6 +409,14 @@ static int gtkui_stop (void) { deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_ACTIVATE, DB_CALLBACK (gtkui_on_activate), 0); deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_SONGCHANGED, DB_CALLBACK (gtkui_on_songchanged), 0); + deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_TRACKINFOCHANGED, DB_CALLBACK (gtkui_on_trackinfochanged), 0); + deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_PAUSED, DB_CALLBACK (gtkui_on_paused), 0); + deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_PLAYLISTCHANGED, DB_CALLBACK (gtkui_on_playlistchanged), 0); + deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_FRAMEUPDATE, DB_CALLBACK (gtkui_on_frameupdate), 0); + deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_VOLUMECHANGED, DB_CALLBACK (gtkui_on_volumechanged), 0); + gtkpl_free (&main_playlist); + gtkpl_free (&search_playlist); + gdk_threads_leave (); return 0; } diff --git a/progress.c b/plugins/gtkui/progress.c index 4c413dfc..4c413dfc 100644 --- a/progress.c +++ b/plugins/gtkui/progress.c diff --git a/progress.h b/plugins/gtkui/progress.h index e4de0e8e..e4de0e8e 100644 --- a/progress.h +++ b/plugins/gtkui/progress.h diff --git a/search.c b/plugins/gtkui/search.c index 1ce99edd..1ce99edd 100644 --- a/search.c +++ b/plugins/gtkui/search.c diff --git a/search.h b/plugins/gtkui/search.h index 32d45e07..32d45e07 100644 --- a/search.h +++ b/plugins/gtkui/search.h diff --git a/plugins/lastfm/lastfm.c b/plugins/lastfm/lastfm.c index 776e2bbe..773a8fa3 100644 --- a/plugins/lastfm/lastfm.c +++ b/plugins/lastfm/lastfm.c @@ -445,9 +445,9 @@ lfm_format_uri (int subm, DB_playItem_t *song, char *out, int outl) { } static int -lastfm_songstarted (DB_event_song_t *ev, uintptr_t data) { +lastfm_songstarted (DB_event_track_t *ev, uintptr_t data) { deadbeef->mutex_lock (lfm_mutex); - if (lfm_format_uri (-1, ev->song, lfm_nowplaying, sizeof (lfm_nowplaying)) < 0) { + if (lfm_format_uri (-1, ev->track, lfm_nowplaying, sizeof (lfm_nowplaying)) < 0) { lfm_nowplaying[0] = 0; } // trace ("%s\n", lfm_nowplaying); @@ -460,28 +460,28 @@ lastfm_songstarted (DB_event_song_t *ev, uintptr_t data) { } static int -lastfm_songfinished (DB_event_song_t *ev, uintptr_t data) { +lastfm_songfinished (DB_event_track_t *ev, uintptr_t data) { trace ("lfm songfinished\n"); #if !LFM_IGNORE_RULES // check submission rules // duration must be >= 30 sec - if (deadbeef->pl_get_item_duration (ev->song) < 30) { - trace ("song duration is %f seconds. not eligible for submission\n", ev->song->duration); + if (deadbeef->pl_get_item_duration (ev->track) < 30) { + trace ("track duration is %f seconds. not eligible for submission\n", ev->song->duration); return 0; } // must be played for >=240sec of half the total time - if (ev->song->playtime < 240 && ev->song->playtime < deadbeef->pl_get_item_duration (ev->song)/2) { - trace ("song playtime=%f seconds. not eligible for submission\n", ev->song->playtime); + if (ev->track->playtime < 240 && ev->track->playtime < deadbeef->pl_get_item_duration (ev->track)/2) { + trace ("track playtime=%f seconds. not eligible for submission\n", ev->track->playtime); return 0; } #endif - if (!deadbeef->pl_find_meta (ev->song, "artist") - || !deadbeef->pl_find_meta (ev->song, "title") -// || !deadbeef->pl_find_meta (ev->song, "album") + if (!deadbeef->pl_find_meta (ev->track, "artist") + || !deadbeef->pl_find_meta (ev->track, "title") +// || !deadbeef->pl_find_meta (ev->track, "album") ) { - trace ("lfm: not enough metadata for submission, artist=%s, title=%s, album=%s\n", deadbeef->pl_find_meta (ev->song, "artist"), deadbeef->pl_find_meta (ev->song, "title"), deadbeef->pl_find_meta (ev->song, "album")); + trace ("lfm: not enough metadata for submission, artist=%s, title=%s, album=%s\n", deadbeef->pl_find_meta (ev->track, "artist"), deadbeef->pl_find_meta (ev->track, "title"), deadbeef->pl_find_meta (ev->track, "album")); return 0; } deadbeef->mutex_lock (lfm_mutex); @@ -490,7 +490,7 @@ lastfm_songfinished (DB_event_song_t *ev, uintptr_t data) { if (!lfm_subm_queue[i]) { trace ("lfm: song is now in queue for submission\n"); lfm_subm_queue[i] = deadbeef->pl_item_alloc (); - deadbeef->pl_item_copy (lfm_subm_queue[i], ev->song); + deadbeef->pl_item_copy (lfm_subm_queue[i], ev->track); break; } } diff --git a/plugins/vorbis/vorbis.c b/plugins/vorbis/vorbis.c index 31e252eb..2a10322c 100644 --- a/plugins/vorbis/vorbis.c +++ b/plugins/vorbis/vorbis.c @@ -354,8 +354,8 @@ cvorbis_insert (DB_playItem_t *after, const char *fname) { } static int -vorbis_trackdeleted (DB_event_song_t *ev, uintptr_t data) { - if (ev->song == ptrack) { +vorbis_trackdeleted (DB_event_track_t *ev, uintptr_t data) { + if (ev->track == ptrack) { ptrack = NULL; } return 0; @@ -890,9 +890,9 @@ streamer_play_current_track (void) { if (p_ispaused ()) { p_unpause (); } - else if (ps->row != -1) { + else if (playlist_current_row[PL_MAIN] != -1) { p_stop (); - streamer_set_nextsong (ps->row, 1); + streamer_set_nextsong (playlist_current_row[PL_MAIN], 1); } else { p_stop (); |