summaryrefslogtreecommitdiffstats
path: root/pica-client/capturegain_coreaudio.cpp
diff options
context:
space:
mode:
authorAnton <anton@picapica.im>2026-09-03 21:01:17 +0400
committerAnton <anton@picapica.im>2026-09-03 21:01:17 +0400
commite62dd7d30bec7a679013dcce8ec4bc2b2f842109 (patch)
tree0be99751303e3c0b3306b9d79ca344897996a05d /pica-client/capturegain_coreaudio.cpp
parentc6649895d58bcfab864bcc33b131db222e45bfef (diff)
downloadpica-pica-e62dd7d30bec7a679013dcce8ec4bc2b2f842109.tar.gz
pica-pica-e62dd7d30bec7a679013dcce8ec4bc2b2f842109.zip
pica-client: more improvements of echo cancellation
Diffstat (limited to 'pica-client/capturegain_coreaudio.cpp')
-rw-r--r--pica-client/capturegain_coreaudio.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/pica-client/capturegain_coreaudio.cpp b/pica-client/capturegain_coreaudio.cpp
index 59b1ff5..919d08d 100644
--- a/pica-client/capturegain_coreaudio.cpp
+++ b/pica-client/capturegain_coreaudio.cpp
@@ -183,6 +183,31 @@ public:
return true;
}
+ // kAudioDevicePropertyVolumeDecibels is the same control as the scalar
+ // above, reported on a decibel scale. Devices that expose the scalar do not
+ // always expose this one, hence the plain false rather than a fallback.
+ bool gainDb(double *out) override
+ {
+ if (!out || m_dev == kAudioObjectUnknown)
+ return false;
+
+ AudioObjectPropertyAddress addr;
+ addr.mSelector = kAudioDevicePropertyVolumeDecibels;
+ addr.mScope = kAudioObjectPropertyScopeInput;
+ addr.mElement = m_master ? 0 : (m_channels.isEmpty() ? 0 : m_channels[0]);
+
+ if (!AudioObjectHasProperty(m_dev, &addr))
+ return false;
+
+ Float32 db = 0.0f;
+ UInt32 size = sizeof(db);
+ if (AudioObjectGetPropertyData(m_dev, &addr, 0, nullptr, &size, &db) != noErr)
+ return false;
+
+ *out = db;
+ return true;
+ }
+
bool setGain(double value) override
{
if (m_dev == kAudioObjectUnknown)