summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--deadbeef.h1
-rw-r--r--main.c4
-rw-r--r--plugins.c9
-rw-r--r--plugins.h2
-rw-r--r--plugins/vorbis/vorbis.c20
-rw-r--r--streamer.c7
6 files changed, 36 insertions, 7 deletions
diff --git a/deadbeef.h b/deadbeef.h
index f9c8084a..9af6ff68 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -109,6 +109,7 @@ enum {
DB_EV_SONGCHANGED = 1, // triggers when song was just changed
DB_EV_SONGSTARTED = 2, // triggers when song started playing (for scrobblers and such)
DB_EV_SONGFINISHED = 3, // triggers when song finished playing (for scrobblers and such)
+ DB_EV_TRACKDELETED = 4, // triggers when track is to be deleted from playlist
DB_EV_MAX
};
diff --git a/main.c b/main.c
index 691c0ae1..6029bb91 100644
--- a/main.c
+++ b/main.c
@@ -341,7 +341,7 @@ player_thread (uintptr_t ctx) {
messagepump_push (M_TERMINATE, 0, 0, 0);
}
}
- plug_trigger_event (DB_EV_FRAMEUPDATE);
+ plug_trigger_event (DB_EV_FRAMEUPDATE, 0);
uint32_t msg;
uintptr_t ctx;
uint32_t p1;
@@ -388,7 +388,7 @@ player_thread (uintptr_t ctx) {
// update playlist view
gtkpl_songchanged (&main_playlist, p1, p2);
GDK_THREADS_LEAVE();
- plug_trigger_event (DB_EV_SONGCHANGED);
+ plug_trigger_event (DB_EV_SONGCHANGED, 0);
break;
case M_PLAYSONG:
gtkpl_playsong (&main_playlist);
diff --git a/plugins.c b/plugins.c
index c456e711..3292e878 100644
--- a/plugins.c
+++ b/plugins.c
@@ -255,7 +255,7 @@ plug_quit (void) {
/////// non-api functions (plugin support)
void
-plug_trigger_event (int ev) {
+plug_trigger_event (int ev, uintptr_t param) {
mutex_lock (mutex);
DB_event_t *event;
switch (ev) {
@@ -267,6 +267,13 @@ plug_trigger_event (int ev) {
event = DB_EVENT (pev);
}
break;
+ case DB_EV_TRACKDELETED:
+ {
+ DB_event_song_t *pev = malloc (sizeof (DB_event_song_t));
+ pev->song = DB_PLAYITEM (param);
+ event = DB_EVENT (pev);
+ }
+ break;
default:
event = malloc (sizeof (DB_event_t));
}
diff --git a/plugins.h b/plugins.h
index f1d542a5..4d72bd8a 100644
--- a/plugins.h
+++ b/plugins.h
@@ -35,7 +35,7 @@ void
plug_ev_unsubscribe (DB_plugin_t *plugin, int ev, DB_callback_t callback, uintptr_t data);
void
-plug_trigger_event (int ev);
+plug_trigger_event (int ev, uintptr_t param);
void
plug_md5 (uint8_t sig[16], const char *in, int len);
diff --git a/plugins/vorbis/vorbis.c b/plugins/vorbis/vorbis.c
index 0c277f04..48b6c4c4 100644
--- a/plugins/vorbis/vorbis.c
+++ b/plugins/vorbis/vorbis.c
@@ -351,6 +351,24 @@ cvorbis_insert (DB_playItem_t *after, const char *fname) {
return after;
}
+static int
+vorbis_trackdeleted (DB_event_song_t *ev, uintptr_t data) {
+ if (ev->song == ptrack) {
+ ptrack = NULL;
+ }
+ return 0;
+}
+
+static int
+vorbis_start (void) {
+ deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_TRACKDELETED, DB_CALLBACK (vorbis_trackdeleted), 0);
+}
+
+static int
+vorbis_stop (void) {
+ deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_TRACKDELETED, DB_CALLBACK (vorbis_trackdeleted), 0);
+}
+
static const char * exts[] = { "ogg", NULL };
static const char *filetypes[] = { "OggVorbis", NULL };
@@ -364,6 +382,8 @@ static DB_decoder_t plugin = {
.plugin.author = "Alexey Yakovenko",
.plugin.email = "waker@users.sourceforge.net",
.plugin.website = "http://deadbeef.sf.net",
+ .plugin.start = vorbis_start,
+ .plugin.stop = vorbis_stop,
.init = cvorbis_init,
.free = cvorbis_free,
.read_int16 = cvorbis_read,
diff --git a/streamer.c b/streamer.c
index 2f2e05aa..ceb15654 100644
--- a/streamer.c
+++ b/streamer.c
@@ -82,6 +82,7 @@ static playItem_t *orig_streaming_song;
// playlist must call that whenever item was removed
void
streamer_song_removed_notify (playItem_t *it) {
+ plug_trigger_event (DB_EV_TRACKDELETED, (uintptr_t)it);
if (it == orig_playing_song) {
orig_playing_song = NULL;
}
@@ -249,7 +250,7 @@ streamer_thread (uintptr_t ctx) {
p_stop ();
if (str_playing_song.decoder) {
trace ("sending songfinished to plugins [1]\n");
- plug_trigger_event (DB_EV_SONGFINISHED);
+ plug_trigger_event (DB_EV_SONGFINISHED, 0);
}
messagepump_push (M_SONGCHANGED, 0, pl_get_idx_of (orig_playing_song), -1);
streamer_set_current (NULL);
@@ -276,7 +277,7 @@ streamer_thread (uintptr_t ctx) {
// plugin will get pointer to str_playing_song
if (str_playing_song.decoder) {
trace ("sending songfinished to plugins [2]\n");
- plug_trigger_event (DB_EV_SONGFINISHED);
+ plug_trigger_event (DB_EV_SONGFINISHED, 0);
}
// free old copy of playing
pl_item_free (&str_playing_song);
@@ -297,7 +298,7 @@ streamer_thread (uintptr_t ctx) {
messagepump_push (M_SONGCHANGED, 0, from, to);
// plugin will get pointer to new str_playing_song
trace ("sending songstarted to plugins\n");
- plug_trigger_event (DB_EV_SONGSTARTED);
+ plug_trigger_event (DB_EV_SONGSTARTED, 0);
playpos = 0;
}