summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-06 21:14:09 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-06 21:14:09 +0200
commit9c6e2108adbcedccee5a2984b1d8ffc57e6b1087 (patch)
treedf71b7e38fc1ee16db79e8876b2a30bd13e32301
parente62b0f28ff08c7913463855cba8082e1b9dff867 (diff)
added ability to enable/disable dsp plugins
-rw-r--r--deadbeef.h2
-rw-r--r--plugins/supereq/supereq.c43
-rw-r--r--streamer.c8
3 files changed, 50 insertions, 3 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 430f2e90..87d7deaf 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -615,6 +615,8 @@ typedef struct DB_dsp_s {
// stereo sample is counted as 1 sample
int (*process_int16) (int16_t *samples, int nsamples, int nch, int bps, int srate);
void (*reset) (void);
+ void (*enable) (int e);
+ int (*enabled) (void);
} DB_dsp_t;
// misc plugin
diff --git a/plugins/supereq/supereq.c b/plugins/supereq/supereq.c
index 368bcda3..cf56f349 100644
--- a/plugins/supereq/supereq.c
+++ b/plugins/supereq/supereq.c
@@ -22,6 +22,7 @@
#include "supereq.h"
static DB_functions_t *deadbeef;
+static DB_supereq_dsp_t plugin;
void *paramlist_alloc (void);
void paramlist_free (void *);
@@ -31,6 +32,8 @@ void equ_clearbuf(int bps,int srate);
void equ_init(int wb);
void equ_quit(void);
+void supereq_reset (void);
+
static float last_srate = 0;
static int last_nch = 0, last_bps = 0;
static float lbands[18] = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
@@ -40,9 +43,24 @@ static void *paramsroot;
static int params_changed = 0;
static intptr_t tid = 0;
static uintptr_t mutex = 0;
+static int enabled = 0;
+
+static int
+supereq_on_configchanged (DB_event_t *ev, uintptr_t data) {
+ int e = deadbeef->conf_get_int ("supereq.enable", 0);
+ if (e != enabled) {
+ if (e) {
+ supereq_reset ();
+ }
+ enabled = e;
+ }
+
+ return 0;
+}
int
supereq_plugin_start (void) {
+ enabled = deadbeef->conf_get_int ("supereq.enable", 0);
// load bands from config
for (int i = 0; i < 18; i++) {
char key[100];
@@ -58,11 +76,13 @@ supereq_plugin_start (void) {
equ_makeTable (lbands, rbands, paramsroot, last_srate);
equ_clearbuf (last_bps,last_srate);
mutex = deadbeef->mutex_create ();
+ deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_CONFIGCHANGED, DB_CALLBACK (supereq_on_configchanged), 0);
return 0;
}
int
supereq_plugin_stop (void) {
+ deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_CONFIGCHANGED, DB_CALLBACK (supereq_on_configchanged), 0);
if (tid) {
deadbeef->thread_join (tid);
deadbeef->mutex_free (mutex);
@@ -144,6 +164,25 @@ supereq_reset (void) {
deadbeef->mutex_unlock (mutex);
}
+void
+supereq_enable (int e) {
+ deadbeef->conf_set_int ("supereq.enable", e);
+
+ if (e && !enabled) {
+ supereq_reset ();
+ }
+ enabled = e;
+}
+
+int
+supereq_enabled (void) {
+ return enabled;
+}
+
+static const char settings_dlg[] =
+ "property \"Enable\" checkbox supereq.enable 0;\n"
+;
+
static DB_supereq_dsp_t plugin = {
.dsp.plugin.api_vmajor = DB_API_VERSION_MAJOR,
.dsp.plugin.api_vminor = DB_API_VERSION_MINOR,
@@ -156,9 +195,11 @@ static DB_supereq_dsp_t plugin = {
.dsp.plugin.website = "http://deadbeef.sf.net",
.dsp.plugin.start = supereq_plugin_start,
.dsp.plugin.stop = supereq_plugin_stop,
-// .dsp.plugin.configdialog = settings_dlg,
+ .dsp.plugin.configdialog = settings_dlg,
.dsp.process_int16 = supereq_process_int16,
.dsp.reset = supereq_reset,
+ .dsp.enable = supereq_enable,
+ .dsp.enabled = supereq_enabled,
.get_band = supereq_get_band,
.set_band = supereq_set_band,
};
diff --git a/streamer.c b/streamer.c
index fe7c0ed4..949ef383 100644
--- a/streamer.c
+++ b/streamer.c
@@ -976,7 +976,9 @@ streamer_reset (int full) { // must be called when current song changes by exter
DB_dsp_t **dsp = deadbeef->plug_get_dsp_list ();
int srate = p_get_rate ();
for (int i = 0; dsp[i]; i++) {
- dsp[i]->reset ();
+ if (dsp[i]->enabled ()) {
+ dsp[i]->reset ();
+ }
}
src_unlock ();
}
@@ -1356,7 +1358,9 @@ streamer_read_async (char *bytes, int size) {
DB_dsp_t **dsp = deadbeef->plug_get_dsp_list ();
int srate = p_get_rate ();
for (int i = 0; dsp[i]; i++) {
- dsp[i]->process_int16 ((int16_t *)bytes, bytesread/4, 2, 16, srate);
+ if (dsp[i]->enabled ()) {
+ dsp[i]->process_int16 ((int16_t *)bytes, bytesread/4, 2, 16, srate);
+ }
}
mutex_unlock (decodemutex);
bytes += bytesread;