summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMarcelo Fernandez <marcelofg55@gmail.com>2018-07-27 15:09:03 -0300
committerMarcelo Fernandez <marcelofg55@gmail.com>2018-07-27 15:09:03 -0300
commit597301db349c2c0c70af6b411465a5f578765052 (patch)
treeb0962c874bfd78eef0f688b5f7160414b06cdd00 /drivers
parentdd8a0b92e0bbc0e82263061b3947cb93a39f9df1 (diff)
Renamed AudioDriver audio_input_* vars to input_*
Diffstat (limited to 'drivers')
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.cpp25
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.h1
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp16
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp36
4 files changed, 28 insertions, 50 deletions
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp
index 1344a9075e..e1f47cb8c2 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.cpp
+++ b/drivers/coreaudio/audio_driver_coreaudio.cpp
@@ -174,9 +174,9 @@ Error AudioDriverCoreAudio::init() {
unsigned int buffer_size = buffer_frames * channels;
samples_in.resize(buffer_size);
input_buf.resize(buffer_size);
- audio_input_buffer.resize(buffer_size * 8);
- audio_input_position = 0;
- audio_input_size = 0;
+ input_buffer.resize(buffer_size * 8);
+ input_position = 0;
+ input_size = 0;
if (OS::get_singleton()->is_stdout_verbose()) {
print_line("CoreAudio: detected " + itos(channels) + " channels");
@@ -247,17 +247,6 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
return 0;
};
-void AudioDriverCoreAudio::_input_write_sample(int32_t sample) {
-
- audio_input_buffer.write[audio_input_position++] = sample;
- if (audio_input_position >= audio_input_buffer.size()) {
- audio_input_position = 0;
- }
- if (audio_input_size < audio_input_buffer.size()) {
- audio_input_size++;
- }
-}
-
OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
@@ -281,11 +270,11 @@ OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon,
if (result == noErr) {
for (int i = 0; i < inNumberFrames * ad->capture_channels; i++) {
int32_t sample = ad->input_buf[i] << 16;
- ad->_input_write_sample(sample);
+ ad->input_buffer_write(sample);
if (ad->capture_channels == 1) {
// In case input device is single channel convert it to Stereo
- ad->_input_write_sample(sample);
+ ad->input_buffer_write(sample);
}
}
} else {
@@ -545,8 +534,8 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
ERR_FAIL_COND(result != noErr);
// Reset audio input to keep synchronisation.
- audio_input_position = 0;
- audio_input_size = 0;
+ input_position = 0;
+ input_size = 0;
}
}
diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h
index 53a3e5e038..d3f7c8d596 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.h
+++ b/drivers/coreaudio/audio_driver_coreaudio.h
@@ -61,7 +61,6 @@ class AudioDriverCoreAudio : public AudioDriver {
#ifdef OSX_ENABLED
Array _get_device_list(bool capture = false);
void _set_device(const String &device, bool capture = false);
- void _input_write_sample(int32_t sample);
static OSStatus input_device_address_cb(AudioObjectID inObjectID,
UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses,
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index 71e7591566..66fdfc9c1b 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -380,7 +380,7 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
size_t bytes = pa_stream_readable_size(ad->pa_rec_str);
if (bytes > 0) {
const void *ptr = NULL;
- size_t maxbytes = ad->audio_input_buffer.size() * sizeof(int16_t);
+ size_t maxbytes = ad->input_buffer.size() * sizeof(int16_t);
bytes = MIN(bytes, maxbytes);
ret = pa_stream_peek(ad->pa_rec_str, &ptr, &bytes);
@@ -389,9 +389,9 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
} else {
int16_t *srcptr = (int16_t *)ptr;
for (size_t i = bytes >> 1; i > 0; i--) {
- ad->audio_input_buffer.write[ad->audio_input_position++] = int32_t(*srcptr++) << 16;
- if (ad->audio_input_position >= ad->audio_input_buffer.size()) {
- ad->audio_input_position = 0;
+ ad->input_buffer.write[ad->input_position++] = int32_t(*srcptr++) << 16;
+ if (ad->input_position >= ad->input_buffer.size()) {
+ ad->input_position = 0;
}
}
@@ -601,11 +601,11 @@ Error AudioDriverPulseAudio::capture_init_device() {
ERR_FAIL_V(ERR_CANT_OPEN);
}
- audio_input_buffer.resize(input_buffer_frames * 8);
- for (int i = 0; i < audio_input_buffer.size(); i++) {
- audio_input_buffer.write[i] = 0;
+ input_buffer.resize(input_buffer_frames * 8);
+ for (int i = 0; i < input_buffer.size(); i++) {
+ input_buffer.write[i] = 0;
}
- audio_input_position = 0;
+ input_position = 0;
return OK;
}
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index b641e213a8..827aecd1c8 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -320,8 +320,8 @@ Error AudioDriverWASAPI::init_render_device(bool reinit) {
// Sample rate is independent of channels (ref: https://stackoverflow.com/questions/11048825/audio-sample-frequency-rely-on-channels)
samples_in.resize(buffer_frames * channels);
- audio_input_position = 0;
- audio_input_size = 0;
+ input_position = 0;
+ input_size = 0;
if (OS::get_singleton()->is_stdout_verbose()) {
print_line("WASAPI: detected " + itos(channels) + " channels");
@@ -343,12 +343,9 @@ Error AudioDriverWASAPI::init_capture_device(bool reinit) {
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
// Set the buffer size
- audio_input_buffer.resize(max_frames * CAPTURE_BUFFER_CHANNELS);
- for (int i = 0; i < audio_input_buffer.size(); i++) {
- audio_input_buffer.write[i] = 0;
- }
- audio_input_position = 0;
- audio_input_size = 0;
+ input_buffer.resize(max_frames * CAPTURE_BUFFER_CHANNELS);
+ input_position = 0;
+ input_size = 0;
return OK;
}
@@ -682,31 +679,24 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
// fixme: Only works for floating point atm
for (int j = 0; j < num_frames_available; j++) {
- int32_t sample_channel[CAPTURE_BUFFER_CHANNELS];
+ int32_t l, r;
if (flags & AUDCLNT_BUFFERFLAGS_SILENT) {
- sample_channel[0] = sample_channel[1] = 0;
+ l = r = 0;
} else {
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);
+ l = read_sample(ad->audio_input.format_tag, ad->audio_input.bits_per_sample, data, j * 2);
+ r = 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);
+ l = r = read_sample(ad->audio_input.format_tag, ad->audio_input.bits_per_sample, data, j);
} else {
- sample_channel[0] = sample_channel[1] = 0;
+ l = r = 0;
ERR_PRINT("WASAPI: unsupported channel count in microphone!");
}
}
- for (int k = 0; k < CAPTURE_BUFFER_CHANNELS; 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;
- }
- if (ad->audio_input_size < ad->audio_input_buffer.size()) {
- ad->audio_input_size++;
- }
- }
+ input_buffer_write(l);
+ input_buffer_write(r);
}
read_frames += num_frames_available;