2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "config.h" /* must be first for large file support */
21 #include "update_internal.h"
23 #include "event_pipe.h"
29 #include "song_sticker.h"
36 static const struct song
*removed_song
;
38 static struct notify remove_notify
;
41 * Safely remove a song from the database. This must be done in the
42 * main task, to be sure that there is no pointer left to it.
45 song_remove_event(void)
49 assert(removed_song
!= NULL
);
51 uri
= song_get_uri(removed_song
);
52 g_debug("removing: %s", uri
);
56 /* if the song has a sticker, remove it */
57 if (sticker_enabled())
58 sticker_song_delete(removed_song
);
61 playlist_delete_song(&g_playlist
, removed_song
);
64 notify_signal(&remove_notify
);
68 update_remove_global_init(void)
70 notify_init(&remove_notify
);
72 event_pipe_register(PIPE_EVENT_DELETE
, song_remove_event
);
76 update_remove_global_finish(void)
78 notify_deinit(&remove_notify
);
82 update_remove_song(const struct song
*song
)
84 assert(removed_song
== NULL
);
88 event_pipe_emit(PIPE_EVENT_DELETE
);
91 notify_wait(&remove_notify
);
92 } while (removed_song
!= NULL
);