summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-06 08:31:05 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-06 08:31:05 +0200
commitaa8a0e7eb57d8b3d2dabd86d9ac26a8ea400aca1 (patch)
tree11a439e3590d31f9573207c3ca7c2c5cb2f9eeb5
parentf12d01e7840fa9f71ff52876c7034231c38811ac (diff)
several fixes to playqueue handling
-rw-r--r--main.c4
-rw-r--r--playlist.c26
-rw-r--r--plugins.c10
-rw-r--r--plugins.h3
4 files changed, 40 insertions, 3 deletions
diff --git a/main.c b/main.c
index 8df51535..0f257fd4 100644
--- a/main.c
+++ b/main.c
@@ -643,10 +643,10 @@ main (int argc, char *argv[]) {
// at this point we can simply do exit(0), but let's clean up for debugging
plt_free (); // plt_free may access conf_*
+ pl_free ();
conf_free ();
messagepump_free ();
- plug_free_decoder_ids ();
- pl_free ();
+ plug_cleanup ();
sigterm_handled = 1;
fprintf (stderr, "hej-hej!\n");
return 0;
diff --git a/playlist.c b/playlist.c
index c52b00a3..96a335c1 100644
--- a/playlist.c
+++ b/playlist.c
@@ -446,6 +446,7 @@ void
plt_free (void) {
trace ("plt_free\n");
PLT_LOCK;
+ pl_playqueue_clear ();
plt_loading = 1;
while (playlists_head) {
@@ -2882,7 +2883,11 @@ pl_playqueue_push (playItem_t *it) {
return -1;
}
LOCK;
+ pl_item_ref (it);
playqueue[playqueue_count++] = it;
+ for (int i = 0; i < playqueue_count; i++) {
+ plug_trigger_event_trackinfochanged (playqueue[i]);
+ }
UNLOCK;
return 0;
}
@@ -2890,7 +2895,15 @@ pl_playqueue_push (playItem_t *it) {
void
pl_playqueue_clear (void) {
LOCK;
+ int cnt = playqueue_count;
playqueue_count = 0;
+ int i;
+ for (i = 0; i < cnt; i++) {
+ plug_trigger_event_trackinfochanged (playqueue[i]);
+ }
+ for (i = 0; i < cnt; i++) {
+ pl_item_unref (playqueue[i]);
+ }
UNLOCK;
}
@@ -2902,11 +2915,19 @@ pl_playqueue_pop (void) {
LOCK;
if (playqueue_count == 1) {
playqueue_count = 0;
+ plug_trigger_event_trackinfochanged (playqueue[0]);
+ pl_item_unref (playqueue[0]);
UNLOCK;
return;
}
+ playItem_t *it = playqueue[0];
memmove (&playqueue[0], &playqueue[1], (playqueue_count-1) * sizeof (playItem_t*));
playqueue_count--;
+ plug_trigger_event_trackinfochanged (it);
+ for (int i = 0; i < playqueue_count; i++) {
+ plug_trigger_event_trackinfochanged (playqueue[i]);
+ }
+ pl_item_unref (it);
UNLOCK;
}
@@ -2920,6 +2941,8 @@ pl_playqueue_remove (playItem_t *it) {
if (i < playqueue_count-1) {
memmove (&playqueue[i], &playqueue[i+1], (playqueue_count-i) * sizeof (playItem_t*));
}
+ plug_trigger_event_trackinfochanged (it);
+ pl_item_unref (it);
playqueue_count--;
break;
}
@@ -2928,6 +2951,9 @@ pl_playqueue_remove (playItem_t *it) {
break;
}
}
+ for (int i = 0; i < playqueue_count; i++) {
+ plug_trigger_event_trackinfochanged (playqueue[i]);
+ }
UNLOCK;
}
diff --git a/plugins.c b/plugins.c
index e3ba48f3..273b3d1a 100644
--- a/plugins.c
+++ b/plugins.c
@@ -744,10 +744,18 @@ plug_unload_all (void) {
free (plugins);
plugins = next;
}
- mutex_free (mutex);
fprintf (stderr, "all plugins had been unloaded\n");
}
+void
+plug_cleanup (void) {
+ if (mutex) {
+ mutex_free (mutex);
+ mutex = 0;
+ }
+ plug_free_decoder_ids ();
+}
+
struct DB_decoder_s **
plug_get_decoder_list (void) {
return g_decoder_plugins;
diff --git a/plugins.h b/plugins.h
index d2e2b519..3b275316 100644
--- a/plugins.h
+++ b/plugins.h
@@ -31,6 +31,9 @@ void
plug_unload_all (void);
void
+plug_cleanup (void);
+
+void
plug_ev_subscribe (DB_plugin_t *plugin, int ev, DB_callback_t callback, uintptr_t data);
void