forked from OpenGamers/abaddon
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
|
#ifdef WITH_VOICE
|
||||||
void Abaddon::OnVoiceConnected() {
|
void Abaddon::OnVoiceConnected() {
|
||||||
|
m_audio->StartCaptureDevice();
|
||||||
|
|
||||||
auto *wnd = new VoiceWindow(m_discord.GetVoiceChannelID());
|
auto *wnd = new VoiceWindow(m_discord.GetVoiceChannelID());
|
||||||
m_voice_window = wnd;
|
m_voice_window = wnd;
|
||||||
|
|
||||||
@@ -473,6 +475,7 @@ void Abaddon::OnVoiceConnected() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Abaddon::OnVoiceDisconnected() {
|
void Abaddon::OnVoiceDisconnected() {
|
||||||
|
m_audio->StopCaptureDevice();
|
||||||
m_audio->RemoveAllSSRCs();
|
m_audio->RemoveAllSSRCs();
|
||||||
if (m_voice_window != nullptr) {
|
if (m_voice_window != nullptr) {
|
||||||
m_voice_window->close();
|
m_voice_window->close();
|
||||||
|
|||||||
@@ -98,13 +98,6 @@ AudioManager::AudioManager() {
|
|||||||
return;
|
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];
|
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);
|
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);
|
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) {
|
void AudioManager::SetCapture(bool capture) {
|
||||||
m_should_capture = capture;
|
m_should_capture = capture;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ public:
|
|||||||
void SetOpusBuffer(uint8_t *ptr);
|
void SetOpusBuffer(uint8_t *ptr);
|
||||||
void FeedMeOpus(uint32_t ssrc, const std::vector<uint8_t> &data);
|
void FeedMeOpus(uint32_t ssrc, const std::vector<uint8_t> &data);
|
||||||
|
|
||||||
|
void StartCaptureDevice();
|
||||||
|
void StopCaptureDevice();
|
||||||
|
|
||||||
void SetCapture(bool capture);
|
void SetCapture(bool capture);
|
||||||
void SetPlayback(bool playback);
|
void SetPlayback(bool playback);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user