summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-05-10 21:34:49 +0200
committerGravatar waker <wakeroid@gmail.com>2011-05-10 21:34:49 +0200
commit9d529eb05995069583ffa3e07670c0ea23b42b15 (patch)
tree055c27ab1954e8a8493a519bc5de9d27807293a9
parent1a8737e1466a3c17d77ab30e2035472feb7c2773 (diff)
added several new plt_* functions to work on specific playlists
-rw-r--r--deadbeef.h29
-rw-r--r--main.c4
-rw-r--r--playlist.c155
-rw-r--r--playlist.h42
-rw-r--r--plugins.c21
-rw-r--r--plugins/ao/eng_dsf/eng_dsf.c2
-rw-r--r--plugins/ao/eng_ssf/eng_ssf.c2
-rw-r--r--plugins/ao/main.c2
-rw-r--r--plugins/gtkui/ddblistview.c6
-rw-r--r--plugins/gtkui/ddblistview.h3
-rw-r--r--plugins/gtkui/ddbtabstrip.c6
-rw-r--r--plugins/gtkui/mainplaylist.c9
-rw-r--r--plugins/gtkui/search.c4
13 files changed, 193 insertions, 92 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 26eb3e11..79553c64 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -402,6 +402,7 @@ typedef struct {
// clear playlist
void (*plt_clear) (ddb_playlist_t *plt);
+ void (*pl_clear) (void);
// set current playlist
void (*plt_set_curr) (ddb_playlist_t *plt);
@@ -454,6 +455,25 @@ typedef struct {
DB_playItem_t * (*plt_insert_file) (ddb_playlist_t *playlist, DB_playItem_t *after, const char *fname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
DB_playItem_t *(*plt_insert_dir) (ddb_playlist_t *plt, DB_playItem_t *after, const char *dirname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
void (*plt_set_item_duration) (ddb_playlist_t *plt, DB_playItem_t *it, float duration);
+ int (*plt_remove_item) (ddb_playlist_t *playlist, DB_playItem_t *it);
+ int (*plt_getselcount) (ddb_playlist_t *playlist);
+ float (*plt_get_totaltime) (ddb_playlist_t *plt);
+ int (*plt_getcount) (ddb_playlist_t *plt, int iter);
+ int (*plt_delete_selected) (ddb_playlist_t *plt);
+ void (*plt_set_cursor) (ddb_playlist_t *plt, int iter, int cursor);
+ int (*plt_get_cursor) (ddb_playlist_t *plt, int iter);
+ void (*plt_select_all) (ddb_playlist_t *plt);
+ void (*plt_crop_selected) (ddb_playlist_t *plt);
+ DB_playItem_t *(*plt_get_first) (ddb_playlist_t *plt, int iter);
+ DB_playItem_t *(*plt_get_last) (ddb_playlist_t *plt, int iter);
+ void (*plt_move_items) (ddb_playlist_t *to, int iter, ddb_playlist_t *from, DB_playItem_t *drop_before, uint32_t *indexes, int count);
+ void (*plt_copy_items) (ddb_playlist_t *to, int iter, ddb_playlist_t * from, DB_playItem_t *before, uint32_t *indices, int cnt);
+ void (*plt_search_reset) (ddb_playlist_t *plt);
+ void (*plt_search_process) (ddb_playlist_t *plt, const char *text);
+
+ // add files and folders to current playlist
+ int (*plt_add_file) (ddb_playlist_t *plt, const char *fname, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
+ int (*plt_add_dir) (ddb_playlist_t *plt, const char *dirname, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
// playlist locking
void (*pl_lock) (void);
@@ -466,10 +486,6 @@ typedef struct {
void (*pl_item_unref) (DB_playItem_t *it);
void (*pl_item_copy) (DB_playItem_t *out, DB_playItem_t *in);
- // add files and folders to current playlist
- int (*plt_add_file) (ddb_playlist_t *plt, const char *fname, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
- int (*plt_add_dir) (ddb_playlist_t *plt, const char *dirname, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
-
// this function may return -1 if it is not possible to add files right now.
// caller must cancel operation in this case, or wait until previous add
// finishes
@@ -494,7 +510,6 @@ typedef struct {
int (*pl_get_cursor) (int iter);
void (*pl_set_selected) (DB_playItem_t *it, int sel);
int (*pl_is_selected) (DB_playItem_t *it);
- void (*pl_clear) (void);
int (*pl_save_current) (void);
int (*pl_save_all) (void);
void (*pl_select_all) (void);
@@ -534,10 +549,6 @@ typedef struct {
// _escaped version wraps all conversions with '' and replaces every ' in conversions with \'
int (*pl_format_title_escaped) (DB_playItem_t *it, int idx, char *s, int size, int id, const char *fmt);
void (*pl_format_time) (float t, char *dur, int size);
- void (*pl_move_items) (int iter, int plt_from, DB_playItem_t *drop_before, uint32_t *indexes, int count);
- void (*pl_copy_items) (int iter, int plt_from, DB_playItem_t *before, uint32_t *indices, int cnt);
- void (*pl_search_reset) (void);
- void (*pl_search_process) (const char *text);
// find which playlist the specified item belongs to, returns NULL if none
ddb_playlist_t * (*pl_get_playlist) (DB_playItem_t *it);
diff --git a/main.c b/main.c
index c671a58f..80e07b27 100644
--- a/main.c
+++ b/main.c
@@ -245,9 +245,9 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi
// add files
playlist_t *curr_plt = plt_get_curr ();
if (!queue) {
- pl_clear ();
+ plt_clear (curr_plt);
messagepump_push (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
- pl_reset_cursor ();
+ plt_reset_cursor (curr_plt);
}
if (parg < pend) {
if (deadbeef->pl_add_files_begin ((ddb_playlist_t *)curr_plt) != 0) {
diff --git a/playlist.c b/playlist.c
index b54904ab..063e2d42 100644
--- a/playlist.c
+++ b/playlist.c
@@ -741,19 +741,19 @@ plt_move (int from, int to) {
void
plt_clear (playlist_t *plt) {
- LOCK;
while (plt->head[PL_MAIN]) {
- pl_remove_item (plt->head[PL_MAIN]);
+ plt_remove_item (plt, plt->head[PL_MAIN]);
}
plt->current_row[PL_MAIN] = -1;
plt->current_row[PL_SEARCH] = -1;
plt_modified (plt);
- UNLOCK;
}
void
pl_clear (void) {
+ LOCK;
plt_clear (playlist);
+ UNLOCK;
}
static const uint8_t *
@@ -1723,28 +1723,39 @@ plt_remove_item (playlist_t *playlist, playItem_t *it) {
}
int
-pl_remove_item (playItem_t *it) {
- return plt_remove_item (playlist, it);
+plt_getcount (playlist_t *plt, int iter) {
+ return plt->count[iter];
}
int
pl_getcount (int iter) {
+ LOCK;
if (!playlist) {
+ UNLOCK;
return 0;
}
- return playlist->count[iter];
+
+ int cnt = playlist->count[iter];
+ UNLOCK;
+ return cnt;
}
int
-pl_getselcount (void) {
+plt_getselcount (playlist_t *playlist) {
// FIXME: slow!
int cnt = 0;
- LOCK;
for (playItem_t *it = playlist->head[PL_MAIN]; it; it = it->next[PL_MAIN]) {
if (it->selected) {
cnt++;
}
}
+ return cnt;
+}
+
+int
+pl_getselcount (void) {
+ LOCK;
+ int cnt = plt_getselcount (playlist);
UNLOCK;
return cnt;
}
@@ -1940,7 +1951,7 @@ pl_item_unref (playItem_t *it) {
}
int
-pl_delete_selected (void) {
+plt_delete_selected (playlist_t *playlist) {
LOCK;
int i = 0;
int ret = -1;
@@ -1951,7 +1962,7 @@ pl_delete_selected (void) {
if (ret == -1) {
ret = i;
}
- pl_remove_item (it);
+ plt_remove_item (playlist, it);
}
}
if (playlist->current_row[PL_MAIN] >= playlist->count[PL_MAIN]) {
@@ -1964,19 +1975,33 @@ pl_delete_selected (void) {
return ret;
}
+int
+pl_delete_selected (void) {
+ LOCK;
+ plt_delete_selected (playlist);
+ UNLOCK;
+}
+
void
-pl_crop_selected (void) {
+plt_crop_selected (playlist_t *playlist) {
LOCK;
playItem_t *next = NULL;
for (playItem_t *it = playlist->head[PL_MAIN]; it; it = next) {
next = it->next[PL_MAIN];
if (!it->selected) {
- pl_remove_item (it);
+ plt_remove_item (playlist, it);
}
}
UNLOCK;
}
+void
+pl_crop_selected (void) {
+ LOCK;
+ plt_crop_selected (playlist);
+ UNLOCK;
+}
+
int
plt_save (playlist_t *plt, playItem_t *first, playItem_t *last, const char *fname, int *pabort, int (*cb)(playItem_t *it, void *data), void *user_data) {
LOCK;
@@ -2593,7 +2618,7 @@ pl_load_all (void) {
}
void
-pl_select_all (void) {
+plt_select_all (playlist_t *playlist) {
LOCK;
for (playItem_t *it = playlist->head[PL_MAIN]; it; it = it->next[PL_MAIN]) {
it->selected = 1;
@@ -2602,6 +2627,13 @@ pl_select_all (void) {
}
void
+pl_select_all (void) {
+ LOCK;
+ plt_select_all (playlist);
+ UNLOCK;
+}
+
+void
plt_reshuffle (playlist_t *playlist, playItem_t **ppmin, playItem_t **ppmax) {
LOCK;
playItem_t *pmin = NULL;
@@ -3326,7 +3358,7 @@ plt_sort (playlist_t *playlist, int iter, int id, const char *format, int ascend
}
void
-pl_reset_cursor (void) {
+plt_reset_cursor (playlist_t *playlist) {
int i;
LOCK;
for (i = 0; i < PL_MAX_ITERATORS; i++) {
@@ -3336,10 +3368,16 @@ pl_reset_cursor (void) {
}
float
+plt_get_totaltime (playlist_t *playlist) {
+ return playlist->totaltime;
+}
+
+float
pl_get_totaltime (void) {
LOCK;
- float t = playlist->totaltime;
+ float t = plt_get_totaltime (playlist);
UNLOCK;
+ return t;
}
void
@@ -3355,7 +3393,7 @@ pl_is_selected (playItem_t *it) {
}
playItem_t *
-pl_get_first (int iter) {
+plt_get_first (playlist_t *playlist, int iter) {
if (!playlist) {
return NULL;
}
@@ -3367,7 +3405,15 @@ pl_get_first (int iter) {
}
playItem_t *
-pl_get_last (int iter) {
+pl_get_first (int iter) {
+ LOCK;
+ playItem_t *it = plt_get_first (playlist, iter);
+ UNLOCK;
+ return it;
+}
+
+playItem_t *
+plt_get_last (playlist_t *playlist, int iter) {
playItem_t *p = playlist->tail[iter];
if (p) {
pl_item_ref (p);
@@ -3376,6 +3422,14 @@ pl_get_last (int iter) {
}
playItem_t *
+pl_get_last (int iter) {
+ LOCK;
+ playItem_t *it = plt_get_last (playlist, iter);
+ UNLOCK;
+ return it;
+}
+
+playItem_t *
pl_get_next (playItem_t *it, int iter) {
playItem_t *next = it ? it->next[iter] : NULL;
if (next) {
@@ -3394,17 +3448,30 @@ pl_get_prev (playItem_t *it, int iter) {
}
int
-pl_get_cursor (int iter) {
+plt_get_cursor (playlist_t *playlist, int iter) {
if (!playlist) {
return -1;
}
return playlist->current_row[iter];
}
+int
+pl_get_cursor (int iter) {
+ LOCK;
+ int c = plt_get_cursor (playlist, iter);
+ UNLOCK;
+ return c;
+}
+
+void
+plt_set_cursor (playlist_t *playlist, int iter, int cursor) {
+ playlist->current_row[iter] = cursor;
+}
+
void
pl_set_cursor (int iter, int cursor) {
LOCK;
- playlist->current_row[iter] = cursor;
+ plt_set_cursor (playlist, iter, cursor);
UNLOCK;
}
@@ -3412,19 +3479,10 @@ pl_set_cursor (int iter, int cursor) {
// list of items is indexes[count]
// drop_before is insertion point
void
-pl_move_items (int iter, int plt_from, playItem_t *drop_before, uint32_t *indexes, int count) {
+plt_move_items (playlist_t *to, int iter, playlist_t *from, playItem_t *drop_before, uint32_t *indexes, int count) {
LOCK;
- playlist_t *playlist = plt_get_for_idx (plt_from);
- playlist_t *to = plt_get_curr ();
-
- if (!playlist || !to) {
- if (to) {
- plt_unref (to);
- }
- if (playlist) {
- plt_unref (playlist);
- }
+ if (!from || !to) {
UNLOCK;
return;
}
@@ -3432,7 +3490,7 @@ pl_move_items (int iter, int plt_from, playItem_t *drop_before, uint32_t *indexe
// don't let streamer think that current song was removed
no_remove_notify = 1;
- // unlink items from playlist, and link together
+ // unlink items from from, and link together
playItem_t *head = NULL;
playItem_t *tail = NULL;
int processed = 0;
@@ -3448,14 +3506,14 @@ pl_move_items (int iter, int plt_from, playItem_t *drop_before, uint32_t *indexe
drop_after = to->tail[iter];
}
- for (playItem_t *it = playlist->head[iter]; it && processed < count; it = next, idx++) {
+ for (playItem_t *it = from->head[iter]; it && processed < count; it = next, idx++) {
next = it->next[iter];
if (idx == indexes[processed]) {
pl_item_ref (it);
if (drop_after == it) {
drop_after = it->prev[PL_MAIN];
}
- plt_remove_item (playlist, it);
+ plt_remove_item (from, it);
plt_insert_item (to, drop_after, it);
pl_item_unref (it);
drop_after = it;
@@ -3463,29 +3521,14 @@ pl_move_items (int iter, int plt_from, playItem_t *drop_before, uint32_t *indexe
}
}
no_remove_notify = 0;
- if (to) {
- plt_unref (to);
- }
- if (playlist) {
- plt_unref (playlist);
- }
UNLOCK;
}
void
-pl_copy_items (int iter, int plt_from, playItem_t *before, uint32_t *indices, int cnt) {
+plt_copy_items (playlist_t *to, int iter, playlist_t *from, playItem_t *before, uint32_t *indices, int cnt) {
pl_lock ();
- playlist_t *from = plt_get_for_idx (plt_from);
- playlist_t *to = plt_get_curr ();
-
if (!from || !to) {
- if (to) {
- plt_unref (to);
- }
- if (from) {
- plt_unref (from);
- }
pl_unlock ();
return;
}
@@ -3498,7 +3541,7 @@ pl_copy_items (int iter, int plt_from, playItem_t *before, uint32_t *indices, in
idx++;
}
if (!it) {
- trace ("pl_copy_items: warning: item %d not found in source playlist\n", indices[i]);
+ trace ("pl_copy_items: warning: item %d not found in source plt_to\n", indices[i]);
continue;
}
playItem_t *it_new = pl_item_alloc ();
@@ -3509,17 +3552,11 @@ pl_copy_items (int iter, int plt_from, playItem_t *before, uint32_t *indices, in
pl_item_unref (it_new);
}
- if (to) {
- plt_unref (to);
- }
- if (from) {
- plt_unref (from);
- }
pl_unlock ();
}
void
-pl_search_reset (void) {
+plt_search_reset (playlist_t *playlist) {
LOCK;
while (playlist->head[PL_SEARCH]) {
playItem_t *next = playlist->head[PL_SEARCH]->next[PL_SEARCH];
@@ -3534,9 +3571,9 @@ pl_search_reset (void) {
}
void
-pl_search_process (const char *text) {
+plt_search_process (playlist_t *playlist, const char *text) {
LOCK;
- pl_search_reset ();
+ plt_search_reset (playlist);
// convert text to lowercase, to save some cycles
char lc[1000];
diff --git a/playlist.h b/playlist.h
index a21c6937..ef42ff59 100644
--- a/playlist.h
+++ b/playlist.h
@@ -179,7 +179,7 @@ playItem_t *
plt_insert_item (playlist_t *playlist, playItem_t *after, playItem_t *it);
int
-pl_remove_item (playItem_t *i);
+plt_remove_item (playlist_t *playlist, playItem_t *it);
playItem_t *
pl_item_alloc (void);
@@ -200,8 +200,14 @@ int
pl_getcount (int iter);
int
+plt_getcount (playlist_t *plt, int iter);
+
+int
pl_getselcount (void);
+int
+plt_getselcount (playlist_t *playlist);
+
playItem_t *
pl_get_for_idx (int idx);
@@ -254,9 +260,15 @@ pl_delete_all_meta (playItem_t *it);
// returns index of 1st deleted item
int
+plt_delete_selected (playlist_t *plt);
+
+int
pl_delete_selected (void);
void
+plt_crop_selected (playlist_t *playlist);
+
+void
pl_crop_selected (void);
int
@@ -278,6 +290,9 @@ int
pl_load_all (void);
void
+plt_select_all (playlist_t *plt);
+
+void
pl_select_all (void);
void
@@ -317,7 +332,10 @@ void
pl_format_time (float t, char *dur, int size);
void
-pl_reset_cursor (void);
+plt_reset_cursor (playlist_t *plt);
+
+float
+plt_get_totaltime (playlist_t *plt);
float
pl_get_totaltime (void);
@@ -329,9 +347,15 @@ int
pl_is_selected (playItem_t *it);
playItem_t *
+plt_get_first (playlist_t *playlist, int iter);
+
+playItem_t *
pl_get_first (int iter);
playItem_t *
+plt_get_last (playlist_t *playlist, int iter);
+
+playItem_t *
pl_get_last (int iter);
playItem_t *
@@ -341,22 +365,28 @@ playItem_t *
pl_get_prev (playItem_t *it, int iter);
int
+plt_get_cursor (playlist_t *plt, int iter);
+
+int
pl_get_cursor (int iter);
void
+plt_set_cursor (playlist_t *plt, int iter, int cursor);
+
+void
pl_set_cursor (int iter, int cursor);
void
-pl_move_items (int iter, int plt_from, playItem_t *drop_before, uint32_t *indexes, int count);
+plt_move_items (playlist_t *to, int iter, playlist_t *from, playItem_t *drop_before, uint32_t *indexes, int count);
void
-pl_copy_items (int iter, int plt_from, playItem_t *before, uint32_t *indices, int cnt);
+plt_copy_items (playlist_t *to, int iter, playlist_t *from, playItem_t *before, uint32_t *indices, int cnt);
void
-pl_search_reset (void);
+plt_search_reset (playlist_t *plt);
void
-pl_search_process (const char *text);
+plt_search_process (playlist_t *plt, const char *text);
void
plt_sort (playlist_t *plt, int iter, int id, const char *format, int ascending);
diff --git a/plugins.c b/plugins.c
index ec0f26a2..caba68bc 100644
--- a/plugins.c
+++ b/plugins.c
@@ -113,6 +113,7 @@ static DB_functions_t deadbeef_api = {
.plt_add = plt_add,
.plt_remove = plt_remove,
.plt_clear = (void (*)(ddb_playlist_t *))plt_clear,
+ .pl_clear = pl_clear,
.plt_set_curr = (void (*) (ddb_playlist_t *plt))plt_set_curr,
.plt_get_curr = (ddb_playlist_t *(*) (void))plt_get_curr,
.plt_set_curr_idx = (void (*) (int plt))plt_set_curr_idx,
@@ -147,6 +148,8 @@ static DB_functions_t deadbeef_api = {
.plt_insert_file = (DB_playItem_t *(*) (ddb_playlist_t *playlist, DB_playItem_t *after, const char *fname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data))plt_insert_file,
.plt_insert_dir = (DB_playItem_t *(*) (ddb_playlist_t *plt, DB_playItem_t *after, const char *dirname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data))plt_insert_dir,
.plt_set_item_duration = (void (*) (ddb_playlist_t *plt, DB_playItem_t *it, float duration))plt_set_item_duration,
+ .plt_remove_item = (int (*) (ddb_playlist_t *playlist, DB_playItem_t *it))plt_remove_item,
+ .plt_getselcount = (int (*) (ddb_playlist_t *playlist))plt_getselcount,
// playlist access
.pl_lock = pl_lock,
@@ -173,30 +176,38 @@ static DB_functions_t deadbeef_api = {
.pl_items_copy_junk = (void (*)(DB_playItem_t *from, DB_playItem_t *first, DB_playItem_t *last))pl_items_copy_junk,
.pl_set_item_replaygain = (void (*)(DB_playItem_t *it, int idx, float value))pl_set_item_replaygain,
.pl_get_item_replaygain = (float (*)(DB_playItem_t *it, int idx))pl_get_item_replaygain,
+ .plt_get_totaltime = (float (*) (ddb_playlist_t *plt))plt_get_totaltime,
.pl_get_totaltime = pl_get_totaltime,
.pl_getcount = pl_getcount,
+ .plt_getcount = (int (*)(ddb_playlist_t *plt, int iter))plt_getcount,
+ .plt_delete_selected = (int (*) (ddb_playlist_t *plt))plt_delete_selected,
.pl_delete_selected = pl_delete_selected,
+ .plt_set_cursor = (void (*)(ddb_playlist_t *plt, int iter, int cursor))plt_set_cursor,
.pl_set_cursor = pl_set_cursor,
+ .plt_get_cursor = (int (*)(ddb_playlist_t *plt, int iter))plt_get_cursor,
.pl_get_cursor = pl_get_cursor,
.pl_set_selected = (void (*) (DB_playItem_t *, int))pl_set_selected,
.pl_is_selected = (int (*) (DB_playItem_t *))pl_is_selected,
- .pl_clear = pl_clear,
.pl_save_current = pl_save_current,
.pl_save_all = pl_save_all,
+ .plt_select_all = (void (*) (ddb_playlist_t *plt))plt_select_all,
.pl_select_all = pl_select_all,
+ .plt_crop_selected = (void (*) (ddb_playlist_t *plt))plt_crop_selected,
.pl_crop_selected = pl_crop_selected,
.pl_getselcount = pl_getselcount,
+ .plt_get_first = (DB_playItem_t *(*) (ddb_playlist_t *plt, int))plt_get_first,
.pl_get_first = (DB_playItem_t *(*) (int))pl_get_first,
+ .plt_get_last = (DB_playItem_t *(*) (ddb_playlist_t *plt, int))plt_get_last,
.pl_get_last = (DB_playItem_t *(*) (int))pl_get_last,
.pl_get_next = (DB_playItem_t *(*) (DB_playItem_t *, int))pl_get_next,
.pl_get_prev = (DB_playItem_t *(*) (DB_playItem_t *, int))pl_get_prev,
.pl_format_title = (int (*) (DB_playItem_t *it, int idx, char *s, int size, int id, const char *fmt))pl_format_title,
.pl_format_title_escaped = (int (*) (DB_playItem_t *it, int idx, char *s, int size, int id, const char *fmt))pl_format_title_escaped,
.pl_format_time = pl_format_time,
- .pl_move_items = (void (*) (int iter, int plt_from, DB_playItem_t *drop_before, uint32_t *indexes, int count))pl_move_items,
- .pl_copy_items = (void (*) (int iter, int plt_from, DB_playItem_t *before, uint32_t *indices, int cnt))pl_copy_items,
- .pl_search_reset = pl_search_reset,
- .pl_search_process = pl_search_process,
+ .plt_move_items = (void (*) (ddb_playlist_t *to, int iter, ddb_playlist_t *from, DB_playItem_t *drop_before, uint32_t *indexes, int count))plt_move_items,
+ .plt_copy_items = (void (*) (ddb_playlist_t *to, int iter, ddb_playlist_t *from, DB_playItem_t *before, uint32_t *indices, int cnt))plt_copy_items,
+ .plt_search_reset = (void (*)(ddb_playlist_t *plt))plt_search_reset,
+ .plt_search_process = (void (*)(ddb_playlist_t *plt, const char *t))plt_search_process,
.pl_get_playlist = (ddb_playlist_t * (*) (DB_playItem_t *it))pl_get_playlist,
// metainfo
.pl_add_meta = (void (*) (DB_playItem_t *, const char *, const char *))pl_add_meta,
diff --git a/plugins/ao/eng_dsf/eng_dsf.c b/plugins/ao/eng_dsf/eng_dsf.c
index af814dc0..0221caf0 100644
--- a/plugins/ao/eng_dsf/eng_dsf.c
+++ b/plugins/ao/eng_dsf/eng_dsf.c
@@ -44,7 +44,7 @@ void *dsf_start(const char *path, uint8 *buffer, uint32 length)
memset (s, 0, sizeof (dsf_synth_t));
uint8 *file = NULL, *lib_decoded = NULL, *lib_raw_file = NULL;
- uint32 offset, plength, lengthMS, fadeMS;
+ uint32 offset, lengthMS, fadeMS;
uint64 file_len, lib_len, lib_raw_length;
corlett_t *lib;
char *libfile;
diff --git a/plugins/ao/eng_ssf/eng_ssf.c b/plugins/ao/eng_ssf/eng_ssf.c
index f15eb114..d2910fa2 100644
--- a/plugins/ao/eng_ssf/eng_ssf.c
+++ b/plugins/ao/eng_ssf/eng_ssf.c
@@ -91,7 +91,7 @@ void *ssf_start(const char *path, uint8 *buffer, uint32 length)
ssf_synth_t *s = malloc (sizeof (ssf_synth_t));
memset (s, 0, sizeof (ssf_synth_t));
uint8 *file, *lib_decoded, *lib_raw_file;
- uint32 offset, plength, lengthMS, fadeMS;
+ uint32 offset, lengthMS, fadeMS;
uint64 file_len, lib_len, lib_raw_length;
corlett_t *lib;
char *libfile;
diff --git a/plugins/ao/main.c b/plugins/ao/main.c
index 18067410..a4da36d0 100644
--- a/plugins/ao/main.c
+++ b/plugins/ao/main.c
@@ -27,7 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <deadbeef/deadbeef.h>
+#include "../../deadbeef.h"
#include "ao.h"
#include "eng_protos.h"
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c
index 14dd9a70..c1203364 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -963,7 +963,11 @@ ddb_listview_list_drag_data_received (GtkWidget *widget,
UNREF (drop_before);
drop_before = next;
}
- ps->binding->drag_n_drop (drop_before, plt, d, length, drag_context->action == GDK_ACTION_COPY ? 1 : 0);
+ ddb_playlist_t *p = deadbeef->plt_get_for_idx (plt);
+ if (p) {
+ ps->binding->drag_n_drop (drop_before, p, d, length, drag_context->action == GDK_ACTION_COPY ? 1 : 0);
+ deadbeef->plt_unref (p);
+ }
if (drop_before) {
UNREF (drop_before);
}
diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h
index 33677205..b22469ed 100644
--- a/plugins/gtkui/ddblistview.h
+++ b/plugins/gtkui/ddblistview.h
@@ -41,6 +41,7 @@ typedef struct _DdbListview DdbListview;
typedef struct _DdbListviewClass DdbListviewClass;
typedef void * DdbListviewIter;
+typedef void * DdbPlaylistHandle;
//typedef void * DdbListviewColIter;
typedef struct {
@@ -68,7 +69,7 @@ typedef struct {
int (*get_group) (DdbListviewIter it, char *str, int size);
// drag-n-drop
- void (*drag_n_drop) (DdbListviewIter before, int playlist, uint32_t *indices, int length, int copy);
+ void (*drag_n_drop) (DdbListviewIter before, DdbPlaylistHandle playlist_from, uint32_t *indices, int length, int copy);
void (*external_drag_n_drop) (DdbListviewIter before, char *mem, int length);
// callbacks
diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c
index 8539a10d..f40c1ade 100644
--- a/plugins/gtkui/ddbtabstrip.c
+++ b/plugins/gtkui/ddbtabstrip.c
@@ -270,7 +270,11 @@ on_tabstrip_drag_data_received (GtkWidget *widget,
int plt = *d;
d++;
int length = (data->length/4)-1;
- ps->binding->drag_n_drop (NULL, plt, d, length, drag_context->action == GDK_ACTION_COPY ? 1 : 0);
+ ddb_playlist_t *p = deadbeef->plt_get_for_idx (plt);
+ if (p) {
+ ps->binding->drag_n_drop (NULL, p, d, length, drag_context->action == GDK_ACTION_COPY ? 1 : 0);
+ deadbeef->plt_unref (p);
+ }
}
gtk_drag_finish (drag_context, TRUE, FALSE, time);
}
diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c
index 1611f03d..f3cbde3d 100644
--- a/plugins/gtkui/mainplaylist.c
+++ b/plugins/gtkui/mainplaylist.c
@@ -107,15 +107,16 @@ int main_get_idx (DdbListviewIter it) {
}
void
-main_drag_n_drop (DdbListviewIter before, int from_playlist, uint32_t *indices, int length, int copy) {
+main_drag_n_drop (DdbListviewIter before, ddb_playlist_t *from_playlist, uint32_t *indices, int length, int copy) {
deadbeef->pl_lock ();
-// int curr = deadbeef->plt_get_curr_idx ();
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
if (copy) {
- deadbeef->pl_copy_items (PL_MAIN, from_playlist, (DB_playItem_t *)before, indices, length);
+ deadbeef->plt_copy_items (plt, PL_MAIN, from_playlist, (DB_playItem_t *)before, indices, length);
}
else {
- deadbeef->pl_move_items (PL_MAIN, from_playlist, (DB_playItem_t *)before, indices, length);
+ deadbeef->plt_move_items (plt, PL_MAIN, from_playlist, (DB_playItem_t *)before, indices, length);
}
+ deadbeef->plt_unref (plt);
deadbeef->pl_unlock ();
}
diff --git a/plugins/gtkui/search.c b/plugins/gtkui/search.c
index 4c6bd99b..d71b4cef 100644
--- a/plugins/gtkui/search.c
+++ b/plugins/gtkui/search.c
@@ -62,7 +62,9 @@ search_start (void) {
void
search_process (const char *text) {
- deadbeef->pl_search_process (text);
+ ddb_playlist_t *plt = deadbeef->plt_get_curr ();
+ deadbeef->plt_search_process (plt, text);
+ deadbeef->plt_unref (plt);
int row = deadbeef->pl_get_cursor (PL_SEARCH);
if (row >= deadbeef->pl_getcount (PL_SEARCH)) {