summaryrefslogtreecommitdiff
path: root/plugins/supereq
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-03-20 19:01:38 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-03-20 19:01:38 +0100
commiteef7400dc4c55adf166a09142d859900d537c803 (patch)
treedd4f5907345945d624997cc5995e458f131cd319 /plugins/supereq
parent056037264ec02c62109c525ef5bd2097577adf81 (diff)
moved eq reconfiguration to separate thread
Diffstat (limited to 'plugins/supereq')
-rw-r--r--plugins/supereq/supereq.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/plugins/supereq/supereq.c b/plugins/supereq/supereq.c
index d3509312..f9f98940 100644
--- a/plugins/supereq/supereq.c
+++ b/plugins/supereq/supereq.c
@@ -29,40 +29,73 @@ void equ_clearbuf(int bps,int srate);
void equ_init(int wb);
void equ_quit(void);
-float last_srate = 0;
-int last_nch = 0, last_bps = 0;
-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};
-float rbands[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};
-void *paramsroot;
+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};
+static float rbands[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};
+static void *paramsroot;
+
+static int params_changed = 0;
+static intptr_t tid = 0;
+static uintptr_t mutex = 0;
int
supereq_plugin_start (void) {
equ_init (14);
paramsroot = paramlist_alloc ();
+ last_srate = 44100;
+ last_nch = 2;
+ last_bps = 16;
+ equ_makeTable (lbands, rbands, paramsroot, last_srate);
+ equ_clearbuf (last_bps,last_srate);
+ mutex = deadbeef->mutex_create ();
return 0;
}
int
supereq_plugin_stop (void) {
+ if (tid) {
+ deadbeef->thread_join (tid);
+ deadbeef->mutex_free (mutex);
+ mutex = 0;
+ }
equ_quit ();
paramlist_free (paramsroot);
return 0;
}
+void
+supereq_regen_table_thread (void *param) {
+ void *params = paramlist_alloc ();
+ deadbeef->mutex_lock (mutex);
+ equ_makeTable (lbands, rbands, params, last_srate);
+ paramlist_free (paramsroot);
+ paramsroot = params;
+ deadbeef->mutex_unlock (mutex);
+ tid = 0;
+}
int
supereq_process_int16 (int16_t *samples, int nsamples, int nch, int bps, int srate) {
if ((nch != 1 && nch != 2) || (bps != 8 && bps != 16 && bps != 24)) return nsamples;
+ if (params_changed && !tid) {
+ tid = deadbeef->thread_start (supereq_regen_table_thread, NULL);
+ params_changed = 0;
+ }
if (last_srate != srate) {
+ deadbeef->mutex_lock (mutex);
equ_makeTable (lbands, rbands, paramsroot, srate);
last_srate = srate;
last_nch = nch;
last_bps = bps;
+ deadbeef->mutex_unlock (mutex);
equ_clearbuf(bps,srate);
}
else if (last_nch != nch || last_bps != bps) {
+ deadbeef->mutex_lock (mutex);
last_nch = nch;
last_bps = bps;
+ deadbeef->mutex_unlock (mutex);
equ_clearbuf(bps,srate);
}
equ_modifySamples((char *)samples,nsamples,nch,bps);
@@ -76,8 +109,10 @@ supereq_get_band (int band) {
void
supereq_set_band (int band, float value) {
- last_srate = 0;
+ deadbeef->mutex_lock (mutex);
lbands[band] = rbands[band] = value;
+ deadbeef->mutex_unlock (mutex);
+ params_changed = 1;
}
static DB_supereq_dsp_t plugin = {