From d4e5ec35dca8dd93dfb932cb8b83309e955ec86f Mon Sep 17 00:00:00 2001 From: waker Date: Thu, 27 Aug 2009 21:01:23 +0200 Subject: added volume control and seeking to plugin api --- deadbeef.h | 10 ++++++++-- plugins.c | 36 ++++++++++++++++++++++++++---------- plugins.h | 7 +++++-- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/deadbeef.h b/deadbeef.h index 6106bfec..fd775d3f 100644 --- a/deadbeef.h +++ b/deadbeef.h @@ -116,6 +116,9 @@ typedef struct { void (*playback_pause) (void); void (*playback_stop) (void); void (*playback_play) (void); + float (*playback_get_pos) (void); // [0..100] + void (*playback_set_pos) (float pos); // [0..100] + // process control void (*quit) (void); // threading void (*thread_start) (void (*fn)(uintptr_t ctx), uintptr_t ctx); @@ -125,8 +128,11 @@ typedef struct { int (*mutex_unlock) (uintptr_t mtx); // playlist access const char *(*pl_find_meta) (DB_playItem_t *song, const char *meta); - // web browser - int (*show_uri) (const char *uri); + // volume control + void (*volume_set_db) (float dB); + float (*volume_get_db) (void); + void (*volume_set_amp) (float amp); + float (*volume_get_amp) (void); } DB_functions_t; // base plugin interface diff --git a/plugins.c b/plugins.c index e0d7f68b..265fea5b 100644 --- a/plugins.c +++ b/plugins.c @@ -15,6 +15,8 @@ #include "threading.h" #include "progress.h" #include "playlist.h" +#include "volume.h" +#include "streamer.h" // deadbeef api DB_functions_t deadbeef_api = { @@ -30,6 +32,8 @@ DB_functions_t deadbeef_api = { .playback_pause = plug_playback_pause, .playback_stop = plug_playback_stop, .playback_play = plug_playback_play, + .playback_get_pos = plug_playback_get_pos, + .playback_set_pos = plug_playback_set_pos, .quit = plug_quit, .thread_start = thread_start, .mutex_create = mutex_create, @@ -37,7 +41,11 @@ DB_functions_t deadbeef_api = { .mutex_lock = mutex_lock, .mutex_unlock = mutex_unlock, .pl_find_meta = (const char *(*) (DB_playItem_t *song, const char *meta))pl_find_meta, - .show_uri = plug_show_uri, + // volume control + .volume_set_db = volume_set_db, + .volume_get_db = volume_get_db, + .volume_set_amp = volume_set_amp, + .volume_get_amp = volume_get_amp, }; void @@ -119,21 +127,29 @@ plug_playback_play (void) { messagepump_push (M_PLAYSONG, 0, 0, 0); } +float +plug_playback_get_pos (void) { + if (playlist_current.duration <= 0) { + return 0; + } + return streamer_get_playpos () * 100 / playlist_current.duration; +} + +void +plug_playback_set_pos (float pos) { + if (playlist_current.duration <= 0) { + return; + } + float t = pos * playlist_current.duration / 100.f; + streamer_set_seek (t); +} + void plug_quit (void) { progress_abort (); messagepump_push (M_TERMINATE, 0, 0, 0); } -int -plug_show_uri (const char *uri) { - GError *error = NULL; - GDK_THREADS_ENTER(); - gboolean ret = gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, &error); - GDK_THREADS_LEAVE(); - return ret; -} - /////// non-api functions (plugin support) void plug_trigger_event (int ev) { diff --git a/plugins.h b/plugins.h index 0525d9e4..dec83bde 100644 --- a/plugins.h +++ b/plugins.h @@ -41,7 +41,10 @@ plug_playback_play (void); void plug_quit (void); -int -plug_show_uri (const char *uri); +float +plug_playback_get_pos (void); + +void +plug_playback_set_pos (float pos); #endif // __PLUGINS_H -- cgit v1.2.3