Merge pull request #113288 from goatchurchprime/gtch/audioservermic

AudioServer to have function to access microphone buffer directly
This commit is contained in:
Thaddeus Crews
2025-12-03 16:50:32 -06:00
7 changed files with 136 additions and 23 deletions

View File

@@ -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();

View File

@@ -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() {