summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c6
-rw-r--r--plugins.c18
-rw-r--r--plugins/gtkui/callbacks.c7
-rw-r--r--plugins/gtkui/gtkui.c5
4 files changed, 34 insertions, 2 deletions
diff --git a/main.c b/main.c
index 24dff4a0..129273b4 100644
--- a/main.c
+++ b/main.c
@@ -148,6 +148,9 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi
else {
strcpy (sendback, "nowplaying nothing");
}
+ if (curr) {
+ pl_item_unref (curr);
+ }
}
else {
char out[2048];
@@ -159,6 +162,9 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi
else {
strcpy (out, "nothing");
}
+ if (curr) {
+ pl_item_unref (curr);
+ }
fwrite (out, 1, strlen (out), stdout);
return 1; // exit
}
diff --git a/plugins.c b/plugins.c
index 02dddb88..3a379a06 100644
--- a/plugins.c
+++ b/plugins.c
@@ -374,8 +374,14 @@ float
plug_playback_get_pos (void) {
playItem_t *trk = streamer_get_playing_track ();
if (!trk || trk->_duration <= 0) {
+ if (trk) {
+ pl_item_unref (trk);
+ }
return 0;
}
+ if (trk) {
+ pl_item_unref (trk);
+ }
return streamer_get_playpos () * 100 / trk->_duration;
}
@@ -383,9 +389,15 @@ void
plug_playback_set_pos (float pos) {
playItem_t *trk = streamer_get_playing_track ();
if (!trk || trk->_duration <= 0) {
+ if (trk) {
+ pl_item_unref (trk);
+ }
return;
}
float t = pos * trk->_duration / 100.f;
+ if (trk) {
+ pl_item_unref (trk);
+ }
streamer_set_seek (t);
}
@@ -416,13 +428,14 @@ plug_event_call (DB_event_t *ev) {
void
plug_trigger_event (int ev, uintptr_t param) {
DB_event_t *event;
+ playItem_t *pltrack = streamer_get_playing_track ();
switch (ev) {
case DB_EV_SONGSTARTED:
case DB_EV_SONGFINISHED:
{
DB_event_track_t *pev = alloca (sizeof (DB_event_track_t));
pev->index = -1;
- pev->track = DB_PLAYITEM (streamer_get_playing_track ());
+ pev->track = DB_PLAYITEM (pltrack);
event = DB_EVENT (pev);
}
break;
@@ -439,6 +452,9 @@ plug_trigger_event (int ev, uintptr_t param) {
}
event->event = ev;
plug_event_call (event);
+ if (pltrack) {
+ pl_item_unref (pltrack);
+ }
}
void
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index 761bd930..2b277a4c 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -496,6 +496,9 @@ seekbar_draw (GtkWidget *widget) {
DB_playItem_t *trk = deadbeef->streamer_get_playing_track ();
if (!trk || deadbeef->pl_get_item_duration (trk) < 0) {
+ if (trk) {
+ deadbeef->pl_item_unref (trk);
+ }
clearlooks_rounded_rectangle (cr, 2, widget->allocation.height/2-4, widget->allocation.width-4, 8, 4, 0xff);
// empty seekbar, just a frame
cairo_set_source_rgb (cr, clr_selection->red/65535.f, clr_selection->green/65535.f, clr_selection->blue/65535.f );
@@ -539,6 +542,9 @@ seekbar_draw (GtkWidget *widget) {
cairo_reset_clip (cr);
cairo_destroy (cr);
+ if (trk) {
+ deadbeef->pl_item_unref (trk);
+ }
}
void
@@ -613,6 +619,7 @@ on_seekbar_button_release_event (GtkWidget *widget,
time = 0;
}
deadbeef->streamer_seek (time);
+ deadbeef->pl_item_unref (trk);
}
return FALSE;
}
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index d08af942..ea8da97e 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -136,7 +136,7 @@ update_songinfo (gpointer ctx) {
}
DB_playItem_t *track = deadbeef->streamer_get_playing_track ();
- DB_fileinfo_t *c = deadbeef->streamer_get_current_fileinfo ();
+ DB_fileinfo_t *c = deadbeef->streamer_get_current_fileinfo (); // FIXME: might crash streamer
float duration = track ? deadbeef->pl_get_item_duration (track) : -1;
@@ -208,6 +208,9 @@ update_songinfo (gpointer ctx) {
last_songpos = songpos;
}
}
+ if (track) {
+ deadbeef->pl_item_unref (track);
+ }
return FALSE;
}