summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSaracen <SaracenOne@gmail.com>2018-07-26 23:36:16 +0100
committerSaracen <SaracenOne@gmail.com>2018-07-27 16:50:12 +0100
commit7142e1d3f7af98850d64ec881d21ed82222396a0 (patch)
tree8996c7c54913b3cfdf16f411a470d0b5234464c6 /drivers
parent909cf03568b2b9ca62cd72a7d20e494fac21be66 (diff)
Fix single channel capture devices on WASAPI.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index a01d991450..7ae87f04a8 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -675,18 +675,28 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
ERR_BREAK(hr != S_OK);
// fixme: Only works for floating point atm
- for (int j = 0; j < num_frames_available * ad->audio_input.channels; j++) {
- int32_t sample;
+ for (int j = 0; j < num_frames_available; j++) {
+ int32_t sample_channel[2];
if (flags & AUDCLNT_BUFFERFLAGS_SILENT) {
- sample = 0;
+ sample_channel[0] = sample_channel[1] = 0;
} 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;
- if (ad->audio_input_position >= ad->audio_input_buffer.size()) {
- ad->audio_input_position = 0;
+ for (int k = 0; k < 2; k++) {
+ ad->audio_input_buffer.write[ad->audio_input_position++] = sample_channel[k];
+ if (ad->audio_input_position >= ad->audio_input_buffer.size()) {
+ ad->audio_input_position = 0;
+ }
}
}