]> code.delx.au - pulseaudio/blobdiff - src/modules/echo-cancel/echo-cancel.h
bluetooth: Fix thread teardown code ordering
[pulseaudio] / src / modules / echo-cancel / echo-cancel.h
index 15d44f53644941810d2f4f68065a96d995559418..c33b1ef467d8065d646e3aa427377b1024852413 100644 (file)
@@ -46,16 +46,21 @@ typedef struct pa_echo_canceller_params pa_echo_canceller_params;
 
 struct pa_echo_canceller_params {
     union {
+        struct {
+            pa_sample_spec source_ss;
+        } null;
 #ifdef HAVE_SPEEX
         struct {
             SpeexEchoState *state;
             SpeexPreprocessState *pp_state;
         } speex;
 #endif
+#ifdef HAVE_ADRIAN_EC
         struct {
             uint32_t blocksize;
             AEC *aec;
         } adrian;
+#endif
 #ifdef HAVE_WEBRTC
         struct {
             /* This is a void* so that we don't have to convert this whole file
@@ -84,7 +89,7 @@ struct pa_echo_canceller {
                                          pa_channel_map *source_map,
                                          pa_sample_spec *sink_ss,
                                          pa_channel_map *sink_map,
-                                         uint32_t *blocksize,
+                                         uint32_t *nframes,
                                          const char *args);
 
     /* You should have only one of play()+record() or run() set. The first
@@ -92,13 +97,13 @@ struct pa_echo_canceller {
      * samples yourself. If you set run(), module-echo-cancel will handle
      * synchronising the playback and record streams. */
 
-    /* Feed the engine 'blocksize' playback bytes.. */
+    /* Feed the engine 'nframes' playback frames. */
     void        (*play)                 (pa_echo_canceller *ec, const uint8_t *play);
-    /* Feed the engine 'blocksize' record bytes. blocksize processed bytes are
+    /* Feed the engine 'nframes' record frames. nframes processed frames are
      * returned in out. */
     void        (*record)               (pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out);
-    /* Feed the engine blocksize playback and record streams, with a reasonable
-     * effort at keeping the two in sync. blocksize processed bytes are
+    /* Feed the engine nframes playback and record frames, with a reasonable
+     * effort at keeping the two in sync. nframes processed frames are
      * returned in out. */
     void        (*run)                  (pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
 
@@ -126,23 +131,37 @@ struct pa_echo_canceller {
 void pa_echo_canceller_get_capture_volume(pa_echo_canceller *ec, pa_cvolume *v);
 void pa_echo_canceller_set_capture_volume(pa_echo_canceller *ec, pa_cvolume *v);
 
+/* Computes EC block size in frames (rounded down to nearest power-of-2) based
+ * on sample rate and milliseconds. */
+uint32_t pa_echo_canceller_blocksize_power2(unsigned rate, unsigned ms);
+
+/* Null canceller functions */
+pa_bool_t pa_null_ec_init(pa_core *c, pa_echo_canceller *ec,
+                           pa_sample_spec *source_ss, pa_channel_map *source_map,
+                           pa_sample_spec *sink_ss, pa_channel_map *sink_map,
+                           uint32_t *nframes, const char *args);
+void pa_null_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
+void pa_null_ec_done(pa_echo_canceller *ec);
+
 #ifdef HAVE_SPEEX
 /* Speex canceller functions */
 pa_bool_t pa_speex_ec_init(pa_core *c, pa_echo_canceller *ec,
                            pa_sample_spec *source_ss, pa_channel_map *source_map,
                            pa_sample_spec *sink_ss, pa_channel_map *sink_map,
-                           uint32_t *blocksize, const char *args);
+                           uint32_t *nframes, const char *args);
 void pa_speex_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
 void pa_speex_ec_done(pa_echo_canceller *ec);
 #endif
 
+#ifdef HAVE_ADRIAN_EC
 /* Adrian Andre's echo canceller */
 pa_bool_t pa_adrian_ec_init(pa_core *c, pa_echo_canceller *ec,
                            pa_sample_spec *source_ss, pa_channel_map *source_map,
                            pa_sample_spec *sink_ss, pa_channel_map *sink_map,
-                           uint32_t *blocksize, const char *args);
+                           uint32_t *nframes, const char *args);
 void pa_adrian_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
 void pa_adrian_ec_done(pa_echo_canceller *ec);
+#endif
 
 #ifdef HAVE_WEBRTC
 /* WebRTC canceller functions */
@@ -150,7 +169,7 @@ PA_C_DECL_BEGIN
 pa_bool_t pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
                             pa_sample_spec *source_ss, pa_channel_map *source_map,
                             pa_sample_spec *sink_ss, pa_channel_map *sink_map,
-                            uint32_t *blocksize, const char *args);
+                            uint32_t *nframes, const char *args);
 void pa_webrtc_ec_play(pa_echo_canceller *ec, const uint8_t *play);
 void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out);
 void pa_webrtc_ec_set_drift(pa_echo_canceller *ec, float drift);