summaryrefslogtreecommitdiffstats
path: root/drivers/coreaudio
diff options
context:
space:
mode:
authorsouplamp <camden.mcall@gmail.com>2022-11-24 08:41:40 -0600
committerRémi Verschelde <rverschelde@gmail.com>2023-01-31 18:25:11 +0100
commit5300daaff29b55d1d9ed55877f70644df3d3a434 (patch)
treeafa2cfab046e351df2a8c7f74261ce9d013fc320 /drivers/coreaudio
parent2b710bc336a02ace95eb0588f3b0744923faf004 (diff)
downloadredot-engine-5300daaff29b55d1d9ed55877f70644df3d3a434.tar.gz
Audio rename (device, capture_device) -> (output_device, input_device)
Change instances of audio properties 'device' to 'output_device', and instances of audio properties 'capture_device' to 'input_device', as well as their subsequent getter & setter functions. Update the docs to reflect these changes, as well as the 3-to-4 converter for GDScript and CSharp to make proper conversions (only exception is 'device' since that name is too vague and might replace non-AudioServer related instances, such as user comments and variables). This does not change internal references to references like 'Render Client' and 'Capture Client' in WASAPI; such is outside the scope of this commit. This also does not change ALSA's references, considering that it uses 'device' to mean input and output interchangeably. Other references are changed, however where applicable, to be consistent with the new AudioServer methods and property names.
Diffstat (limited to 'drivers/coreaudio')
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.cpp54
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.h18
2 files changed, 36 insertions, 36 deletions
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp
index e9eb11e2e3..c454da8e23 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.cpp
+++ b/drivers/coreaudio/audio_driver_coreaudio.cpp
@@ -44,10 +44,10 @@ OSStatus AudioDriverCoreAudio::input_device_address_cb(AudioObjectID inObjectID,
void *inClientData) {
AudioDriverCoreAudio *driver = static_cast<AudioDriverCoreAudio *>(inClientData);
- // If our selected device is the Default call set_device to update the
+ // If our selected input device is the Default, call set_input_device to update the
// kAudioOutputUnitProperty_CurrentDevice property
- if (driver->capture_device_name == "Default") {
- driver->capture_set_device("Default");
+ if (driver->input_device_name == "Default") {
+ driver->set_input_device("Default");
}
return noErr;
@@ -58,10 +58,10 @@ OSStatus AudioDriverCoreAudio::output_device_address_cb(AudioObjectID inObjectID
void *inClientData) {
AudioDriverCoreAudio *driver = static_cast<AudioDriverCoreAudio *>(inClientData);
- // If our selected device is the Default call set_device to update the
+ // If our selected output device is the Default call set_output_device to update the
// kAudioOutputUnitProperty_CurrentDevice property
- if (driver->device_name == "Default") {
- driver->set_device("Default");
+ if (driver->output_device_name == "Default") {
+ driver->set_output_device("Default");
}
return noErr;
@@ -495,7 +495,7 @@ Error AudioDriverCoreAudio::capture_stop() {
#ifdef MACOS_ENABLED
-PackedStringArray AudioDriverCoreAudio::_get_device_list(bool capture) {
+PackedStringArray AudioDriverCoreAudio::_get_device_list(bool input) {
PackedStringArray list;
list.push_back("Default");
@@ -514,7 +514,7 @@ PackedStringArray AudioDriverCoreAudio::_get_device_list(bool capture) {
UInt32 deviceCount = size / sizeof(AudioDeviceID);
for (UInt32 i = 0; i < deviceCount; i++) {
- prop.mScope = capture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+ prop.mScope = input ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
prop.mSelector = kAudioDevicePropertyStreamConfiguration;
AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, nullptr, &size);
@@ -555,10 +555,10 @@ PackedStringArray AudioDriverCoreAudio::_get_device_list(bool capture) {
return list;
}
-void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
+void AudioDriverCoreAudio::_set_device(const String &output_device, bool input) {
AudioDeviceID deviceId;
bool found = false;
- if (device != "Default") {
+ if (output_device != "Default") {
AudioObjectPropertyAddress prop;
prop.mSelector = kAudioHardwarePropertyDevices;
@@ -573,7 +573,7 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
UInt32 deviceCount = size / sizeof(AudioDeviceID);
for (UInt32 i = 0; i < deviceCount && !found; i++) {
- prop.mScope = capture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+ prop.mScope = input ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
prop.mSelector = kAudioDevicePropertyStreamConfiguration;
AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, nullptr, &size);
@@ -602,7 +602,7 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
ERR_FAIL_NULL_MSG(buffer, "Out of memory.");
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
String name = String::utf8(buffer) + " (" + itos(audioDevices[i]) + ")";
- if (name == device) {
+ if (name == output_device) {
deviceId = audioDevices[i];
found = true;
}
@@ -618,7 +618,7 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
if (!found) {
// If we haven't found the desired device get the system default one
UInt32 size = sizeof(AudioDeviceID);
- UInt32 elem = capture ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice;
+ UInt32 elem = input ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice;
AudioObjectPropertyAddress property = { elem, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, nullptr, &size, &deviceId);
@@ -628,10 +628,10 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
}
if (found) {
- OSStatus result = AudioUnitSetProperty(capture ? input_unit : audio_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(AudioDeviceID));
+ OSStatus result = AudioUnitSetProperty(input ? input_unit : audio_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(AudioDeviceID));
ERR_FAIL_COND(result != noErr);
- if (capture) {
+ if (input) {
// Reset audio input to keep synchronization.
input_position = 0;
input_size = 0;
@@ -639,34 +639,34 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
}
}
-PackedStringArray AudioDriverCoreAudio::get_device_list() {
+PackedStringArray AudioDriverCoreAudio::get_output_device_list() {
return _get_device_list();
}
-String AudioDriverCoreAudio::get_device() {
- return device_name;
+String AudioDriverCoreAudio::get_output_device() {
+ return output_device_name;
}
-void AudioDriverCoreAudio::set_device(String device) {
- device_name = device;
+void AudioDriverCoreAudio::set_output_device(String output_device) {
+ output_device_name = output_device;
if (active) {
- _set_device(device_name);
+ _set_device(output_device_name);
}
}
-void AudioDriverCoreAudio::capture_set_device(const String &p_name) {
- capture_device_name = p_name;
+void AudioDriverCoreAudio::set_input_device(const String &p_name) {
+ input_device_name = p_name;
if (active) {
- _set_device(capture_device_name, true);
+ _set_device(input_device_name, true);
}
}
-PackedStringArray AudioDriverCoreAudio::capture_get_device_list() {
+PackedStringArray AudioDriverCoreAudio::get_input_device_list() {
return _get_device_list(true);
}
-String AudioDriverCoreAudio::capture_get_device() {
- return capture_device_name;
+String AudioDriverCoreAudio::get_input_device() {
+ return input_device_name;
}
#endif
diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h
index 675265757b..2b192e630e 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.h
+++ b/drivers/coreaudio/audio_driver_coreaudio.h
@@ -47,8 +47,8 @@ class AudioDriverCoreAudio : public AudioDriver {
bool active = false;
Mutex mutex;
- String device_name = "Default";
- String capture_device_name = "Default";
+ String output_device_name = "Default";
+ String input_device_name = "Default";
int mix_rate = 0;
unsigned int channels = 2;
@@ -60,7 +60,7 @@ class AudioDriverCoreAudio : public AudioDriver {
#ifdef MACOS_ENABLED
PackedStringArray _get_device_list(bool capture = false);
- void _set_device(const String &device, bool capture = false);
+ void _set_device(const String &output_device, bool capture = false);
static OSStatus input_device_address_cb(AudioObjectID inObjectID,
UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses,
@@ -107,13 +107,13 @@ public:
void stop();
#ifdef MACOS_ENABLED
- virtual PackedStringArray get_device_list();
- virtual String get_device();
- virtual void set_device(String device);
+ virtual PackedStringArray get_output_device_list();
+ virtual String get_output_device();
+ virtual void set_output_device(String output_device);
- virtual PackedStringArray capture_get_device_list();
- virtual void capture_set_device(const String &p_name);
- virtual String capture_get_device();
+ virtual PackedStringArray get_input_device_list();
+ virtual void set_input_device(const String &p_name);
+ virtual String get_input_device();
#endif
AudioDriverCoreAudio();