1 /*
2 hotkey action handlers for deadbeef hotkeys plugin
3 Copyright (C) 2009-2013 Alexey Yakovenko and other contributors
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17
18 2. Altered source versions must be plainly marked as such, and must not be
19 misrepresented as being the original software.
20
21 3. This notice may not be removed or altered from any source distribution.
22 */
23 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
26
27 #include <string.h>
28 #include "../../gettext.h"
29 #include "../../deadbeef.h"
30
31 extern DB_functions_t *deadbeef;
32
33 int
action_jump_to_current_handler(DB_plugin_action_t * act,int ctx)34 action_jump_to_current_handler (DB_plugin_action_t *act, int ctx)
35 {
36 deadbeef->sendmessage (DB_EV_TRACKFOCUSCURRENT, 0, 0, 0);
37 return 0;
38 }
39
40 static DB_playItem_t*
skip_to_get_track_helper()41 skip_to_get_track_helper ()
42 {
43 DB_playItem_t *current = deadbeef->streamer_get_playing_track ();
44 if (!current) {
45 return NULL;
46 }
47
48 ddb_playlist_t *plt_curr = deadbeef->plt_get_curr ();
49 ddb_playlist_t *plt = deadbeef->pl_get_playlist (current);
50
51 DB_playItem_t *it = NULL;
52 if (plt && plt_curr && plt != plt_curr) {
53 deadbeef->pl_item_unref (current);
54 it = deadbeef->plt_get_first (plt_curr, PL_MAIN);
55 while (it) {
56 if (deadbeef->pl_is_selected (it)) {
57 break;
58 }
59 DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
60 deadbeef->pl_item_unref (it);
61 it = next;
62 }
63 }
64 else {
65 it = current;
66 }
67
68 if (plt) {
69 deadbeef->plt_unref (plt);
70 }
71 if (plt_curr) {
72 deadbeef->plt_unref (plt_curr);
73 }
74 return it;
75 }
76
77 static void
skip_to_prev_helper(const char * meta)78 skip_to_prev_helper (const char *meta)
79 {
80 if (!meta) {
81 return;
82 }
83 deadbeef->pl_lock ();
84 DB_output_t *output = deadbeef->get_output ();
85 if (output->state () == OUTPUT_STATE_STOPPED) {
86 deadbeef->pl_unlock ();
87 return;
88 }
89
90 DB_playItem_t *it = skip_to_get_track_helper ();
91 if (!it) {
92 deadbeef->pl_unlock ();
93 return;
94 }
95
96 const char *cur_meta = deadbeef->pl_find_meta_raw (it, meta);
97 int c = 0;
98 while (it) {
99 DB_playItem_t *prev = deadbeef->pl_get_prev (it, PL_MAIN);
100 if (!prev) {
101 if (c == 1) {
102 deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (it), 0);
103 }
104 deadbeef->pl_item_unref (it);
105 break;
106 }
107 const char *prev_meta = deadbeef->pl_find_meta_raw (prev, meta);
108 if (cur_meta != prev_meta) {
109 if (c == 0) {
110 cur_meta = prev_meta;
111 c = 1;
112 }
113 else {
114 deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (it), 0);
115 deadbeef->pl_item_unref (it);
116 deadbeef->pl_item_unref (prev);
117 break;
118 }
119 }
120 deadbeef->pl_item_unref (it);
121 it = prev;
122 }
123 deadbeef->pl_unlock ();
124 }
125
126 static void
skip_to_next_helper(const char * meta)127 skip_to_next_helper (const char *meta)
128 {
129 if (!meta) {
130 return;
131 }
132 deadbeef->pl_lock ();
133 DB_output_t *output = deadbeef->get_output ();
134 if (output->state () == OUTPUT_STATE_STOPPED) {
135 deadbeef->pl_unlock ();
136 return;
137 }
138
139 DB_playItem_t *it = skip_to_get_track_helper ();
140 if (!it) {
141 deadbeef->pl_unlock ();
142 return;
143 }
144
145 const char *cur_meta = deadbeef->pl_find_meta_raw (it, meta);
146 while (it) {
147 DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
148 if (!next) {
149 deadbeef->pl_item_unref (it);
150 break;
151 }
152 const char *next_meta = deadbeef->pl_find_meta_raw (next, meta);
153 if (cur_meta != next_meta) {
154 deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (next), 0);
155 deadbeef->pl_item_unref (it);
156 deadbeef->pl_item_unref (next);
157 break;
158 }
159 deadbeef->pl_item_unref (it);
160 it = next;
161 }
162 deadbeef->pl_unlock ();
163 }
164
165 int
action_skip_to_next_album_handler(DB_plugin_action_t * act,int ctx)166 action_skip_to_next_album_handler (DB_plugin_action_t *act, int ctx)
167 {
168 skip_to_next_helper ("album");
169 return 0;
170 }
171
172 int
action_skip_to_next_genre_handler(DB_plugin_action_t * act,int ctx)173 action_skip_to_next_genre_handler (DB_plugin_action_t *act, int ctx)
174 {
175 skip_to_next_helper ("genre");
176 return 0;
177 }
178
179 int
action_skip_to_next_composer_handler(DB_plugin_action_t * act,int ctx)180 action_skip_to_next_composer_handler (DB_plugin_action_t *act, int ctx)
181 {
182 skip_to_next_helper ("composer");
183 return 0;
184 }
185
186 int
action_skip_to_prev_album_handler(DB_plugin_action_t * act,int ctx)187 action_skip_to_prev_album_handler (DB_plugin_action_t *act, int ctx)
188 {
189 skip_to_prev_helper ("album");
190 return 0;
191 }
192
193 int
action_skip_to_prev_genre_handler(DB_plugin_action_t * act,int ctx)194 action_skip_to_prev_genre_handler (DB_plugin_action_t *act, int ctx)
195 {
196 skip_to_prev_helper ("genre");
197 return 0;
198 }
199
200 int
action_skip_to_prev_composer_handler(DB_plugin_action_t * act,int ctx)201 action_skip_to_prev_composer_handler (DB_plugin_action_t *act, int ctx)
202 {
203 skip_to_prev_helper ("composer");
204 return 0;
205 }
206
207 int
action_skip_to_next_artist_handler(DB_plugin_action_t * act,int ctx)208 action_skip_to_next_artist_handler (DB_plugin_action_t *act, int ctx)
209 {
210 deadbeef->pl_lock ();
211 DB_output_t *output = deadbeef->get_output ();
212 if (output->state () == OUTPUT_STATE_STOPPED) {
213 deadbeef->pl_unlock ();
214 return 0;
215 }
216
217 DB_playItem_t *it = skip_to_get_track_helper ();
218 if (!it) {
219 deadbeef->pl_unlock ();
220 return 0;
221 }
222
223 const char *cur_artist = deadbeef->pl_find_meta_raw (it, "band");
224 if (!cur_artist) {
225 cur_artist = deadbeef->pl_find_meta_raw (it, "album artist");
226 }
227 if (!cur_artist) {
228 cur_artist = deadbeef->pl_find_meta_raw (it, "albumartist");
229 }
230 if (!cur_artist) {
231 cur_artist = deadbeef->pl_find_meta_raw (it, "artist");
232 }
233 while (it) {
234 DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
235 if (!next) {
236 deadbeef->pl_item_unref (it);
237 break;
238 }
239 const char *next_artist = deadbeef->pl_find_meta_raw (next, "band");
240 if (!next_artist) {
241 next_artist = deadbeef->pl_find_meta_raw (next, "album artist");
242 }
243 if (!next_artist) {
244 next_artist = deadbeef->pl_find_meta_raw (next, "albumartist");
245 }
246 if (!next_artist) {
247 next_artist = deadbeef->pl_find_meta_raw (next, "artist");
248 }
249
250 if (cur_artist != next_artist) {
251 deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (next), 0);
252 deadbeef->pl_item_unref (it);
253 deadbeef->pl_item_unref (next);
254 break;
255 }
256 deadbeef->pl_item_unref (it);
257 it = next;
258 }
259 deadbeef->pl_unlock ();
260 return 0;
261 }
262
263 int
action_skip_to_prev_artist_handler(DB_plugin_action_t * act,int ctx)264 action_skip_to_prev_artist_handler (DB_plugin_action_t *act, int ctx)
265 {
266 deadbeef->pl_lock ();
267 DB_output_t *output = deadbeef->get_output ();
268 if (output->state () == OUTPUT_STATE_STOPPED) {
269 deadbeef->pl_unlock ();
270 return 0;
271 }
272
273 DB_playItem_t *it = skip_to_get_track_helper ();
274 if (!it) {
275 deadbeef->pl_unlock ();
276 return 0;
277 }
278
279 const char *cur_artist = deadbeef->pl_find_meta_raw (it, "band");
280 if (!cur_artist) {
281 cur_artist = deadbeef->pl_find_meta_raw (it, "album artist");
282 }
283 if (!cur_artist) {
284 cur_artist = deadbeef->pl_find_meta_raw (it, "albumartist");
285 }
286 if (!cur_artist) {
287 cur_artist = deadbeef->pl_find_meta_raw (it, "artist");
288 }
289 int c = 0;
290 while (it) {
291 DB_playItem_t *prev = deadbeef->pl_get_prev (it, PL_MAIN);
292 if (!prev) {
293 if (c == 1) {
294 deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (it), 0);
295 }
296 deadbeef->pl_item_unref (it);
297 break;
298 }
299 const char *prev_artist = deadbeef->pl_find_meta_raw (prev, "band");
300 if (!prev_artist) {
301 prev_artist = deadbeef->pl_find_meta_raw (prev, "album artist");
302 }
303 if (!prev_artist) {
304 prev_artist = deadbeef->pl_find_meta_raw (prev, "albumartist");
305 }
306 if (!prev_artist) {
307 prev_artist = deadbeef->pl_find_meta_raw (prev, "artist");
308 }
309
310 if (cur_artist != prev_artist) {
311 if (c == 0) {
312 cur_artist = prev_artist;
313 c = 1;
314 }
315 else {
316 deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (it), 0);
317 deadbeef->pl_item_unref (it);
318 deadbeef->pl_item_unref (prev);
319 break;
320 }
321 }
322 deadbeef->pl_item_unref (it);
323 it = prev;
324 }
325 deadbeef->pl_unlock ();
326 return 0;
327 }
328
329 int
action_reload_metadata_handler(DB_plugin_action_t * act,int ctx)330 action_reload_metadata_handler (DB_plugin_action_t *act, int ctx) {
331 DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
332 while (it) {
333 deadbeef->pl_lock ();
334 char decoder_id[100];
335 const char *dec = deadbeef->pl_find_meta (it, ":DECODER");
336 if (dec) {
337 strncpy (decoder_id, dec, sizeof (decoder_id));
338 }
339 int match;
340 if (ctx == DDB_ACTION_CTX_PLAYLIST) {
341 match = deadbeef->is_local_file (deadbeef->pl_find_meta (it, ":URI")) && dec;
342 }
343 else {
344 match = deadbeef->pl_is_selected (it) && deadbeef->is_local_file (deadbeef->pl_find_meta (it, ":URI")) && dec;
345 }
346 deadbeef->pl_unlock ();
347
348 if (match) {
349 uint32_t f = deadbeef->pl_get_item_flags (it);
350 if (!(f & DDB_IS_SUBTRACK)) {
351 f &= ~DDB_TAG_MASK;
352 deadbeef->pl_set_item_flags (it, f);
353 DB_decoder_t **decoders = deadbeef->plug_get_decoder_list ();
354 for (int i = 0; decoders[i]; i++) {
355 if (!strcmp (decoders[i]->plugin.id, decoder_id)) {
356 if (decoders[i]->read_metadata) {
357 decoders[i]->read_metadata (it);
358 }
359 break;
360 }
361 }
362 }
363 }
364 DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
365 deadbeef->pl_item_unref (it);
366 it = next;
367 }
368 deadbeef->sendmessage (DB_EV_PLAYLIST_REFRESH, 0, 0, 0);
369 return 0;
370 }
371
372 int
action_next_playlist_handler(DB_plugin_action_t * act,int ctx)373 action_next_playlist_handler (DB_plugin_action_t *act, int ctx) {
374 int tab = deadbeef->plt_get_curr_idx ();
375
376 if (tab == deadbeef->plt_get_count ()-1) {
377 tab = 0;
378 }
379 else {
380 tab++;
381 }
382
383 deadbeef->plt_set_curr_idx (tab);
384 deadbeef->conf_set_int ("playlist.current", tab);
385
386 return 0;
387 }
388
389 int
action_prev_playlist_handler(DB_plugin_action_t * act,int ctx)390 action_prev_playlist_handler (DB_plugin_action_t *act, int ctx) {
391 int tab = deadbeef->plt_get_curr_idx ();
392
393 if (tab == 0) {
394 tab = deadbeef->plt_get_count ()-1;
395 }
396 else {
397 tab--;
398 }
399
400 deadbeef->plt_set_curr_idx (tab);
401 deadbeef->conf_set_int ("playlist.current", tab);
402
403 return 0;
404 }
405
406 int
action_playlist1_handler(DB_plugin_action_t * act,int ctx)407 action_playlist1_handler (DB_plugin_action_t *act, int ctx) {
408 int pl = 0;
409 if (pl < deadbeef->plt_get_count ()) {
410 deadbeef->plt_set_curr_idx (pl);
411 deadbeef->conf_set_int ("playlist.current", pl);
412 }
413 return 0;
414 }
415
416 int
action_playlist2_handler(DB_plugin_action_t * act,int ctx)417 action_playlist2_handler (DB_plugin_action_t *act, int ctx) {
418 int pl = 1;
419 if (pl < deadbeef->plt_get_count ()) {
420 deadbeef->plt_set_curr_idx (pl);
421 deadbeef->conf_set_int ("playlist.current", pl);
422 }
423 return 0;
424 }
425
426 int
action_playlist3_handler(DB_plugin_action_t * act,int ctx)427 action_playlist3_handler (DB_plugin_action_t *act, int ctx) {
428 int pl = 2;
429 if (pl < deadbeef->plt_get_count ()) {
430 deadbeef->plt_set_curr_idx (pl);
431 deadbeef->conf_set_int ("playlist.current", pl);
432 }
433 return 0;
434 }
435
436 int
action_playlist4_handler(DB_plugin_action_t * act,int ctx)437 action_playlist4_handler (DB_plugin_action_t *act, int ctx) {
438 int pl = 3;
439 if (pl < deadbeef->plt_get_count ()) {
440 deadbeef->plt_set_curr_idx (pl);
441 deadbeef->conf_set_int ("playlist.current", pl);
442 }
443 return 0;
444 }
445
446 int
action_playlist5_handler(DB_plugin_action_t * act,int ctx)447 action_playlist5_handler (DB_plugin_action_t *act, int ctx) {
448 int pl = 4;
449 if (pl < deadbeef->plt_get_count ()) {
450 deadbeef->plt_set_curr_idx (pl);
451 deadbeef->conf_set_int ("playlist.current", pl);
452 }
453 return 0;
454 }
455
456 int
action_playlist6_handler(DB_plugin_action_t * act,int ctx)457 action_playlist6_handler (DB_plugin_action_t *act, int ctx) {
458 int pl = 5;
459 if (pl < deadbeef->plt_get_count ()) {
460 deadbeef->plt_set_curr_idx (pl);
461 deadbeef->conf_set_int ("playlist.current", pl);
462 }
463 return 0;
464 }
465
466 int
action_playlist7_handler(DB_plugin_action_t * act,int ctx)467 action_playlist7_handler (DB_plugin_action_t *act, int ctx) {
468 int pl = 6;
469 if (pl < deadbeef->plt_get_count ()) {
470 deadbeef->plt_set_curr_idx (pl);
471 deadbeef->conf_set_int ("playlist.current", pl);
472 }
473 return 0;
474 }
475
476 int
action_playlist8_handler(DB_plugin_action_t * act,int ctx)477 action_playlist8_handler (DB_plugin_action_t *act, int ctx) {
478 int pl = 7;
479 if (pl < deadbeef->plt_get_count ()) {
480 deadbeef->plt_set_curr_idx (pl);
481 deadbeef->conf_set_int ("playlist.current", pl);
482 }
483 return 0;
484 }
485
486 int
action_playlist9_handler(DB_plugin_action_t * act,int ctx)487 action_playlist9_handler (DB_plugin_action_t *act, int ctx) {
488 int pl = 8;
489 if (pl < deadbeef->plt_get_count ()) {
490 deadbeef->plt_set_curr_idx (pl);
491 deadbeef->conf_set_int ("playlist.current", pl);
492 }
493 return 0;
494 }
495
496 int
action_playlist10_handler(DB_plugin_action_t * act,int ctx)497 action_playlist10_handler (DB_plugin_action_t *act, int ctx) {
498 int pl = 9;
499 if (pl < deadbeef->plt_get_count ()) {
500 deadbeef->plt_set_curr_idx (pl);
501 deadbeef->conf_set_int ("playlist.current", pl);
502 }
503 return 0;
504 }
505
506 int
action_sort_randomize_handler(DB_plugin_action_t * act,int ctx)507 action_sort_randomize_handler (DB_plugin_action_t *act, int ctx) {
508 ddb_playlist_t *plt = deadbeef->plt_get_curr ();
509 deadbeef->plt_sort_v2 (plt, PL_MAIN, -1, NULL, DDB_SORT_RANDOM);
510 deadbeef->plt_unref (plt);
511 deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0);
512 return 0;
513 }
514
515 int
action_sort_by_date_handler(DB_plugin_action_t * act,int ctx)516 action_sort_by_date_handler (DB_plugin_action_t *act, int ctx) {
517 ddb_playlist_t *plt = deadbeef->plt_get_curr ();
518 deadbeef->plt_sort_v2 (plt, PL_MAIN, -1, "%year%", DDB_SORT_ASCENDING);
519 deadbeef->plt_unref (plt);
520 deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0);
521 return 0;
522 }
523
524 int
action_sort_by_artist_handler(DB_plugin_action_t * act,int ctx)525 action_sort_by_artist_handler (DB_plugin_action_t *act, int ctx) {
526 ddb_playlist_t *plt = deadbeef->plt_get_curr ();
527 deadbeef->plt_sort_v2 (plt, PL_MAIN, -1, "%artist%", DDB_SORT_ASCENDING);
528 deadbeef->plt_unref (plt);
529 deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0);
530 return 0;
531 }
532
533 int
action_sort_by_album_handler(DB_plugin_action_t * act,int ctx)534 action_sort_by_album_handler (DB_plugin_action_t *act, int ctx) {
535 ddb_playlist_t *plt = deadbeef->plt_get_curr ();
536 deadbeef->plt_sort_v2 (plt, PL_MAIN, -1, "%album%", DDB_SORT_ASCENDING);
537 deadbeef->plt_unref (plt);
538 deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0);
539 return 0;
540 }
541
542 int
action_sort_by_tracknr_handler(DB_plugin_action_t * act,int ctx)543 action_sort_by_tracknr_handler (DB_plugin_action_t *act, int ctx) {
544 ddb_playlist_t *plt = deadbeef->plt_get_curr ();
545 deadbeef->plt_sort_v2 (plt, PL_MAIN, -1, "%tracknumber%", DDB_SORT_ASCENDING);
546 deadbeef->plt_unref (plt);
547 deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0);
548 return 0;
549 }
550
551 int
action_sort_by_title_handler(DB_plugin_action_t * act,int ctx)552 action_sort_by_title_handler (DB_plugin_action_t *act, int ctx) {
553 ddb_playlist_t *plt = deadbeef->plt_get_curr ();
554 deadbeef->plt_sort_v2 (plt, PL_MAIN, -1, "%title%", DDB_SORT_ASCENDING);
555 deadbeef->plt_unref (plt);
556 deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0);
557 return 0;
558 }
559
560 int
action_invert_selection_handler(DB_plugin_action_t * act,int ctx)561 action_invert_selection_handler (DB_plugin_action_t *act, int ctx) {
562 deadbeef->pl_lock ();
563 DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
564 while (it) {
565 if (deadbeef->pl_is_selected (it)) {
566 deadbeef->pl_set_selected (it, 0);
567 }
568 else {
569 deadbeef->pl_set_selected (it, 1);
570 }
571 DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
572 deadbeef->pl_item_unref (it);
573 it = next;
574 }
575 deadbeef->pl_unlock ();
576 deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_SELECTION, 0);
577 return 0;
578 }
579
580 int
action_clear_playlist_handler(DB_plugin_action_t * act,int ctx)581 action_clear_playlist_handler (DB_plugin_action_t *act, int ctx) {
582 deadbeef->pl_clear ();
583 deadbeef->pl_save_current ();
584 deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0);
585 return 0;
586 }
587
588 int
action_add_to_playqueue_handler(DB_plugin_action_t * act,int ctx)589 action_add_to_playqueue_handler (DB_plugin_action_t *act, int ctx) {
590 ddb_playlist_t *plt = deadbeef->action_get_playlist ();
591
592 DB_playItem_t *it = deadbeef->plt_get_first (plt, PL_MAIN);
593 while (it) {
594 if (ctx == DDB_ACTION_CTX_PLAYLIST || (ctx == DDB_ACTION_CTX_SELECTION && deadbeef->pl_is_selected (it))) {
595 deadbeef->pl_playqueue_push (it);
596 }
597 DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
598 deadbeef->pl_item_unref (it);
599 it = next;
600 }
601
602 deadbeef->sendmessage (DB_EV_PLAYLIST_REFRESH, 0, 0, 0);
603
604 deadbeef->plt_unref (plt);
605
606 return 0;
607 }
608
609 int
action_remove_from_playqueue_handler(DB_plugin_action_t * act,int ctx)610 action_remove_from_playqueue_handler (DB_plugin_action_t *act, int ctx) {
611 ddb_playlist_t *plt = deadbeef->action_get_playlist ();
612
613 DB_playItem_t *it = deadbeef->plt_get_first (plt, PL_MAIN);
614 while (it) {
615 if (ctx == DDB_ACTION_CTX_PLAYLIST || (ctx == DDB_ACTION_CTX_SELECTION && deadbeef->pl_is_selected (it))) {
616 deadbeef->pl_playqueue_remove (it);
617 }
618 DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
619 deadbeef->pl_item_unref (it);
620 it = next;
621 }
622
623 deadbeef->sendmessage (DB_EV_PLAYLIST_REFRESH, 0, 0, 0);
624
625 deadbeef->plt_unref (plt);
626 return 0;
627 }
628
629 int
action_toggle_mute_handler(DB_plugin_action_t * act,int ctx)630 action_toggle_mute_handler (DB_plugin_action_t *act, int ctx) {
631 int mute = 1-deadbeef->audio_is_mute ();
632 deadbeef->audio_set_mute (mute);
633 return 0;
634 }
635