PA_ECHO_CANCELLER_INVALID = -1,
PA_ECHO_CANCELLER_SPEEX = 0,
PA_ECHO_CANCELLER_ADRIAN,
+#ifdef HAVE_WEBRTC
+ PA_ECHO_CANCELLER_WEBRTC,
+#endif
} pa_echo_canceller_method_t;
#define DEFAULT_ECHO_CANCELLER "speex"
.run = pa_adrian_ec_run,
.done = pa_adrian_ec_done,
},
+#ifdef HAVE_WEBRTC
+ {
+ /* WebRTC's audio processing engine */
+ .init = pa_webrtc_ec_init,
+ .run = pa_webrtc_ec_run,
+ .done = pa_webrtc_ec_done,
+ },
+#endif
};
#define DEFAULT_RATE 32000
#define MEMBLOCKQ_MAXLENGTH (16*1024*1024)
+/* Can only be used in main context */
+#define IS_ACTIVE(u) ((pa_source_get_state((u)->source) == PA_SOURCE_RUNNING) && \
+ (pa_sink_get_state((u)->sink) == PA_SINK_RUNNING))
+
/* This module creates a new (virtual) source and sink.
*
* The data sent to the new sink is kept in a memblockq before being
pa_atomic_t request_resync;
- int active_mask;
pa_time_event *time_event;
pa_usec_t adjust_time;
int adjust_threshold;
pa_assert(u->time_event == e);
pa_assert_ctl_context();
- if (u->active_mask != 3)
+ if (!IS_ACTIVE(u))
return;
/* update our snapshots */
!PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output)))
return 0;
- pa_log_debug("Source state %d %d", state, u->active_mask);
-
if (state == PA_SOURCE_RUNNING) {
/* restart timer when both sink and source are active */
- u->active_mask |= 1;
- if (u->active_mask == 3 && u->adjust_time)
+ if (IS_ACTIVE(u) && u->adjust_time)
pa_core_rttime_restart(u->core, u->time_event, pa_rtclock_now() + u->adjust_time);
pa_atomic_store(&u->request_resync, 1);
pa_source_output_cork(u->source_output, FALSE);
} else if (state == PA_SOURCE_SUSPENDED) {
- u->active_mask &= ~1;
pa_source_output_cork(u->source_output, TRUE);
}
+
return 0;
}
!PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
return 0;
- pa_log_debug("Sink state %d %d", state, u->active_mask);
-
if (state == PA_SINK_RUNNING) {
/* restart timer when both sink and source are active */
- u->active_mask |= 2;
- if (u->active_mask == 3 && u->adjust_time)
+ if (IS_ACTIVE(u) && u->adjust_time)
pa_core_rttime_restart(u->core, u->time_event, pa_rtclock_now() + u->adjust_time);
pa_atomic_store(&u->request_resync, 1);
pa_sink_input_cork(u->sink_input, FALSE);
} else if (state == PA_SINK_SUSPENDED) {
- u->active_mask &= ~2;
pa_sink_input_cork(u->sink_input, TRUE);
}
+
return 0;
}
return PA_ECHO_CANCELLER_SPEEX;
else if (pa_streq(method, "adrian"))
return PA_ECHO_CANCELLER_ADRIAN;
+#ifdef HAVE_WEBRTC
+ else if (pa_streq(method, "webrtc"))
+ return PA_ECHO_CANCELLER_WEBRTC;
+#endif
else
return PA_ECHO_CANCELLER_INVALID;
}
goto fail;
}
- /* our source and sink are not suspended when we create them */
- u->active_mask = 3;
-
if (u->adjust_time > 0)
u->time_event = pa_core_rttime_new(m->core, pa_rtclock_now() + u->adjust_time, time_callback, u);