Access microphone buffer from AudioServer and prevent microphone double starts
This commit is contained in:
committed by
Lukas Tenbrink
parent
7ed0b61676
commit
3e8bf3ba91
@@ -555,6 +555,8 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
|
||||
}
|
||||
|
||||
// User selected a new input device, finish the current one so we'll init the new input device
|
||||
// (If `AudioServer.set_input_device()` did not set the value when the microphone was running,
|
||||
// this section with its problematic error handling could be deleted.)
|
||||
if (ad->input_device_name != ad->new_input_device) {
|
||||
ad->input_device_name = ad->new_input_device;
|
||||
ad->finish_input_device();
|
||||
@@ -691,6 +693,10 @@ void AudioDriverPulseAudio::finish() {
|
||||
}
|
||||
|
||||
Error AudioDriverPulseAudio::init_input_device() {
|
||||
if (pa_rec_str) {
|
||||
return ERR_ALREADY_IN_USE;
|
||||
}
|
||||
|
||||
// If there is a specified input device, check that it is really present
|
||||
if (input_device_name != "Default") {
|
||||
PackedStringArray list = get_input_device_list();
|
||||
|
||||
@@ -542,6 +542,10 @@ Error AudioDriverWASAPI::init_output_device(bool p_reinit) {
|
||||
}
|
||||
|
||||
Error AudioDriverWASAPI::init_input_device(bool p_reinit) {
|
||||
if (audio_input.active.is_set()) {
|
||||
return ERR_ALREADY_IN_USE;
|
||||
}
|
||||
|
||||
Error err = audio_device_init(&audio_input, true, p_reinit);
|
||||
if (err != OK) {
|
||||
// We've tried to init the device, but have failed. Time to clean up.
|
||||
@@ -1023,11 +1027,9 @@ Error AudioDriverWASAPI::input_stop() {
|
||||
if (audio_input.active.is_set()) {
|
||||
audio_input.audio_client->Stop();
|
||||
audio_input.active.clear();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
return FAILED;
|
||||
return OK;
|
||||
}
|
||||
|
||||
PackedStringArray AudioDriverWASAPI::get_input_device_list() {
|
||||
|
||||
Reference in New Issue
Block a user