summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--deadbeef.h28
-rw-r--r--main.c7
-rw-r--r--playlist.c11
-rw-r--r--playlist.h2
-rw-r--r--plugins.c8
5 files changed, 43 insertions, 13 deletions
diff --git a/deadbeef.h b/deadbeef.h
index bf7a4082..2e6dfe18 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -43,20 +43,25 @@ extern "C" {
// this function should return pointer to DB_plugin_t structure
// that is enough for both static and dynamic modules
-// add DB_PLUGIN_SET_API_VERSION macro when you define plugin structure
+// add DDB_REQUIRE_API_VERSION(x,y) macro when you define plugin structure
// like this:
// static DB_decoder_t plugin = {
-// DB_PLUGIN_SET_API_VERSION
+// DDB_REQUIRE_API_VERSION(1,0)
// ............
// }
// this is required for versioning
// if you don't do it -- no version checking will be done (useful for
// debugging/development)
-// DON'T release plugins without DB_PLUGIN_SET_API_VERSION
+// your plugin will be accepted in all releases with API major version 'x',
+// and minor version 'y' and up.
+// increments in major version number mean that there are API breaks, and
+// plugins must be recompiled to be compatible
+//
+// please DON'T release plugins without version requirement
// api version history:
// 9.9 -- devel
-// 0.10 -- deadbeef-0.4.4-portable-r1
+// 0.10 -- deadbeef-0.4.4-portable-r1 (note: 0.4.4 uses api v0.9)
// 0.9 -- deadbeef-0.4.3-portable-build3
// 0.8 -- deadbeef-0.4.2
// 0.7 -- deabdeef-0.4.0
@@ -70,10 +75,17 @@ extern "C" {
#define DB_API_VERSION_MAJOR 9
#define DB_API_VERSION_MINOR 9
-#define DB_PLUGIN_SET_API_VERSION\
+#define DDB_PLUGIN_SET_API_VERSION\
.plugin.api_vmajor = DB_API_VERSION_MAJOR,\
.plugin.api_vminor = DB_API_VERSION_MINOR,
+// backwards compat macro
+#define DB_PLUGIN_SET_API_VERSION DDB_PLUGIN_SET_API_VERSION
+
+#define DDB_REQUIRE_API_VERSION(x,y)\
+ .plugin.api_vmajor = x,\
+ .plugin.api_vminor = y,
+
#define MAX_DECODER_PLUGINS 50
////////////////////////////
@@ -409,7 +421,11 @@ typedef struct {
void (*pl_item_copy) (DB_playItem_t *out, DB_playItem_t *in);
int (*pl_add_file) (const char *fname, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
int (*pl_add_dir) (const char *dirname, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
- void (*pl_add_files_begin) (int playlist);
+
+ // 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
+ int (*pl_add_files_begin) (int playlist);
void (*pl_add_files_end) (void);
DB_playItem_t *(*pl_insert_item) (DB_playItem_t *after, DB_playItem_t *it);
DB_playItem_t *(*pl_insert_dir) (DB_playItem_t *after, const char *dirname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
diff --git a/main.c b/main.c
index 6462111b..6bcad18f 100644
--- a/main.c
+++ b/main.c
@@ -238,7 +238,10 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi
pl_reset_cursor ();
}
if (parg < pend) {
- deadbeef->pl_add_files_begin (curr_plt);
+ if (deadbeef->pl_add_files_begin (curr_plt) != 0) {
+ snprintf (sendback, sbsize, "it's not allowed to add files to playlist right now, because another file adding operation is in progress. please try again later.");
+ return 0;
+ }
while (parg < pend) {
char resolved[PATH_MAX];
const char *pname;
@@ -778,7 +781,7 @@ main (int argc, char *argv[]) {
fwrite (prn, 1, strlen (prn), stderr);
}
else if (sz > 0 && out[0]) {
- fprintf (stderr, "got unknown response:\nlength=%d\n%s\n", (int)sz, out);
+ fprintf (stderr, "%s\n", out);
}
}
close (s);
diff --git a/playlist.c b/playlist.c
index e61a08e7..c8f4ac53 100644
--- a/playlist.c
+++ b/playlist.c
@@ -1601,16 +1601,25 @@ pl_add_dir (const char *dirname, int (*cb)(playItem_t *it, void *data), void *us
return -1;
}
-void
+int
pl_add_files_begin (int plt) {
+ pl_lock ();
+ if (addfiles_playlist) {
+ pl_unlock ();
+ return -1;
+ }
addfiles_playlist = plt_get (plt);
+ pl_unlock ();
trace ("adding to playlist %d (%s)\n", plt, addfiles_playlist->title);
+ return 0;
}
void
pl_add_files_end (void) {
trace ("end adding to playlist %s\n", addfiles_playlist->title);
+ pl_lock ();
addfiles_playlist = NULL;
+ pl_unlock ();
}
int
diff --git a/playlist.h b/playlist.h
index 88d35c47..cf156a81 100644
--- a/playlist.h
+++ b/playlist.h
@@ -146,7 +146,7 @@ pl_add_dir (const char *dirname, int (*cb)(playItem_t *it, void *data), void *us
int
pl_add_file (const char *fname, int (*cb)(playItem_t *it, void *data), void *user_data);
-void
+int
pl_add_files_begin (int plt);
void
diff --git a/plugins.c b/plugins.c
index 6671a501..399663bc 100644
--- a/plugins.c
+++ b/plugins.c
@@ -486,9 +486,11 @@ plug_init_plugin (DB_plugin_t* (*loadfunc)(DB_functions_t *), void *handle) {
#if !DISABLE_VERSIONCHECK
if (plugin_api->api_vmajor != 0 || plugin_api->api_vminor != 0) {
// version check enabled
- if (plugin_api->api_vmajor != DB_API_VERSION_MAJOR || plugin_api->api_vminor != DB_API_VERSION_MINOR) {
- trace ("\033[0;31mWARNING: plugin \"%s\" wants API v%d.%d (got %d.%d), will not be loaded\033[0;m\n", plugin_api->name, plugin_api->api_vmajor, plugin_api->api_vminor, DB_API_VERSION_MAJOR, DB_API_VERSION_MINOR);
- return -1;
+ if (DB_API_VERSION_MAJOR != 9 && DB_API_VERSION_MINOR != 9) {
+ if (plugin_api->api_vmajor != DB_API_VERSION_MAJOR || plugin_api->api_vminor > DB_API_VERSION_MINOR) {
+ trace ("\033[0;31mWARNING: plugin \"%s\" wants API v%d.%d (got %d.%d), will not be loaded\033[0;m\n", plugin_api->name, plugin_api->api_vmajor, plugin_api->api_vminor, DB_API_VERSION_MAJOR, DB_API_VERSION_MINOR);
+ return -1;
+ }
}
}
else {