mirror of
https://github.com/godotengine/godot.git
synced 2025-01-18 20:40:57 +08:00
Fix single channel capture devices on WASAPI.
This commit is contained in:
parent
909cf03568
commit
7142e1d3f7
@ -675,18 +675,28 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
|
|||||||
ERR_BREAK(hr != S_OK);
|
ERR_BREAK(hr != S_OK);
|
||||||
|
|
||||||
// fixme: Only works for floating point atm
|
// fixme: Only works for floating point atm
|
||||||
for (int j = 0; j < num_frames_available * ad->audio_input.channels; j++) {
|
for (int j = 0; j < num_frames_available; j++) {
|
||||||
int32_t sample;
|
int32_t sample_channel[2];
|
||||||
|
|
||||||
if (flags & AUDCLNT_BUFFERFLAGS_SILENT) {
|
if (flags & AUDCLNT_BUFFERFLAGS_SILENT) {
|
||||||
sample = 0;
|
sample_channel[0] = sample_channel[1] = 0;
|
||||||
} else {
|
} else {
|
||||||
sample = read_sample(ad->audio_input.format_tag, ad->audio_input.bits_per_sample, data, j);
|
if (ad->audio_input.channels == 2) {
|
||||||
|
sample_channel[0] = read_sample(ad->audio_input.format_tag, ad->audio_input.bits_per_sample, data, j * 2);
|
||||||
|
sample_channel[1] = read_sample(ad->audio_input.format_tag, ad->audio_input.bits_per_sample, data, j * 2 + 1);
|
||||||
|
} else if (ad->audio_input.channels == 1) {
|
||||||
|
sample_channel[0] = sample_channel[1] = read_sample(ad->audio_input.format_tag, ad->audio_input.bits_per_sample, data, j);
|
||||||
|
} else {
|
||||||
|
sample_channel[0] = sample_channel[1] = 0;
|
||||||
|
ERR_PRINT("WASAPI: unsupported channel count in microphone!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ad->audio_input_buffer.write[ad->audio_input_position++] = sample;
|
for (int k = 0; k < 2; k++) {
|
||||||
if (ad->audio_input_position >= ad->audio_input_buffer.size()) {
|
ad->audio_input_buffer.write[ad->audio_input_position++] = sample_channel[k];
|
||||||
ad->audio_input_position = 0;
|
if (ad->audio_input_position >= ad->audio_input_buffer.size()) {
|
||||||
|
ad->audio_input_position = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user