mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-06 20:15:19 +03:00
only enable microphone when in a voice channel
This commit is contained in:
@@ -427,6 +427,8 @@ void Abaddon::DiscordOnThreadUpdate(const ThreadUpdateData &data) {
|
||||
|
||||
#ifdef WITH_VOICE
|
||||
void Abaddon::OnVoiceConnected() {
|
||||
m_audio->StartCaptureDevice();
|
||||
|
||||
auto *wnd = new VoiceWindow(m_discord.GetVoiceChannelID());
|
||||
m_voice_window = wnd;
|
||||
|
||||
@@ -473,6 +475,7 @@ void Abaddon::OnVoiceConnected() {
|
||||
}
|
||||
|
||||
void Abaddon::OnVoiceDisconnected() {
|
||||
m_audio->StopCaptureDevice();
|
||||
m_audio->RemoveAllSSRCs();
|
||||
if (m_voice_window != nullptr) {
|
||||
m_voice_window->close();
|
||||
|
||||
@@ -98,13 +98,6 @@ AudioManager::AudioManager() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ma_device_start(&m_capture_device) != MA_SUCCESS) {
|
||||
puts("failed to start capture");
|
||||
ma_device_uninit(&m_capture_device);
|
||||
m_ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
char device_name[MA_MAX_DEVICE_NAME_LENGTH + 1];
|
||||
ma_device_get_name(&m_capture_device, ma_device_type_capture, device_name, sizeof(device_name), nullptr);
|
||||
printf("using %s for capture\n", device_name);
|
||||
@@ -168,6 +161,18 @@ void AudioManager::FeedMeOpus(uint32_t ssrc, const std::vector<uint8_t> &data) {
|
||||
}
|
||||
}
|
||||
|
||||
void AudioManager::StartCaptureDevice() {
|
||||
if (ma_device_start(&m_capture_device) != MA_SUCCESS) {
|
||||
puts("failed to start capture");
|
||||
}
|
||||
}
|
||||
|
||||
void AudioManager::StopCaptureDevice() {
|
||||
if (ma_device_stop(&m_capture_device) != MA_SUCCESS) {
|
||||
puts("failed to stop capture");
|
||||
}
|
||||
}
|
||||
|
||||
void AudioManager::SetCapture(bool capture) {
|
||||
m_should_capture = capture;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ public:
|
||||
void SetOpusBuffer(uint8_t *ptr);
|
||||
void FeedMeOpus(uint32_t ssrc, const std::vector<uint8_t> &data);
|
||||
|
||||
void StartCaptureDevice();
|
||||
void StopCaptureDevice();
|
||||
|
||||
void SetCapture(bool capture);
|
||||
void SetPlayback(bool playback);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user