diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2009-10-03 20:27:55 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2009-10-03 20:27:55 +0200 |
commit | b13342fe99b83bf37d420a827b5f55e2b770cd5e (patch) | |
tree | 8effc14d3c5ee98cbf4214a9c045dcd958c70655 | |
parent | f86fc192b0dbe26d39406c7b9f508142b6e0c9be (diff) |
moved message ids to deadbeef.h
added message sending to plugin API
added M_TRACKCHANGED message
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | deadbeef.h | 25 | ||||
-rw-r--r-- | gtkplaylist.c | 1 | ||||
-rw-r--r-- | main.c | 14 | ||||
-rw-r--r-- | messages.h | 41 | ||||
-rw-r--r-- | palsa.c | 1 | ||||
-rw-r--r-- | plugins.c | 3 | ||||
-rw-r--r-- | search.c | 2 |
8 files changed, 44 insertions, 45 deletions
diff --git a/Makefile.am b/Makefile.am index 2c23dcb8..ff98f2cd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,7 +31,7 @@ deadbeef_SOURCES =\ streamer.c streamer.h\ progress.c progress.h\ codec.c codec.h\ - messagepump.c messagepump.h messages.h\ + messagepump.c messagepump.h\ conf.c conf.h\ search.c search.h\ cgme.c cdumb.c csid.cpp\ @@ -112,6 +112,28 @@ enum { DB_EV_MAX }; +// message ids for communicating with player +enum { + M_SONGFINISHED, + M_NEXTSONG, + M_PREVSONG, + M_PLAYSONG, + M_PLAYSONGNUM, + M_STOPSONG, + M_PAUSESONG, + M_PLAYRANDOM, + M_SONGCHANGED, // p1=from, p2=to + M_ADDDIR, // ctx = pointer to string, which must be freed by g_free + M_ADDFILES, // ctx = GSList pointer, must be freed with g_slist_free + M_ADDDIRS, // ctx = GSList pointer, must be freed with g_slist_free + M_OPENFILES, // ctx = GSList pointer, must be freed with g_slist_free + M_FMDRAGDROP, // ctx = char* ptr, must be freed with standard free, p1 is length of data, p2 is drop_y + M_TERMINATE, // must be sent to player thread to terminate + M_PLAYLISTREFRESH, + M_REINIT_SOUND, + M_TRACKCHANGED, // p1=tracknumber +}; + // typecasting macros #define DB_PLUGIN(x) ((DB_plugin_t *)(x)) #define DB_CALLBACK(x) ((DB_callback_t)(x)) @@ -167,6 +189,7 @@ typedef struct { void (*pl_item_free) (DB_playItem_t *it); void (*pl_item_copy) (DB_playItem_t *out, DB_playItem_t *in); DB_playItem_t *(*pl_insert_item) (DB_playItem_t *after, DB_playItem_t *it); + int (*pl_get_idx_of) (DB_playItem_t *it); // metainfo void (*pl_add_meta) (DB_playItem_t *it, const char *key, const char *value); const char *(*pl_find_meta) (DB_playItem_t *song, const char *meta); @@ -192,6 +215,8 @@ typedef struct { int64_t (*ftell) (DB_FILE *stream); void (*rewind) (DB_FILE *stream); int64_t (*fgetlength) (DB_FILE *stream); + // message passing + int (*sendmessage) (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2); } DB_functions_t; // base plugin interface diff --git a/gtkplaylist.c b/gtkplaylist.c index 2c97a3f5..50fe7b3e 100644 --- a/gtkplaylist.c +++ b/gtkplaylist.c @@ -43,6 +43,7 @@ #include "progress.h" #include "drawing.h" #include "session.h" +#include "deadbeef.h" //#define trace(...) { fprintf(stderr, __VA_ARGS__); } #define trace(fmt,...) @@ -388,11 +388,21 @@ player_thread (uintptr_t ctx) { break; case M_PLAYSONG: gtkpl_playsong (&main_playlist); - GDK_THREADS_ENTER(); if (playlist_current_ptr) { + GDK_THREADS_ENTER(); gtkpl_redraw_pl_row (&main_playlist, pl_get_idx_of (playlist_current_ptr), playlist_current_ptr); + GDK_THREADS_LEAVE(); + } + break; + case M_TRACKCHANGED: + { + playItem_t *it = pl_get_for_idx (p1); + if (it) { + GDK_THREADS_ENTER(); + gtkpl_redraw_pl_row (&main_playlist, p1, it); + GDK_THREADS_LEAVE(); + } } - GDK_THREADS_LEAVE(); break; case M_PLAYSONGNUM: GDK_THREADS_ENTER(); diff --git a/messages.h b/messages.h deleted file mode 100644 index f0bfcb49..00000000 --- a/messages.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - DeaDBeeF - ultimate music player for GNU/Linux systems with X11 - Copyright (C) 2009 Alexey Yakovenko - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ -#ifndef __MESSAGES_H -#define __MESSAGES_H - -enum { - M_SONGFINISHED, - M_NEXTSONG, - M_PREVSONG, - M_PLAYSONG, - M_PLAYSONGNUM, - M_STOPSONG, - M_PAUSESONG, - M_PLAYRANDOM, - M_SONGCHANGED, // p1=from, p2=to - M_ADDDIR, // ctx = pointer to string, which must be freed by f_free - M_ADDFILES, // ctx = GSList pointer, must be freed with g_slist_free - M_ADDDIRS, // ctx = GSList pointer, must be freed with g_slist_free - M_OPENFILES, // ctx = GSList pointer, must be freed with g_slist_free - M_FMDRAGDROP, // ctx = char* ptr, must be freed with standard free, p1 is length of data, p2 is drop_y - M_TERMINATE, // must be sent to player thread to terminate - M_PLAYLISTREFRESH, - M_REINIT_SOUND, -}; - -#endif // __MESSAGES_H @@ -30,6 +30,7 @@ #include "volume.h" #include "messagepump.h" #include "messages.h" +#include "deadbeef.h" #define trace(...) { fprintf(stderr, __VA_ARGS__); } //#define trace(fmt,...) @@ -82,6 +82,7 @@ static DB_functions_t deadbeef_api = { .pl_item_free = (void (*)(DB_playItem_t *))pl_item_free, .pl_item_copy = (void (*)(DB_playItem_t *, DB_playItem_t *))pl_item_copy, .pl_insert_item = (DB_playItem_t *(*) (DB_playItem_t *after, DB_playItem_t *it))pl_insert_item, + .pl_get_idx_of = (int (*) (DB_playItem_t *it))pl_get_idx_of, // metainfo .pl_add_meta = (void (*) (DB_playItem_t *, const char *, const char *))pl_add_meta, .pl_find_meta = (const char *(*) (DB_playItem_t *, const char *))pl_find_meta, @@ -107,6 +108,8 @@ static DB_functions_t deadbeef_api = { .ftell = vfs_ftell, .rewind = vfs_rewind, .fgetlength = vfs_fgetlength, + // message passing + .sendmessage = messagepump_push, }; DB_functions_t *deadbeef = &deadbeef_api; @@ -34,8 +34,8 @@ #include "gtkplaylist.h" #include "messagepump.h" #include "messages.h" - #include "utf8.h" +#include "deadbeef.h" extern GtkWidget *searchwin; struct playItem_s *search_current = NULL; |