summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libhfp/soundio.h15
-rw-r--r--libhfp/soundio-manager.cpp40
2 files changed, 50 insertions, 5 deletions
diff --git a/include/libhfp/soundio.h b/include/libhfp/soundio.h
index c349393..08c594c 100644
--- a/include/libhfp/soundio.h
+++ b/include/libhfp/soundio.h
@@ -1363,6 +1363,7 @@ private:
bool m_top_loop;
bool m_primary_open;
SoundIoFilter *m_dsp;
+ bool m_dsp_enabled;
bool m_dsp_installed;
char *m_driver_name;
@@ -1526,9 +1527,19 @@ public:
bool SetMute(bool up, bool dn = false);
/**
- * @brief Configure signal processing
+ * @brief Set the signal processing filter object
*/
- bool SetDsp(SoundIoFilter *dspp) ;
+ bool SetDsp(SoundIoFilter *dspp);
+
+ /**
+ * @brief Enable/disable the DSP filter
+ */
+ bool SetDspEnabled(bool enabled = true);
+
+ /**
+ * @brief Query whether the DSP filter is enabled
+ */
+ bool IsDspEnabled(void) { return m_dsp_enabled; }
/**
* @brief Request stream to start
diff --git a/libhfp/soundio-manager.cpp b/libhfp/soundio-manager.cpp
index b38a864..42f5500 100644
--- a/libhfp/soundio-manager.cpp
+++ b/libhfp/soundio-manager.cpp
@@ -287,7 +287,7 @@ SoundIoManager(DispatchInterface *di)
: m_pump(di, 0), m_config_packet_ms(0), m_primary(0),
m_mute_swap(false), m_mute_soft_up(false), m_mute_soft_dn(false),
m_mute_soft(0), m_top_loop(false), m_primary_open(false),
- m_dsp(0), m_dsp_installed(false),
+ m_dsp(0), m_dsp_enabled(true), m_dsp_installed(false),
m_driver_name(0), m_driver_opts(0)
{
m_pump.cb_NotifyAsyncState.Register(this,
@@ -651,15 +651,18 @@ SetDsp(SoundIoFilter *dspp)
SoundIoFilter *fltp;
if (m_dsp) {
if (m_dsp_installed) {
+ assert(m_dsp_enabled);
do_install = true;
fltp = m_pump.RemoveBottom();
assert(fltp == m_dsp);
m_dsp_installed = false;
}
m_dsp = 0;
+ } else {
+ do_install = IsStarted() && !m_top_loop && !m_mute_swap;
}
- if (do_install) {
+ if (do_install && m_dsp_enabled) {
if (!m_pump.AddBottom(dspp))
return false;
m_dsp_installed = true;
@@ -669,6 +672,34 @@ SetDsp(SoundIoFilter *dspp)
}
bool SoundIoManager::
+SetDspEnabled(bool enabled)
+{
+ SoundIoFilter *fltp;
+
+ if (m_dsp_enabled == enabled)
+ return true;
+
+ if (!enabled) {
+ if (m_dsp_installed) {
+ fltp = m_pump.RemoveBottom();
+ assert(fltp == m_dsp);
+ m_dsp_installed = false;
+ }
+ m_dsp_enabled = false;
+ return true;
+ }
+
+ if (m_dsp && IsStarted() && !m_top_loop && !m_mute_swap) {
+ if (!m_pump.AddBottom(m_dsp))
+ return false;
+ m_dsp_installed = true;
+ }
+
+ m_dsp_enabled = true;
+ return true;
+}
+
+bool SoundIoManager::
OpenPrimary(bool sink, bool source)
{
OpLatencyMonitor lm(GetDi(), "primary open");
@@ -689,6 +720,7 @@ ClosePrimary(void)
if (m_dsp_installed) {
SoundIoFilter *fltp;
+ assert(m_dsp_enabled);
fltp = m_pump.RemoveBottom();
assert(fltp == m_dsp);
m_dsp_installed = false;
@@ -744,13 +776,15 @@ Start(bool up, bool down)
}
if (m_dsp) {
- if (!m_top_loop && !m_mute_swap && !m_dsp_installed) {
+ if (!m_top_loop && !m_mute_swap &&
+ m_dsp_enabled && !m_dsp_installed) {
res = m_pump.AddBottom(m_dsp);
assert(res);
m_dsp_installed = true;
}
else if ((m_top_loop || m_mute_swap) && m_dsp_installed) {
SoundIoFilter *fltp;
+ assert(m_dsp_enabled);
fltp = m_pump.RemoveBottom();
assert(fltp == m_dsp);
m_dsp_installed = false;