summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-04-25 21:49:34 +0200
committerGravatar waker <wakeroid@gmail.com>2011-04-25 21:49:34 +0200
commit43a277e9d2dfaa2055184617495e1d3a48b8d9cc (patch)
tree6e98e5d4df0299825c6ec21ca51c37ca23ccf9d2 /plugins
parent3d8f7348c65f7b071ad488c6d09ecfa6e3baaee6 (diff)
new future-proof playlist API, potentially reducing locking, and allowing more flexibility
Diffstat (limited to 'plugins')
-rw-r--r--plugins/cdda/cdda.c18
-rw-r--r--plugins/gtkui/callbacks.c4
-rw-r--r--plugins/gtkui/ddblistview.c2
-rw-r--r--plugins/gtkui/ddbtabstrip.c24
-rw-r--r--plugins/gtkui/fileman.c6
-rw-r--r--plugins/gtkui/gtkui.c58
-rw-r--r--plugins/gtkui/mainplaylist.c4
-rw-r--r--plugins/gtkui/plcommon.c32
-rw-r--r--plugins/gtkui/trkproperties.c6
-rw-r--r--plugins/vfs_curl/vfs_curl.c12
-rw-r--r--plugins/vorbis/vorbis.c7
11 files changed, 111 insertions, 62 deletions
diff --git a/plugins/cdda/cdda.c b/plugins/cdda/cdda.c
index b8b0f84e..9df88719 100644
--- a/plugins/cdda/cdda.c
+++ b/plugins/cdda/cdda.c
@@ -395,7 +395,11 @@ cddb_thread (void *items_i)
}
cddb_disc_destroy (disc);
cleanup_thread_params (params);
- deadbeef->plt_modified (deadbeef->plt_get_handle (deadbeef->plt_get_curr ()));
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_modified (plt);
+ deadbeef->plt_unref (plt);
+ }
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
}
@@ -584,10 +588,14 @@ cda_insert (DB_playItem_t *after, const char *fname) {
static int
cda_action_add_cd (DB_plugin_action_t *act, DB_playItem_t *it)
{
- deadbeef->pl_add_files_begin (deadbeef->plt_get_curr ());
- deadbeef->pl_add_file ("all.cda", NULL, NULL);
- deadbeef->pl_add_files_end ();
- deadbeef->plt_modified (deadbeef->plt_get_handle (deadbeef->plt_get_curr ()));
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->pl_add_files_begin (plt);
+ deadbeef->pl_add_file ("all.cda", NULL, NULL);
+ deadbeef->pl_add_files_end ();
+ deadbeef->plt_modified (plt);
+ deadbeef->plt_unref (plt);
+ }
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
}
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index 1cbbe523..3bf04373 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -354,7 +354,7 @@ on_mainwin_key_press_event (GtkWidget *widget,
else if ((maskedstate == GDK_MOD1_MASK || maskedstate == 0) && event->keyval >= GDK_1 && event->keyval <= GDK_9) {
int pl = event->keyval - GDK_1;
if (pl >= 0 && pl < deadbeef->plt_get_count ()) {
- deadbeef->plt_set_curr (pl);
+ deadbeef->plt_set_curr_idx (pl);
deadbeef->conf_set_int ("playlist.current", pl);
}
}
@@ -983,7 +983,7 @@ on_new_playlist1_activate (GtkMenuItem *menuitem,
{
int pl = gtkui_add_new_playlist ();
if (pl != -1) {
- deadbeef->plt_set_curr (pl);
+ deadbeef->plt_set_curr_idx (pl);
deadbeef->conf_set_int ("playlist.current", pl);
}
}
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c
index 588439c6..14dd9a70 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -1687,7 +1687,7 @@ ddb_listview_list_mousemove (DdbListview *ps, GdkEventMotion *ev, int ex, int ey
GtkWidget *widget = ps->list;
if (gtk_drag_check_threshold (widget, ps->lastpos[0], ex, ps->lastpos[1], ey)) {
ps->dragwait = 0;
- ps->drag_source_playlist = deadbeef->plt_get_curr ();
+ ps->drag_source_playlist = deadbeef->plt_get_curr_idx ();
GtkTargetEntry entry = {
.target = "DDB_URI_LIST",
.flags = GTK_TARGET_SAME_WIDGET,
diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c
index 8885d51f..8539a10d 100644
--- a/plugins/gtkui/ddbtabstrip.c
+++ b/plugins/gtkui/ddbtabstrip.c
@@ -48,7 +48,7 @@ plt_get_title_wrapper (int plt, char *buffer, int len) {
return;
}
deadbeef->pl_lock ();
- void *p = deadbeef->plt_get_handle (plt);
+ void *p = deadbeef->plt_get_for_idx (plt);
deadbeef->plt_get_title (p, buffer, len);
deadbeef->pl_unlock ();
char *end;
@@ -353,7 +353,7 @@ ddb_tabstrip_draw_tab (GtkWidget *widget, GdkDrawable *drawable, int idx, int se
GdkColor clr;
int fallback = 1;
deadbeef->pl_lock ();
- void *plt = deadbeef->plt_get_handle (idx);
+ void *plt = deadbeef->plt_get_for_idx (idx);
const char *bgclr = deadbeef->plt_find_meta (plt, "gui.bgcolor");
if (bgclr) {
int r, g, b;
@@ -476,7 +476,7 @@ tabstrip_adjust_hscroll (DdbTabStrip *ts) {
ts->hscrollpos = w - (widget->allocation.width - arrow_widget_width*2);
deadbeef->conf_set_int ("gtkui.tabscroll", ts->hscrollpos);
}
- tabstrip_scroll_to_tab_int (ts, deadbeef->plt_get_curr (), 0);
+ tabstrip_scroll_to_tab_int (ts, deadbeef->plt_get_curr_idx (), 0);
}
else {
ts->hscrollpos = 0;
@@ -491,7 +491,7 @@ set_tab_text_color (int idx, int selected) {
return;
}
deadbeef->pl_lock ();
- void *plt = deadbeef->plt_get_handle (idx);
+ void *plt = deadbeef->plt_get_for_idx (idx);
int fallback = 1;
const char *clr = deadbeef->plt_find_meta (plt, "gui.color");
if (clr) {
@@ -534,7 +534,7 @@ tabstrip_render (DdbTabStrip *ts) {
text_right_padding = h - 3;
const char *detail = "button";
- int tab_selected = deadbeef->plt_get_curr ();
+ int tab_selected = deadbeef->plt_get_curr_idx ();
if (tab_selected == -1) {
return;
}
@@ -655,7 +655,7 @@ get_tab_under_cursor (DdbTabStrip *ts, int x) {
int idx;
int cnt = deadbeef->plt_get_count ();
int fw = tabs_left_margin - hscroll;
- int tab_selected = deadbeef->plt_get_curr ();
+ int tab_selected = deadbeef->plt_get_curr_idx ();
for (idx = 0; idx < cnt; idx++) {
char title[100];
plt_get_title_wrapper (idx, title, sizeof (title));
@@ -693,7 +693,7 @@ on_rename_playlist1_activate (GtkMenuItem *menuitem,
if (res == GTK_RESPONSE_OK) {
const char *text = gtk_entry_get_text (GTK_ENTRY (e));
deadbeef->pl_lock ();
- void *p = deadbeef->plt_get_handle (tab_clicked);
+ void *p = deadbeef->plt_get_for_idx (tab_clicked);
deadbeef->plt_set_title (p, text);
deadbeef->pl_unlock ();
}
@@ -710,7 +710,7 @@ on_remove_playlist1_activate (GtkMenuItem *menuitem,
DdbListview *pl = DDB_LISTVIEW (lookup_widget (mainwin, "playlist"));
ddb_listview_refresh (pl, DDB_LIST_CHANGED | DDB_REFRESH_LIST | DDB_REFRESH_VSCROLL);
search_refresh ();
- int playlist = deadbeef->plt_get_curr ();
+ int playlist = deadbeef->plt_get_curr_idx ();
deadbeef->conf_set_int ("playlist.current", playlist);
}
}
@@ -772,7 +772,7 @@ create_plmenu (void)
static void
tabstrip_scroll_left (DdbTabStrip *ts) {
- int tab = deadbeef->plt_get_curr ();
+ int tab = deadbeef->plt_get_curr_idx ();
if (tab > 0) {
tab--;
gtkui_playlist_set_curr (tab);
@@ -782,7 +782,7 @@ tabstrip_scroll_left (DdbTabStrip *ts) {
static void
tabstrip_scroll_right (DdbTabStrip *ts) {
- int tab = deadbeef->plt_get_curr ();
+ int tab = deadbeef->plt_get_curr_idx ();
if (tab < deadbeef->plt_get_count ()-1) {
tab++;
gtkui_playlist_set_curr (tab);
@@ -907,7 +907,7 @@ on_tabstrip_button_press_event(GtkWidget *widget,
DdbListview *pl = DDB_LISTVIEW (lookup_widget (mainwin, "playlist"));
ddb_listview_refresh (pl, DDB_LIST_CHANGED | DDB_REFRESH_LIST | DDB_REFRESH_VSCROLL);
search_refresh ();
- int playlist = deadbeef->plt_get_curr ();
+ int playlist = deadbeef->plt_get_curr_idx ();
deadbeef->conf_set_int ("playlist.current", playlist);
}
}
@@ -1039,7 +1039,7 @@ on_tabstrip_drag_motion_event (GtkWidget *widget,
guint time)
{
int tab = get_tab_under_cursor (DDB_TABSTRIP (widget), x);
- int prev = deadbeef->plt_get_curr ();
+ int prev = deadbeef->plt_get_curr_idx ();
if (tab != -1 && tab != prev) {
gtkui_playlist_set_curr (tab);
}
diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c
index 6ff981b4..a832df09 100644
--- a/plugins/gtkui/fileman.c
+++ b/plugins/gtkui/fileman.c
@@ -26,9 +26,8 @@ gtkpl_add_dirs (GSList *lst) {
deadbeef->pl_add_files_begin (deadbeef->plt_get_curr ());
if (g_slist_length (lst) == 1
&& deadbeef->conf_get_int ("gtkui.name_playlist_from_folder", 0)) {
- int plt = deadbeef->plt_get_curr ();
- if (plt != -1) {
- void *p = deadbeef->plt_get_handle (plt);
+ ddb_playlist_t *p = deadbeef->plt_get_curr ();
+ if (p) {
char t[1000];
if (!deadbeef->plt_get_title (p, t, sizeof (t))) {
char *def = _("New Playlist");
@@ -40,6 +39,7 @@ gtkpl_add_dirs (GSList *lst) {
deadbeef->plt_set_title (p, folder+1);
}
}
+ deadbeef->plt_unref (p);
}
}
deadbeef->pl_unlock ();
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 4d682d6e..7b0583c2 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -473,7 +473,7 @@ gtkui_playlist_changed (void) {
static gboolean
playlistswitch_cb (gpointer none) {
GtkWidget *tabstrip = lookup_widget (mainwin, "tabstrip");
- int curr = deadbeef->plt_get_curr ();
+ int curr = deadbeef->plt_get_curr_idx ();
char conf[100];
snprintf (conf, sizeof (conf), "playlist.scroll.%d", curr);
int scroll = deadbeef->conf_get_int (conf, 0);
@@ -577,10 +577,11 @@ gtkui_hide_status_icon () {
int
gtkui_get_curr_playlist_mod (void) {
- deadbeef->pl_lock ();
- void *plt = deadbeef->plt_get_handle (deadbeef->plt_get_curr ());
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
int res = plt ? deadbeef->plt_get_modification_idx (plt) : 0;
- deadbeef->pl_unlock ();
+ if (plt) {
+ deadbeef->plt_unref (plt);
+ }
return res;
}
@@ -672,9 +673,13 @@ save_playlist_as (void) {
gtk_widget_destroy (dlg);
if (fname) {
- int res = deadbeef->pl_save (fname);
- if (res >= 0 && strlen (fname) < 1024) {
- strcpy (last_playlist_save_name, fname);
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ int res = deadbeef->plt_save (plt, NULL, NULL, fname, NULL, NULL, NULL);
+ if (res >= 0 && strlen (fname) < 1024) {
+ strcpy (last_playlist_save_name, fname);
+ }
+ deadbeef->plt_unref (plt);
}
g_free (fname);
}
@@ -692,7 +697,11 @@ on_playlist_save_activate (GtkMenuItem *menuitem,
save_playlist_as ();
}
else {
- /*int res = */deadbeef->pl_save (last_playlist_save_name);
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_save (plt, NULL, NULL, last_playlist_save_name, NULL, NULL, NULL);
+ deadbeef->plt_unref (plt);
+ }
}
}
@@ -763,7 +772,15 @@ on_playlist_load_activate (GtkMenuItem *menuitem,
gchar *fname = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
gtk_widget_destroy (dlg);
if (fname) {
- /*int res = */deadbeef->pl_load (fname);
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_clear (plt);
+ DB_playItem_t *it = deadbeef->plt_load (plt, NULL, fname, NULL, NULL, NULL);
+ if (it) {
+ deadbeef->pl_item_unref (it);
+ }
+ deadbeef->plt_unref (plt);
+ }
g_free (fname);
main_refresh ();
search_refresh ();
@@ -798,22 +815,21 @@ on_add_location_activate (GtkMenuItem *menuitem,
static void
songchanged (DdbListview *ps, DB_playItem_t *from, DB_playItem_t *to) {
- int plt = deadbeef->plt_get_curr ();
int to_idx = -1;
if (!ddb_listview_is_scrolling (ps) && to) {
int cursor_follows_playback = deadbeef->conf_get_int ("playlist.scroll.cursorfollowplayback", 0);
int scroll_follows_playback = deadbeef->conf_get_int ("playlist.scroll.followplayback", 0);
int plt = deadbeef->streamer_get_current_playlist ();
if (plt != -1) {
- if (cursor_follows_playback && plt != deadbeef->plt_get_curr ()) {
- deadbeef->plt_set_curr (plt);
+ if (cursor_follows_playback && plt != deadbeef->plt_get_curr_idx ()) {
+ deadbeef->plt_set_curr_idx (plt);
}
to_idx = deadbeef->pl_get_idx_of (to);
if (to_idx != -1) {
if (cursor_follows_playback) {
ddb_listview_set_cursor_noscroll (ps, to_idx);
}
- if (scroll_follows_playback && plt == deadbeef->plt_get_curr ()) {
+ if (scroll_follows_playback && plt == deadbeef->plt_get_curr_idx ()) {
ddb_listview_scroll_to (ps, to_idx);
}
}
@@ -891,7 +907,7 @@ gtkui_add_new_playlist (void) {
deadbeef->pl_lock ();
for (i = 0; i < cnt; i++) {
char t[100];
- void *plt = deadbeef->plt_get_handle (i);
+ void *plt = deadbeef->plt_get_for_idx (i);
deadbeef->plt_get_title (plt, t, sizeof (t));
if (!strcasecmp (t, name)) {
break;
@@ -1127,7 +1143,7 @@ gtkui_add_file_info_cb (DB_playItem_t *it, void *data) {
int (*gtkui_original_pl_add_dir) (const char *dirname, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
int (*gtkui_original_pl_add_file) (const char *fname, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
-void (*gtkui_original_pl_add_files_begin) (int plt);
+int (*gtkui_original_pl_add_files_begin) (ddb_playlist_t *plt);
void (*gtkui_original_pl_add_files_end) (void);
int
@@ -1142,10 +1158,10 @@ gtkui_pl_add_file (const char *filename, int (*cb)(DB_playItem_t *it, void *data
return res;
}
-void
-gtkui_pl_add_files_begin (int plt) {
+int
+gtkui_pl_add_files_begin (ddb_playlist_t *plt) {
g_idle_add (gtkui_progress_show_idle, NULL);
- gtkui_original_pl_add_files_begin (plt);
+ return gtkui_original_pl_add_files_begin (plt);
}
void
@@ -1159,8 +1175,8 @@ gtkui_focus_on_playing_track (void) {
DB_playItem_t *it = deadbeef->streamer_get_playing_track ();
if (it) {
int plt = deadbeef->streamer_get_current_playlist ();
- if (plt != deadbeef->plt_get_curr ()) {
- deadbeef->plt_set_curr (plt);
+ if (plt != deadbeef->plt_get_curr_idx ()) {
+ deadbeef->plt_set_curr_idx (plt);
}
int idx = deadbeef->pl_get_idx_of (it);
if (idx != -1) {
@@ -1174,7 +1190,7 @@ gtkui_focus_on_playing_track (void) {
void
gtkui_playlist_set_curr (int playlist) {
- deadbeef->plt_set_curr (playlist);
+ deadbeef->plt_set_curr_idx (playlist);
deadbeef->conf_set_int ("playlist.current", playlist);
}
diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c
index e1537ea0..57b693f8 100644
--- a/plugins/gtkui/mainplaylist.c
+++ b/plugins/gtkui/mainplaylist.c
@@ -109,7 +109,7 @@ int main_get_idx (DdbListviewIter it) {
void
main_drag_n_drop (DdbListviewIter before, int from_playlist, uint32_t *indices, int length, int copy) {
deadbeef->pl_lock ();
- int curr = deadbeef->plt_get_curr ();
+// int curr = deadbeef->plt_get_curr_idx ();
if (copy) {
deadbeef->pl_copy_items (PL_MAIN, from_playlist, (DB_playItem_t *)before, indices, length);
}
@@ -238,7 +238,7 @@ void main_col_free_user_data (void *data) {
void
main_vscroll_changed (int pos) {
coverart_reset_queue ();
- int curr = deadbeef->plt_get_curr ();
+ int curr = deadbeef->plt_get_curr_idx ();
char conf[100];
snprintf (conf, sizeof (conf), "playlist.scroll.%d", curr);
deadbeef->conf_set_int (conf, pos);
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index 6945e5d3..e319ac56 100644
--- a/plugins/gtkui/plcommon.c
+++ b/plugins/gtkui/plcommon.c
@@ -538,9 +538,11 @@ on_group_by_none_activate (GtkMenuItem *menuitem,
strcpy (group_by_str, "");
deadbeef->conf_set_str ("playlist.group_by", group_by_str);
- deadbeef->pl_lock ();
- deadbeef->plt_modified (deadbeef->plt_get_handle (deadbeef->plt_get_curr ()));
- deadbeef->pl_unlock ();
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_modified (plt);
+ deadbeef->plt_unref (plt);
+ }
main_refresh ();
}
@@ -550,9 +552,11 @@ on_group_by_artist_date_album_activate (GtkMenuItem *menuitem,
{
strcpy (group_by_str, "%a - [%y] %b");
deadbeef->conf_set_str ("playlist.group_by", group_by_str);
- deadbeef->pl_lock ();
- deadbeef->plt_modified (deadbeef->plt_get_handle (deadbeef->plt_get_curr ()));
- deadbeef->pl_unlock ();
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_modified (plt);
+ deadbeef->plt_unref (plt);
+ }
main_refresh ();
}
@@ -562,9 +566,11 @@ on_group_by_artist_activate (GtkMenuItem *menuitem,
{
strcpy (group_by_str, "%a");
deadbeef->conf_set_str ("playlist.group_by", group_by_str);
- deadbeef->pl_lock ();
- deadbeef->plt_modified (deadbeef->plt_get_handle (deadbeef->plt_get_curr ()));
- deadbeef->pl_unlock ();
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_modified (plt);
+ deadbeef->plt_unref (plt);
+ }
main_refresh ();
}
@@ -585,9 +591,11 @@ on_group_by_custom_activate (GtkMenuItem *menuitem,
strncpy (group_by_str, text, sizeof (group_by_str));
group_by_str[sizeof (group_by_str)-1] = 0;
deadbeef->conf_set_str ("playlist.group_by", group_by_str);
- deadbeef->pl_lock ();
- deadbeef->plt_modified (deadbeef->plt_get_handle (deadbeef->plt_get_curr ()));
- deadbeef->pl_unlock ();
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_modified (plt);
+ deadbeef->plt_unref (plt);
+ }
main_refresh ();
}
gtk_widget_destroy (dlg);
diff --git a/plugins/gtkui/trkproperties.c b/plugins/gtkui/trkproperties.c
index 12e51924..4e865eee 100644
--- a/plugins/gtkui/trkproperties.c
+++ b/plugins/gtkui/trkproperties.c
@@ -462,7 +462,11 @@ static gboolean
write_finished_cb (void *ctx) {
gtk_widget_destroy (progressdlg);
progressdlg = NULL;
- deadbeef->plt_modified (deadbeef->plt_get_handle (deadbeef->plt_get_curr ()));
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_modified (plt);
+ deadbeef->plt_unref (plt);
+ }
main_refresh ();
search_refresh ();
trkproperties_modified = 0;
diff --git a/plugins/vfs_curl/vfs_curl.c b/plugins/vfs_curl/vfs_curl.c
index 0ef5cc6a..acb0b561 100644
--- a/plugins/vfs_curl/vfs_curl.c
+++ b/plugins/vfs_curl/vfs_curl.c
@@ -212,7 +212,11 @@ http_parse_shoutcast_meta (HTTP_FILE *fp, const char *meta, int size) {
else {
vfs_curl_set_meta (fp->track, "title", title);
}
- deadbeef->plt_modified (deadbeef->plt_get_handle (deadbeef->plt_get_curr ()));
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_modified (plt);
+ deadbeef->plt_unref (plt);
+ }
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
}
return 0;
@@ -468,7 +472,11 @@ http_content_header_handler (void *ptr, size_t size, size_t nmemb, void *stream)
fp->wait_meta = fp->icy_metaint;
}
}
- deadbeef->plt_modified (deadbeef->plt_get_handle (deadbeef->plt_get_curr ()));
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_modified (plt);
+ deadbeef->plt_unref (plt);
+ }
if (refresh_playlist) {
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
}
diff --git a/plugins/vorbis/vorbis.c b/plugins/vorbis/vorbis.c
index 27275eec..ee1871a4 100644
--- a/plugins/vorbis/vorbis.c
+++ b/plugins/vorbis/vorbis.c
@@ -165,7 +165,12 @@ update_vorbis_comments (DB_playItem_t *it, vorbis_comment *vc, int refresh_playl
f &= ~DDB_TAG_MASK;
f |= DDB_TAG_VORBISCOMMENTS;
deadbeef->pl_set_item_flags (it, f);
- deadbeef->plt_modified (deadbeef->plt_get_handle (deadbeef->plt_get_curr ()));
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ if (plt) {
+ deadbeef->plt_modified (plt);
+ deadbeef->plt_unref (plt);
+ }
+
if (refresh_playlist) {
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
}