]> code.delx.au - pulseaudio/blobdiff - src/modules/module-equalizer-sink.c
Correct spelling of PulseAudio
[pulseaudio] / src / modules / module-equalizer-sink.c
index 19b679bf28bdc6fa14f1009f217c74f2d3a3610e..adaef694b632135702e2c45da309c6d0864ca68e 100644 (file)
@@ -3,7 +3,7 @@
 
   This module is based off Lennart Poettering's LADSPA sink and swaps out
   LADSPA functionality for a dbus-aware STFT OLA based digital equalizer.
-  All new work is published under Pulseaudio's original license.
+  All new work is published under PulseAudio's original license.
 
   Copyright 2009 Jason Newton <nevion@gmail.com>
 
@@ -81,6 +81,7 @@ PA_MODULE_USAGE(
           "channels=<number of channels> "
           "channel_map=<channel map> "
           "autoloaded=<set if this module is being loaded automatically> "
+          "use_volume_sharing=<yes or no> "
          ));
 
 #define MEMBLOCKQ_MAXLENGTH (16*1024*1024)
@@ -139,6 +140,7 @@ static const char* const valid_modargs[] = {
     "channels",
     "channel_map",
     "autoloaded",
+    "use_volume_sharing",
     NULL
 };
 
@@ -367,7 +369,7 @@ static void dsp_logic(
     for(size_t j = 0; j < u->window_size; ++j){
         dst[j] = X * W[j] * src[j];
     }
-    //zero pad the the remaining fft window
+    //zero pad the remaining fft window
     memset(dst + u->window_size, 0, (u->fft_size - u->window_size) * sizeof(float));
     //Processing is done here!
     //do fft
@@ -439,7 +441,7 @@ static void dsp_logic(
 //        d->v = x->v * w->v * s->v;
 //#endif
     }
-    //zero pad the the remaining fft window
+    //zero pad the remaining fft window
     memset(dst + u->window_size, 0, (u->fft_size - u->window_size) * sizeof(float));
 
     //Processing is done here!
@@ -1053,6 +1055,9 @@ static pa_bool_t sink_input_may_move_to_cb(pa_sink_input *i, pa_sink *dest) {
     pa_sink_input_assert_ref(i);
     pa_assert_se(u = i->userdata);
 
+    if (u->autoloaded)
+        return FALSE;
+
     return u->sink != dest;
 }
 
@@ -1079,10 +1084,11 @@ int pa__init(pa_module*m) {
     pa_sink *master;
     pa_sink_input_new_data sink_input_data;
     pa_sink_new_data sink_data;
-    size_t fs, i;
+    size_t i;
     unsigned c;
     float *H;
     unsigned a_i;
+    pa_bool_t use_volume_sharing = TRUE;
 
     pa_assert(m);
 
@@ -1104,7 +1110,12 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
-    fs = pa_frame_size(&ss);
+    //fs = pa_frame_size(&ss);
+
+    if (pa_modargs_get_value_boolean(ma, "use_volume_sharing", &use_volume_sharing) < 0) {
+        pa_log("use_volume_sharing= expects a boolean argument");
+        goto fail;
+    }
 
     u = pa_xnew0(struct userdata, 1);
     u->module = m;
@@ -1179,8 +1190,8 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
-    u->sink = pa_sink_new(m->core, &sink_data,
-                          (master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)));
+    u->sink = pa_sink_new(m->core, &sink_data, (master->flags & (PA_SINK_LATENCY | PA_SINK_DYNAMIC_LATENCY))
+                                               | (use_volume_sharing ? PA_SINK_SHARE_VOLUME_WITH_MASTER : 0));
     pa_sink_new_data_done(&sink_data);
 
     if (!u->sink) {
@@ -1192,13 +1203,15 @@ int pa__init(pa_module*m) {
     u->sink->set_state = sink_set_state_cb;
     u->sink->update_requested_latency = sink_update_requested_latency_cb;
     u->sink->request_rewind = sink_request_rewind_cb;
-    pa_sink_enable_decibel_volume(u->sink, TRUE);
-    pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
     pa_sink_set_set_mute_callback(u->sink, sink_set_mute_cb);
+    if (!use_volume_sharing) {
+        pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
+        pa_sink_enable_decibel_volume(u->sink, TRUE);
+    }
     u->sink->userdata = u;
 
-    u->input_q = pa_memblockq_new(0,  MEMBLOCKQ_MAXLENGTH, 0, fs, 1, 1, 0, &u->sink->silence);
-    u->output_q = pa_memblockq_new(0,  MEMBLOCKQ_MAXLENGTH, 0, fs, 1, 1, 0, NULL);
+    u->input_q = pa_memblockq_new("module-equalizer-sink input_q", 0, MEMBLOCKQ_MAXLENGTH, 0, &ss, 1, 1, 0, &u->sink->silence);
+    u->output_q = pa_memblockq_new("module-equalizer-sink output_q", 0, MEMBLOCKQ_MAXLENGTH, 0, &ss, 1, 1, 0, NULL);
     u->output_buffer = NULL;
     u->output_buffer_length = 0;
     u->output_buffer_max_length = 0;
@@ -1235,7 +1248,8 @@ int pa__init(pa_module*m) {
     u->sink_input->state_change = sink_input_state_change_cb;
     u->sink_input->may_move_to = sink_input_may_move_to_cb;
     u->sink_input->moving = sink_input_moving_cb;
-    u->sink_input->volume_changed = sink_input_volume_changed_cb;
+    if (!use_volume_sharing)
+        u->sink_input->volume_changed = sink_input_volume_changed_cb;
     u->sink_input->mute_changed = sink_input_mute_changed_cb;
     u->sink_input->userdata = u;