|
@@ -226,7 +226,7 @@ static SDL_bool AudioDeviceCanUseSimpleCopy(SDL_AudioDevice *device)
|
|
|
// should hold device->lock before calling.
|
|
|
static void UpdateAudioStreamFormatsPhysical(SDL_AudioDevice *device)
|
|
|
{
|
|
|
- if (!device->iscapture) { // for capture devices, we only want to move to float32 for postmix, which we'll handle elsewhere.
|
|
|
+ if (!device->recording) { // for recording devices, we only want to move to float32 for postmix, which we'll handle elsewhere.
|
|
|
const SDL_bool simple_copy = AudioDeviceCanUseSimpleCopy(device);
|
|
|
SDL_AudioSpec spec;
|
|
|
|
|
@@ -273,14 +273,14 @@ static Uint8 *ZombieGetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
|
|
return device->work_buffer;
|
|
|
}
|
|
|
|
|
|
-static int ZombieCaptureFromDevice(SDL_AudioDevice *device, void *buffer, int buflen)
|
|
|
+static int ZombieRecordDevice(SDL_AudioDevice *device, void *buffer, int buflen)
|
|
|
{
|
|
|
// return a full buffer of silence every time.
|
|
|
SDL_memset(buffer, device->silence_value, buflen);
|
|
|
return buflen;
|
|
|
}
|
|
|
|
|
|
-static void ZombieFlushCapture(SDL_AudioDevice *device)
|
|
|
+static void ZombieFlushRecording(SDL_AudioDevice *device)
|
|
|
{
|
|
|
// no-op, this is all imaginary.
|
|
|
}
|
|
@@ -303,19 +303,19 @@ static void ZombieFlushCapture(SDL_AudioDevice *device)
|
|
|
static void ClosePhysicalAudioDevice(SDL_AudioDevice *device);
|
|
|
|
|
|
|
|
|
-SDL_COMPILE_TIME_ASSERT(check_lowest_audio_default_value, SDL_AUDIO_DEVICE_DEFAULT_CAPTURE < SDL_AUDIO_DEVICE_DEFAULT_OUTPUT);
|
|
|
+SDL_COMPILE_TIME_ASSERT(check_lowest_audio_default_value, SDL_AUDIO_DEVICE_DEFAULT_RECORDING < SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK);
|
|
|
|
|
|
static SDL_AtomicInt last_device_instance_id; // increments on each device add to provide unique instance IDs
|
|
|
-static SDL_AudioDeviceID AssignAudioDeviceInstanceId(SDL_bool iscapture, SDL_bool islogical)
|
|
|
+static SDL_AudioDeviceID AssignAudioDeviceInstanceId(SDL_bool recording, SDL_bool islogical)
|
|
|
{
|
|
|
/* Assign an instance id! Start at 2, in case there are things from the SDL2 era that still think 1 is a special value.
|
|
|
- Also, make sure we don't assign SDL_AUDIO_DEVICE_DEFAULT_OUTPUT, etc. */
|
|
|
+ Also, make sure we don't assign SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, etc. */
|
|
|
|
|
|
- // The bottom two bits of the instance id tells you if it's an output device (1<<0), and if it's a physical device (1<<1).
|
|
|
- const SDL_AudioDeviceID flags = (iscapture ? 0 : (1<<0)) | (islogical ? 0 : (1<<1));
|
|
|
+ // The bottom two bits of the instance id tells you if it's an playback device (1<<0), and if it's a physical device (1<<1).
|
|
|
+ const SDL_AudioDeviceID flags = (recording ? 0 : (1<<0)) | (islogical ? 0 : (1<<1));
|
|
|
|
|
|
const SDL_AudioDeviceID instance_id = (((SDL_AudioDeviceID) (SDL_AtomicIncRef(&last_device_instance_id) + 1)) << 2) | flags;
|
|
|
- SDL_assert( (instance_id >= 2) && (instance_id < SDL_AUDIO_DEVICE_DEFAULT_CAPTURE) );
|
|
|
+ SDL_assert( (instance_id >= 2) && (instance_id < SDL_AUDIO_DEVICE_DEFAULT_RECORDING) );
|
|
|
return instance_id;
|
|
|
}
|
|
|
|
|
@@ -418,7 +418,7 @@ static SDL_AudioDevice *ObtainPhysicalAudioDevice(SDL_AudioDeviceID devid) // !
|
|
|
|
|
|
static SDL_AudioDevice *ObtainPhysicalAudioDeviceDefaultAllowed(SDL_AudioDeviceID devid) // !!! FIXME: SDL_ACQUIRE
|
|
|
{
|
|
|
- const SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_OUTPUT) || (devid == SDL_AUDIO_DEVICE_DEFAULT_CAPTURE));
|
|
|
+ const SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) || (devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING));
|
|
|
if (!wants_default) {
|
|
|
return ObtainPhysicalAudioDevice(devid);
|
|
|
}
|
|
@@ -427,10 +427,10 @@ static SDL_AudioDevice *ObtainPhysicalAudioDeviceDefaultAllowed(SDL_AudioDeviceI
|
|
|
|
|
|
while (SDL_TRUE) {
|
|
|
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
|
|
- if (orig_devid == SDL_AUDIO_DEVICE_DEFAULT_OUTPUT) {
|
|
|
- devid = current_audio.default_output_device_id;
|
|
|
- } else if (orig_devid == SDL_AUDIO_DEVICE_DEFAULT_CAPTURE) {
|
|
|
- devid = current_audio.default_capture_device_id;
|
|
|
+ if (orig_devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) {
|
|
|
+ devid = current_audio.default_playback_device_id;
|
|
|
+ } else if (orig_devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING) {
|
|
|
+ devid = current_audio.default_recording_device_id;
|
|
|
}
|
|
|
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
|
|
|
|
@@ -447,9 +447,9 @@ static SDL_AudioDevice *ObtainPhysicalAudioDeviceDefaultAllowed(SDL_AudioDeviceI
|
|
|
// make sure the default didn't change while we were waiting for the lock...
|
|
|
SDL_bool got_it = SDL_FALSE;
|
|
|
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
|
|
- if ((orig_devid == SDL_AUDIO_DEVICE_DEFAULT_OUTPUT) && (devid == current_audio.default_output_device_id)) {
|
|
|
+ if ((orig_devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) && (devid == current_audio.default_playback_device_id)) {
|
|
|
got_it = SDL_TRUE;
|
|
|
- } else if ((orig_devid == SDL_AUDIO_DEVICE_DEFAULT_CAPTURE) && (devid == current_audio.default_capture_device_id)) {
|
|
|
+ } else if ((orig_devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING) && (devid == current_audio.default_recording_device_id)) {
|
|
|
got_it = SDL_TRUE;
|
|
|
}
|
|
|
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
|
@@ -534,7 +534,7 @@ void UnrefPhysicalAudioDevice(SDL_AudioDevice *device)
|
|
|
// take it out of the device list.
|
|
|
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
|
|
if (SDL_RemoveFromHashTable(current_audio.device_hash, (const void *) (uintptr_t) device->instance_id)) {
|
|
|
- SDL_AtomicAdd(device->iscapture ? ¤t_audio.capture_device_count : ¤t_audio.output_device_count, -1);
|
|
|
+ SDL_AtomicAdd(device->recording ? ¤t_audio.recording_device_count : ¤t_audio.playback_device_count, -1);
|
|
|
}
|
|
|
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
|
|
DestroyPhysicalAudioDevice(device); // ...and nuke it.
|
|
@@ -546,7 +546,7 @@ void RefPhysicalAudioDevice(SDL_AudioDevice *device)
|
|
|
SDL_AtomicIncRef(&device->refcount);
|
|
|
}
|
|
|
|
|
|
-static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool iscapture, const SDL_AudioSpec *spec, void *handle, SDL_AtomicInt *device_count)
|
|
|
+static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool recording, const SDL_AudioSpec *spec, void *handle, SDL_AtomicInt *device_count)
|
|
|
{
|
|
|
SDL_assert(name != NULL);
|
|
|
|
|
@@ -585,14 +585,14 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool isc
|
|
|
|
|
|
SDL_AtomicSet(&device->shutdown, 0);
|
|
|
SDL_AtomicSet(&device->zombie, 0);
|
|
|
- device->iscapture = iscapture;
|
|
|
+ device->recording = recording;
|
|
|
SDL_copyp(&device->spec, spec);
|
|
|
SDL_copyp(&device->default_spec, spec);
|
|
|
device->sample_frames = GetDefaultSampleFramesFromFreq(device->spec.freq);
|
|
|
device->silence_value = SDL_GetSilenceValueForFormat(device->spec.format);
|
|
|
device->handle = handle;
|
|
|
|
|
|
- device->instance_id = AssignAudioDeviceInstanceId(iscapture, /*islogical=*/SDL_FALSE);
|
|
|
+ device->instance_id = AssignAudioDeviceInstanceId(recording, /*islogical=*/SDL_FALSE);
|
|
|
|
|
|
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
|
|
if (SDL_InsertIntoHashTable(current_audio.device_hash, (const void *) (uintptr_t) device->instance_id, device)) {
|
|
@@ -610,26 +610,26 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool isc
|
|
|
return device;
|
|
|
}
|
|
|
|
|
|
-static SDL_AudioDevice *CreateAudioCaptureDevice(const char *name, const SDL_AudioSpec *spec, void *handle)
|
|
|
+static SDL_AudioDevice *CreateAudioRecordingDevice(const char *name, const SDL_AudioSpec *spec, void *handle)
|
|
|
{
|
|
|
- SDL_assert(current_audio.impl.HasCaptureSupport);
|
|
|
- return CreatePhysicalAudioDevice(name, SDL_TRUE, spec, handle, ¤t_audio.capture_device_count);
|
|
|
+ SDL_assert(current_audio.impl.HasRecordingSupport);
|
|
|
+ return CreatePhysicalAudioDevice(name, SDL_TRUE, spec, handle, ¤t_audio.recording_device_count);
|
|
|
}
|
|
|
|
|
|
-static SDL_AudioDevice *CreateAudioOutputDevice(const char *name, const SDL_AudioSpec *spec, void *handle)
|
|
|
+static SDL_AudioDevice *CreateAudioPlaybackDevice(const char *name, const SDL_AudioSpec *spec, void *handle)
|
|
|
{
|
|
|
- return CreatePhysicalAudioDevice(name, SDL_FALSE, spec, handle, ¤t_audio.output_device_count);
|
|
|
+ return CreatePhysicalAudioDevice(name, SDL_FALSE, spec, handle, ¤t_audio.playback_device_count);
|
|
|
}
|
|
|
|
|
|
// The audio backends call this when a new device is plugged in.
|
|
|
-SDL_AudioDevice *SDL_AddAudioDevice(const SDL_bool iscapture, const char *name, const SDL_AudioSpec *inspec, void *handle)
|
|
|
+SDL_AudioDevice *SDL_AddAudioDevice(const SDL_bool recording, const char *name, const SDL_AudioSpec *inspec, void *handle)
|
|
|
{
|
|
|
- // device handles MUST be unique! If the target reuses the same handle for hardware with both input and output interfaces, wrap it in a pointer you SDL_malloc'd!
|
|
|
+ // device handles MUST be unique! If the target reuses the same handle for hardware with both recording and playback interfaces, wrap it in a pointer you SDL_malloc'd!
|
|
|
SDL_assert(SDL_FindPhysicalAudioDeviceByHandle(handle) == NULL);
|
|
|
|
|
|
- const SDL_AudioFormat default_format = iscapture ? DEFAULT_AUDIO_CAPTURE_FORMAT : DEFAULT_AUDIO_OUTPUT_FORMAT;
|
|
|
- const int default_channels = iscapture ? DEFAULT_AUDIO_CAPTURE_CHANNELS : DEFAULT_AUDIO_OUTPUT_CHANNELS;
|
|
|
- const int default_freq = iscapture ? DEFAULT_AUDIO_CAPTURE_FREQUENCY : DEFAULT_AUDIO_OUTPUT_FREQUENCY;
|
|
|
+ const SDL_AudioFormat default_format = recording ? DEFAULT_AUDIO_RECORDING_FORMAT : DEFAULT_AUDIO_PLAYBACK_FORMAT;
|
|
|
+ const int default_channels = recording ? DEFAULT_AUDIO_RECORDING_CHANNELS : DEFAULT_AUDIO_PLAYBACK_CHANNELS;
|
|
|
+ const int default_freq = recording ? DEFAULT_AUDIO_RECORDING_FREQUENCY : DEFAULT_AUDIO_PLAYBACK_FREQUENCY;
|
|
|
|
|
|
SDL_AudioSpec spec;
|
|
|
if (!inspec) {
|
|
@@ -642,7 +642,7 @@ SDL_AudioDevice *SDL_AddAudioDevice(const SDL_bool iscapture, const char *name,
|
|
|
spec.freq = (inspec->freq != 0) ? inspec->freq : default_freq;
|
|
|
}
|
|
|
|
|
|
- SDL_AudioDevice *device = iscapture ? CreateAudioCaptureDevice(name, &spec, handle) : CreateAudioOutputDevice(name, &spec, handle);
|
|
|
+ SDL_AudioDevice *device = recording ? CreateAudioRecordingDevice(name, &spec, handle) : CreateAudioPlaybackDevice(name, &spec, handle);
|
|
|
|
|
|
// Add a device add event to the pending list, to be pushed when the event queue is pumped (away from any of our internal threads).
|
|
|
if (device) {
|
|
@@ -682,7 +682,7 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device)
|
|
|
|
|
|
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
|
|
const SDL_AudioDeviceID devid = device->instance_id;
|
|
|
- const SDL_bool is_default_device = ((devid == current_audio.default_output_device_id) || (devid == current_audio.default_capture_device_id));
|
|
|
+ const SDL_bool is_default_device = ((devid == current_audio.default_playback_device_id) || (devid == current_audio.default_recording_device_id));
|
|
|
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
|
|
|
|
|
const SDL_bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1);
|
|
@@ -694,9 +694,9 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device)
|
|
|
device->WaitDevice = ZombieWaitDevice;
|
|
|
device->GetDeviceBuf = ZombieGetDeviceBuf;
|
|
|
device->PlayDevice = ZombiePlayDevice;
|
|
|
- device->WaitCaptureDevice = ZombieWaitDevice;
|
|
|
- device->CaptureFromDevice = ZombieCaptureFromDevice;
|
|
|
- device->FlushCapture = ZombieFlushCapture;
|
|
|
+ device->WaitRecordingDevice = ZombieWaitDevice;
|
|
|
+ device->RecordDevice = ZombieRecordDevice;
|
|
|
+ device->FlushRecording = ZombieFlushRecording;
|
|
|
|
|
|
// on default devices, dump any logical devices that explicitly opened this device. Things that opened the system default can stay.
|
|
|
// on non-default devices, dump everything.
|
|
@@ -746,8 +746,8 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device)
|
|
|
static void SDL_AudioThreadDeinit_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
|
|
static int SDL_AudioWaitDevice_Default(SDL_AudioDevice *device) { return 0; /* no-op. */ }
|
|
|
static int SDL_AudioPlayDevice_Default(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size) { return 0; /* no-op. */ }
|
|
|
-static int SDL_AudioWaitCaptureDevice_Default(SDL_AudioDevice *device) { return 0; /* no-op. */ }
|
|
|
-static void SDL_AudioFlushCapture_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
|
|
+static int SDL_AudioWaitRecordingDevice_Default(SDL_AudioDevice *device) { return 0; /* no-op. */ }
|
|
|
+static void SDL_AudioFlushRecording_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
|
|
static void SDL_AudioCloseDevice_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
|
|
static void SDL_AudioDeinitializeStart_Default(void) { /* no-op. */ }
|
|
|
static void SDL_AudioDeinitialize_Default(void) { /* no-op. */ }
|
|
@@ -755,18 +755,18 @@ static void SDL_AudioFreeDeviceHandle_Default(SDL_AudioDevice *device) { /* no-o
|
|
|
|
|
|
static void SDL_AudioThreadInit_Default(SDL_AudioDevice *device)
|
|
|
{
|
|
|
- SDL_SetThreadPriority(device->iscapture ? SDL_THREAD_PRIORITY_HIGH : SDL_THREAD_PRIORITY_TIME_CRITICAL);
|
|
|
+ SDL_SetThreadPriority(device->recording ? SDL_THREAD_PRIORITY_HIGH : SDL_THREAD_PRIORITY_TIME_CRITICAL);
|
|
|
}
|
|
|
|
|
|
-static void SDL_AudioDetectDevices_Default(SDL_AudioDevice **default_output, SDL_AudioDevice **default_capture)
|
|
|
+static void SDL_AudioDetectDevices_Default(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
|
|
{
|
|
|
// you have to write your own implementation if these assertions fail.
|
|
|
- SDL_assert(current_audio.impl.OnlyHasDefaultOutputDevice);
|
|
|
- SDL_assert(current_audio.impl.OnlyHasDefaultCaptureDevice || !current_audio.impl.HasCaptureSupport);
|
|
|
+ SDL_assert(current_audio.impl.OnlyHasDefaultPlaybackDevice);
|
|
|
+ SDL_assert(current_audio.impl.OnlyHasDefaultRecordingDevice || !current_audio.impl.HasRecordingSupport);
|
|
|
|
|
|
- *default_output = SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *)((size_t)0x1));
|
|
|
- if (current_audio.impl.HasCaptureSupport) {
|
|
|
- *default_capture = SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *)((size_t)0x2));
|
|
|
+ *default_playback = SDL_AddAudioDevice(SDL_FALSE, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)((size_t)0x1));
|
|
|
+ if (current_audio.impl.HasRecordingSupport) {
|
|
|
+ *default_recording = SDL_AddAudioDevice(SDL_TRUE, DEFAULT_RECORDING_DEVNAME, NULL, (void *)((size_t)0x2));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -776,7 +776,7 @@ static Uint8 *SDL_AudioGetDeviceBuf_Default(SDL_AudioDevice *device, int *buffer
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
-static int SDL_AudioCaptureFromDevice_Default(SDL_AudioDevice *device, void *buffer, int buflen)
|
|
|
+static int SDL_AudioRecordDevice_Default(SDL_AudioDevice *device, void *buffer, int buflen)
|
|
|
{
|
|
|
return SDL_Unsupported();
|
|
|
}
|
|
@@ -797,9 +797,9 @@ static void CompleteAudioEntryPoints(void)
|
|
|
FILL_STUB(WaitDevice);
|
|
|
FILL_STUB(PlayDevice);
|
|
|
FILL_STUB(GetDeviceBuf);
|
|
|
- FILL_STUB(WaitCaptureDevice);
|
|
|
- FILL_STUB(CaptureFromDevice);
|
|
|
- FILL_STUB(FlushCapture);
|
|
|
+ FILL_STUB(WaitRecordingDevice);
|
|
|
+ FILL_STUB(RecordDevice);
|
|
|
+ FILL_STUB(FlushRecording);
|
|
|
FILL_STUB(CloseDevice);
|
|
|
FILL_STUB(FreeDeviceHandle);
|
|
|
FILL_STUB(DeinitializeStart);
|
|
@@ -807,9 +807,9 @@ static void CompleteAudioEntryPoints(void)
|
|
|
#undef FILL_STUB
|
|
|
}
|
|
|
|
|
|
-static SDL_AudioDevice *GetFirstAddedAudioDevice(const SDL_bool iscapture)
|
|
|
+static SDL_AudioDevice *GetFirstAddedAudioDevice(const SDL_bool recording)
|
|
|
{
|
|
|
- SDL_AudioDeviceID highest = (SDL_AudioDeviceID) SDL_AUDIO_DEVICE_DEFAULT_OUTPUT; // According to AssignAudioDeviceInstanceId, nothing can have a value this large.
|
|
|
+ SDL_AudioDeviceID highest = (SDL_AudioDeviceID) SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK; // According to AssignAudioDeviceInstanceId, nothing can have a value this large.
|
|
|
SDL_AudioDevice *retval = NULL;
|
|
|
|
|
|
// (Device IDs increase as new devices are added, so the first device added has the lowest SDL_AudioDeviceID value.)
|
|
@@ -820,11 +820,11 @@ static SDL_AudioDevice *GetFirstAddedAudioDevice(const SDL_bool iscapture)
|
|
|
void *iter = NULL;
|
|
|
while (SDL_IterateHashTable(current_audio.device_hash, &key, &value, &iter)) {
|
|
|
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
|
|
|
- // bit #0 of devid is set for output devices and unset for capture.
|
|
|
+ // bit #0 of devid is set for playback devices and unset for recording.
|
|
|
// bit #1 of devid is set for physical devices and unset for logical.
|
|
|
- const SDL_bool devid_iscapture = !(devid & (1 << 0));
|
|
|
+ const SDL_bool devid_recording = !(devid & (1 << 0));
|
|
|
const SDL_bool isphysical = (devid & (1 << 1));
|
|
|
- if (isphysical && (devid_iscapture == iscapture) && (devid < highest)) {
|
|
|
+ if (isphysical && (devid_recording == recording) && (devid < highest)) {
|
|
|
highest = devid;
|
|
|
retval = (SDL_AudioDevice *) value;
|
|
|
}
|
|
@@ -837,7 +837,7 @@ static SDL_AudioDevice *GetFirstAddedAudioDevice(const SDL_bool iscapture)
|
|
|
static Uint32 HashAudioDeviceID(const void *key, void *data)
|
|
|
{
|
|
|
// shift right 2, to dump the first two bits, since these are flags
|
|
|
- // (capture vs playback, logical vs physical) and the rest are unique incrementing integers.
|
|
|
+ // (recording vs playback, logical vs physical) and the rest are unique incrementing integers.
|
|
|
return ((Uint32) ((uintptr_t) key)) >> 2;
|
|
|
}
|
|
|
|
|
@@ -964,27 +964,27 @@ int SDL_InitAudio(const char *driver_name)
|
|
|
CompleteAudioEntryPoints();
|
|
|
|
|
|
// Make sure we have a list of devices available at startup...
|
|
|
- SDL_AudioDevice *default_output = NULL;
|
|
|
- SDL_AudioDevice *default_capture = NULL;
|
|
|
- current_audio.impl.DetectDevices(&default_output, &default_capture);
|
|
|
+ SDL_AudioDevice *default_playback = NULL;
|
|
|
+ SDL_AudioDevice *default_recording = NULL;
|
|
|
+ current_audio.impl.DetectDevices(&default_playback, &default_recording);
|
|
|
|
|
|
// If no default was _ever_ specified, just take the first device we see, if any.
|
|
|
- if (!default_output) {
|
|
|
- default_output = GetFirstAddedAudioDevice(/*iscapture=*/SDL_FALSE);
|
|
|
+ if (!default_playback) {
|
|
|
+ default_playback = GetFirstAddedAudioDevice(/*recording=*/SDL_FALSE);
|
|
|
}
|
|
|
|
|
|
- if (!default_capture) {
|
|
|
- default_capture = GetFirstAddedAudioDevice(/*iscapture=*/SDL_TRUE);
|
|
|
+ if (!default_recording) {
|
|
|
+ default_recording = GetFirstAddedAudioDevice(/*recording=*/SDL_TRUE);
|
|
|
}
|
|
|
|
|
|
- if (default_output) {
|
|
|
- current_audio.default_output_device_id = default_output->instance_id;
|
|
|
- RefPhysicalAudioDevice(default_output); // extra ref on default devices.
|
|
|
+ if (default_playback) {
|
|
|
+ current_audio.default_playback_device_id = default_playback->instance_id;
|
|
|
+ RefPhysicalAudioDevice(default_playback); // extra ref on default devices.
|
|
|
}
|
|
|
|
|
|
- if (default_capture) {
|
|
|
- current_audio.default_capture_device_id = default_capture->instance_id;
|
|
|
- RefPhysicalAudioDevice(default_capture); // extra ref on default devices.
|
|
|
+ if (default_recording) {
|
|
|
+ current_audio.default_recording_device_id = default_recording->instance_id;
|
|
|
+ RefPhysicalAudioDevice(default_recording); // extra ref on default devices.
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
@@ -1009,8 +1009,8 @@ void SDL_QuitAudio(void)
|
|
|
current_audio.device_hash = NULL;
|
|
|
SDL_PendingAudioDeviceEvent *pending_events = current_audio.pending_events.next;
|
|
|
current_audio.pending_events.next = NULL;
|
|
|
- SDL_AtomicSet(¤t_audio.output_device_count, 0);
|
|
|
- SDL_AtomicSet(¤t_audio.capture_device_count, 0);
|
|
|
+ SDL_AtomicSet(¤t_audio.playback_device_count, 0);
|
|
|
+ SDL_AtomicSet(¤t_audio.recording_device_count, 0);
|
|
|
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
|
|
|
|
|
SDL_PendingAudioDeviceEvent *pending_next = NULL;
|
|
@@ -1053,17 +1053,17 @@ static void MixFloat32Audio(float *dst, const float *src, const int buffer_size)
|
|
|
}
|
|
|
|
|
|
|
|
|
-// Output device thread. This is split into chunks, so backends that need to control this directly can use the pieces they need without duplicating effort.
|
|
|
+// Playback device thread. This is split into chunks, so backends that need to control this directly can use the pieces they need without duplicating effort.
|
|
|
|
|
|
-void SDL_OutputAudioThreadSetup(SDL_AudioDevice *device)
|
|
|
+void SDL_PlaybackAudioThreadSetup(SDL_AudioDevice *device)
|
|
|
{
|
|
|
- SDL_assert(!device->iscapture);
|
|
|
+ SDL_assert(!device->recording);
|
|
|
current_audio.impl.ThreadInit(device);
|
|
|
}
|
|
|
|
|
|
-SDL_bool SDL_OutputAudioThreadIterate(SDL_AudioDevice *device)
|
|
|
+SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
|
|
{
|
|
|
- SDL_assert(!device->iscapture);
|
|
|
+ SDL_assert(!device->recording);
|
|
|
|
|
|
SDL_LockMutex(device->lock);
|
|
|
|
|
@@ -1171,9 +1171,9 @@ SDL_bool SDL_OutputAudioThreadIterate(SDL_AudioDevice *device)
|
|
|
return SDL_TRUE; // always go on if not shutting down, even if device failed.
|
|
|
}
|
|
|
|
|
|
-void SDL_OutputAudioThreadShutdown(SDL_AudioDevice *device)
|
|
|
+void SDL_PlaybackAudioThreadShutdown(SDL_AudioDevice *device)
|
|
|
{
|
|
|
- SDL_assert(!device->iscapture);
|
|
|
+ SDL_assert(!device->recording);
|
|
|
const int frames = device->buffer_size / SDL_AUDIO_FRAMESIZE(device->spec);
|
|
|
// Wait for the audio to drain if device didn't die.
|
|
|
if (!SDL_AtomicGet(&device->zombie)) {
|
|
@@ -1183,36 +1183,36 @@ void SDL_OutputAudioThreadShutdown(SDL_AudioDevice *device)
|
|
|
SDL_AudioThreadFinalize(device);
|
|
|
}
|
|
|
|
|
|
-static int SDLCALL OutputAudioThread(void *devicep) // thread entry point
|
|
|
+static int SDLCALL PlaybackAudioThread(void *devicep) // thread entry point
|
|
|
{
|
|
|
SDL_AudioDevice *device = (SDL_AudioDevice *)devicep;
|
|
|
SDL_assert(device != NULL);
|
|
|
- SDL_assert(!device->iscapture);
|
|
|
- SDL_OutputAudioThreadSetup(device);
|
|
|
+ SDL_assert(!device->recording);
|
|
|
+ SDL_PlaybackAudioThreadSetup(device);
|
|
|
|
|
|
do {
|
|
|
if (device->WaitDevice(device) < 0) {
|
|
|
SDL_AudioDeviceDisconnected(device); // doh. (but don't break out of the loop, just be a zombie for now!)
|
|
|
}
|
|
|
- } while (SDL_OutputAudioThreadIterate(device));
|
|
|
+ } while (SDL_PlaybackAudioThreadIterate(device));
|
|
|
|
|
|
- SDL_OutputAudioThreadShutdown(device);
|
|
|
+ SDL_PlaybackAudioThreadShutdown(device);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-// Capture device thread. This is split into chunks, so backends that need to control this directly can use the pieces they need without duplicating effort.
|
|
|
+// Recording device thread. This is split into chunks, so backends that need to control this directly can use the pieces they need without duplicating effort.
|
|
|
|
|
|
-void SDL_CaptureAudioThreadSetup(SDL_AudioDevice *device)
|
|
|
+void SDL_RecordingAudioThreadSetup(SDL_AudioDevice *device)
|
|
|
{
|
|
|
- SDL_assert(device->iscapture);
|
|
|
+ SDL_assert(device->recording);
|
|
|
current_audio.impl.ThreadInit(device);
|
|
|
}
|
|
|
|
|
|
-SDL_bool SDL_CaptureAudioThreadIterate(SDL_AudioDevice *device)
|
|
|
+SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
|
|
|
{
|
|
|
- SDL_assert(device->iscapture);
|
|
|
+ SDL_assert(device->recording);
|
|
|
|
|
|
SDL_LockMutex(device->lock);
|
|
|
|
|
@@ -1224,10 +1224,10 @@ SDL_bool SDL_CaptureAudioThreadIterate(SDL_AudioDevice *device)
|
|
|
SDL_bool failed = SDL_FALSE;
|
|
|
|
|
|
if (!device->logical_devices) {
|
|
|
- device->FlushCapture(device); // nothing wants data, dump anything pending.
|
|
|
+ device->FlushRecording(device); // nothing wants data, dump anything pending.
|
|
|
} else {
|
|
|
- // this SHOULD NOT BLOCK, as we are holding a lock right now. Block in WaitCaptureDevice!
|
|
|
- int br = device->CaptureFromDevice(device, device->work_buffer, device->buffer_size);
|
|
|
+ // this SHOULD NOT BLOCK, as we are holding a lock right now. Block in WaitRecordingDevice!
|
|
|
+ int br = device->RecordDevice(device, device->work_buffer, device->buffer_size);
|
|
|
if (br < 0) { // uhoh, device failed for some reason!
|
|
|
failed = SDL_TRUE;
|
|
|
} else if (br > 0) { // queue the new data to each bound stream.
|
|
@@ -1238,7 +1238,7 @@ SDL_bool SDL_CaptureAudioThreadIterate(SDL_AudioDevice *device)
|
|
|
|
|
|
void *output_buffer = device->work_buffer;
|
|
|
|
|
|
- // I don't know why someone would want a postmix on a capture device, but we offer it for API consistency.
|
|
|
+ // I don't know why someone would want a postmix on a recording device, but we offer it for API consistency.
|
|
|
if (logdev->postmix) {
|
|
|
// move to float format.
|
|
|
SDL_AudioSpec outspec;
|
|
@@ -1281,33 +1281,33 @@ SDL_bool SDL_CaptureAudioThreadIterate(SDL_AudioDevice *device)
|
|
|
return SDL_TRUE; // always go on if not shutting down, even if device failed.
|
|
|
}
|
|
|
|
|
|
-void SDL_CaptureAudioThreadShutdown(SDL_AudioDevice *device)
|
|
|
+void SDL_RecordingAudioThreadShutdown(SDL_AudioDevice *device)
|
|
|
{
|
|
|
- SDL_assert(device->iscapture);
|
|
|
- device->FlushCapture(device);
|
|
|
+ SDL_assert(device->recording);
|
|
|
+ device->FlushRecording(device);
|
|
|
current_audio.impl.ThreadDeinit(device);
|
|
|
SDL_AudioThreadFinalize(device);
|
|
|
}
|
|
|
|
|
|
-static int SDLCALL CaptureAudioThread(void *devicep) // thread entry point
|
|
|
+static int SDLCALL RecordingAudioThread(void *devicep) // thread entry point
|
|
|
{
|
|
|
SDL_AudioDevice *device = (SDL_AudioDevice *)devicep;
|
|
|
SDL_assert(device != NULL);
|
|
|
- SDL_assert(device->iscapture);
|
|
|
- SDL_CaptureAudioThreadSetup(device);
|
|
|
+ SDL_assert(device->recording);
|
|
|
+ SDL_RecordingAudioThreadSetup(device);
|
|
|
|
|
|
do {
|
|
|
- if (device->WaitCaptureDevice(device) < 0) {
|
|
|
+ if (device->WaitRecordingDevice(device) < 0) {
|
|
|
SDL_AudioDeviceDisconnected(device); // doh. (but don't break out of the loop, just be a zombie for now!)
|
|
|
}
|
|
|
- } while (SDL_CaptureAudioThreadIterate(device));
|
|
|
+ } while (SDL_RecordingAudioThreadIterate(device));
|
|
|
|
|
|
- SDL_CaptureAudioThreadShutdown(device);
|
|
|
+ SDL_RecordingAudioThreadShutdown(device);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
-static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool iscapture)
|
|
|
+static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool recording)
|
|
|
{
|
|
|
SDL_AudioDeviceID *retval = NULL;
|
|
|
int num_devices = 0;
|
|
@@ -1315,7 +1315,7 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool iscapture)
|
|
|
if (SDL_GetCurrentAudioDriver()) {
|
|
|
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
|
|
{
|
|
|
- num_devices = SDL_AtomicGet(iscapture ? ¤t_audio.capture_device_count : ¤t_audio.output_device_count);
|
|
|
+ num_devices = SDL_AtomicGet(recording ? ¤t_audio.recording_device_count : ¤t_audio.playback_device_count);
|
|
|
retval = (SDL_AudioDeviceID *) SDL_malloc((num_devices + 1) * sizeof (SDL_AudioDeviceID));
|
|
|
if (retval) {
|
|
|
int devs_seen = 0;
|
|
@@ -1324,11 +1324,11 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool iscapture)
|
|
|
void *iter = NULL;
|
|
|
while (SDL_IterateHashTable(current_audio.device_hash, &key, &value, &iter)) {
|
|
|
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
|
|
|
- // bit #0 of devid is set for output devices and unset for capture.
|
|
|
+ // bit #0 of devid is set for playback devices and unset for recording.
|
|
|
// bit #1 of devid is set for physical devices and unset for logical.
|
|
|
- const SDL_bool devid_iscapture = !(devid & (1<<0));
|
|
|
+ const SDL_bool devid_recording = !(devid & (1<<0));
|
|
|
const SDL_bool isphysical = (devid & (1<<1));
|
|
|
- if (isphysical && (devid_iscapture == iscapture)) {
|
|
|
+ if (isphysical && (devid_recording == recording)) {
|
|
|
SDL_assert(devs_seen < num_devices);
|
|
|
retval[devs_seen++] = devid;
|
|
|
}
|
|
@@ -1353,12 +1353,12 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool iscapture)
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
-SDL_AudioDeviceID *SDL_GetAudioOutputDevices(int *count)
|
|
|
+SDL_AudioDeviceID *SDL_GetAudioPlaybackDevices(int *count)
|
|
|
{
|
|
|
return GetAudioDevices(count, SDL_FALSE);
|
|
|
}
|
|
|
|
|
|
-SDL_AudioDeviceID *SDL_GetAudioCaptureDevices(int *count)
|
|
|
+SDL_AudioDeviceID *SDL_GetAudioRecordingDevices(int *count)
|
|
|
{
|
|
|
return GetAudioDevices(count, SDL_TRUE);
|
|
|
}
|
|
@@ -1527,10 +1527,10 @@ static SDL_AudioFormat ParseAudioFormatString(const char *string)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static void PrepareAudioFormat(SDL_bool iscapture, SDL_AudioSpec *spec)
|
|
|
+static void PrepareAudioFormat(SDL_bool recording, SDL_AudioSpec *spec)
|
|
|
{
|
|
|
if (spec->freq == 0) {
|
|
|
- spec->freq = iscapture ? DEFAULT_AUDIO_CAPTURE_FREQUENCY : DEFAULT_AUDIO_OUTPUT_FREQUENCY;
|
|
|
+ spec->freq = recording ? DEFAULT_AUDIO_RECORDING_FREQUENCY : DEFAULT_AUDIO_PLAYBACK_FREQUENCY;
|
|
|
|
|
|
const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY"); // !!! FIXME: should be a hint?
|
|
|
if (env) {
|
|
@@ -1542,7 +1542,7 @@ static void PrepareAudioFormat(SDL_bool iscapture, SDL_AudioSpec *spec)
|
|
|
}
|
|
|
|
|
|
if (spec->channels == 0) {
|
|
|
- spec->channels = iscapture ? DEFAULT_AUDIO_CAPTURE_CHANNELS : DEFAULT_AUDIO_OUTPUT_CHANNELS;;
|
|
|
+ spec->channels = recording ? DEFAULT_AUDIO_RECORDING_CHANNELS : DEFAULT_AUDIO_PLAYBACK_CHANNELS;;
|
|
|
const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
|
|
|
if (env) {
|
|
|
const int val = SDL_atoi(env);
|
|
@@ -1554,7 +1554,7 @@ static void PrepareAudioFormat(SDL_bool iscapture, SDL_AudioSpec *spec)
|
|
|
|
|
|
if (spec->format == 0) {
|
|
|
const SDL_AudioFormat val = ParseAudioFormatString(SDL_getenv("SDL_AUDIO_FORMAT"));
|
|
|
- spec->format = (val != 0) ? val : (iscapture ? DEFAULT_AUDIO_CAPTURE_FORMAT : DEFAULT_AUDIO_OUTPUT_FORMAT);
|
|
|
+ spec->format = (val != 0) ? val : (recording ? DEFAULT_AUDIO_RECORDING_FORMAT : DEFAULT_AUDIO_PLAYBACK_FORMAT);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1568,7 +1568,7 @@ void SDL_UpdatedAudioDeviceFormat(SDL_AudioDevice *device)
|
|
|
|
|
|
char *SDL_GetAudioThreadName(SDL_AudioDevice *device, char *buf, size_t buflen)
|
|
|
{
|
|
|
- (void)SDL_snprintf(buf, buflen, "SDLAudio%c%d", (device->iscapture) ? 'C' : 'P', (int) device->instance_id);
|
|
|
+ (void)SDL_snprintf(buf, buflen, "SDLAudio%c%d", (device->recording) ? 'C' : 'P', (int) device->instance_id);
|
|
|
return buf;
|
|
|
}
|
|
|
|
|
@@ -1591,13 +1591,13 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec
|
|
|
device->WaitDevice = current_audio.impl.WaitDevice;
|
|
|
device->PlayDevice = current_audio.impl.PlayDevice;
|
|
|
device->GetDeviceBuf = current_audio.impl.GetDeviceBuf;
|
|
|
- device->WaitCaptureDevice = current_audio.impl.WaitCaptureDevice;
|
|
|
- device->CaptureFromDevice = current_audio.impl.CaptureFromDevice;
|
|
|
- device->FlushCapture = current_audio.impl.FlushCapture;
|
|
|
+ device->WaitRecordingDevice = current_audio.impl.WaitRecordingDevice;
|
|
|
+ device->RecordDevice = current_audio.impl.RecordDevice;
|
|
|
+ device->FlushRecording = current_audio.impl.FlushRecording;
|
|
|
|
|
|
SDL_AudioSpec spec;
|
|
|
SDL_copyp(&spec, inspec ? inspec : &device->default_spec);
|
|
|
- PrepareAudioFormat(device->iscapture, &spec);
|
|
|
+ PrepareAudioFormat(device->recording, &spec);
|
|
|
|
|
|
/* We allow the device format to change if it's better than the current settings (by various definitions of "better"). This prevents
|
|
|
something low quality, like an old game using S8/8000Hz audio, from ruining a music thing playing at CD quality that tries to open later.
|
|
@@ -1636,7 +1636,7 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec
|
|
|
if (!current_audio.impl.ProvidesOwnCallbackThread) {
|
|
|
char threadname[64];
|
|
|
SDL_GetAudioThreadName(device, threadname, sizeof (threadname));
|
|
|
- device->thread = SDL_CreateThread(device->iscapture ? CaptureAudioThread : OutputAudioThread, threadname, device);
|
|
|
+ device->thread = SDL_CreateThread(device->recording ? RecordingAudioThread : PlaybackAudioThread, threadname, device);
|
|
|
|
|
|
if (!device->thread) {
|
|
|
ClosePhysicalAudioDevice(device);
|
|
@@ -1654,7 +1654,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_OUTPUT) || (devid == SDL_AUDIO_DEVICE_DEFAULT_CAPTURE));
|
|
|
+ SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) || (devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING));
|
|
|
|
|
|
// this will let you use a logical device to make a new logical device on the parent physical device. Could be useful?
|
|
|
SDL_AudioDevice *device = NULL;
|
|
@@ -1682,7 +1682,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
|
|
} else {
|
|
|
RefPhysicalAudioDevice(device); // unref'd on successful SDL_CloseAudioDevice
|
|
|
SDL_AtomicSet(&logdev->paused, 0);
|
|
|
- retval = logdev->instance_id = AssignAudioDeviceInstanceId(device->iscapture, /*islogical=*/SDL_TRUE);
|
|
|
+ retval = logdev->instance_id = AssignAudioDeviceInstanceId(device->recording, /*islogical=*/SDL_TRUE);
|
|
|
logdev->physical_device = device;
|
|
|
logdev->opened_as_default = wants_default;
|
|
|
logdev->next = device->logical_devices;
|
|
@@ -1758,7 +1758,7 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac
|
|
|
logdev->postmix = callback;
|
|
|
logdev->postmix_userdata = userdata;
|
|
|
|
|
|
- if (device->iscapture) {
|
|
|
+ if (device->recording) {
|
|
|
for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) {
|
|
|
// set the proper end of the stream to the device's format.
|
|
|
// SDL_SetAudioStreamFormat does a ton of validation just to memcpy an audiospec.
|
|
@@ -1836,7 +1836,7 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
|
|
|
|
|
|
if (retval == 0) {
|
|
|
// Now that everything is verified, chain everything together.
|
|
|
- const SDL_bool iscapture = device->iscapture;
|
|
|
+ const SDL_bool recording = device->recording;
|
|
|
for (int i = 0; i < num_streams; i++) {
|
|
|
SDL_AudioStream *stream = streams[i];
|
|
|
if (stream) { // shouldn't be NULL, but just in case...
|
|
@@ -1848,7 +1848,7 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
|
|
|
}
|
|
|
logdev->bound_streams = stream;
|
|
|
|
|
|
- if (iscapture) {
|
|
|
+ if (recording) {
|
|
|
SDL_copyp(&stream->src_spec, &device->spec);
|
|
|
if (logdev->postmix) {
|
|
|
stream->src_spec.format = SDL_AUDIO_F32;
|
|
@@ -1982,7 +1982,7 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au
|
|
|
SDL_AtomicSet(&logdev->paused, 1); // start the device paused, to match SDL2.
|
|
|
|
|
|
SDL_assert(device != NULL);
|
|
|
- const SDL_bool iscapture = device->iscapture;
|
|
|
+ const SDL_bool recording = device->recording;
|
|
|
|
|
|
// if the app didn't request a format _at all_, just make a stream that does no conversion; they can query for it later.
|
|
|
SDL_AudioSpec tmpspec;
|
|
@@ -1991,7 +1991,7 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au
|
|
|
spec = &tmpspec;
|
|
|
}
|
|
|
|
|
|
- if (iscapture) {
|
|
|
+ if (recording) {
|
|
|
stream = SDL_CreateAudioStream(&device->spec, spec);
|
|
|
} else {
|
|
|
stream = SDL_CreateAudioStream(spec, &device->spec);
|
|
@@ -2011,7 +2011,7 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au
|
|
|
|
|
|
if (callback) {
|
|
|
int rc;
|
|
|
- if (iscapture) {
|
|
|
+ if (recording) {
|
|
|
rc = SDL_SetAudioStreamPutCallback(stream, callback, userdata);
|
|
|
} else {
|
|
|
rc = SDL_SetAudioStreamGetCallback(stream, callback, userdata);
|
|
@@ -2086,17 +2086,17 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
|
|
|
return; // uhoh.
|
|
|
}
|
|
|
|
|
|
- const SDL_bool iscapture = new_default_device->iscapture;
|
|
|
+ const SDL_bool recording = new_default_device->recording;
|
|
|
|
|
|
// change the official default over right away, so new opens will go to the new device.
|
|
|
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
|
|
- const SDL_AudioDeviceID current_devid = iscapture ? current_audio.default_capture_device_id : current_audio.default_output_device_id;
|
|
|
+ const SDL_AudioDeviceID current_devid = recording ? current_audio.default_recording_device_id : current_audio.default_playback_device_id;
|
|
|
const SDL_bool is_already_default = (new_default_device->instance_id == current_devid);
|
|
|
if (!is_already_default) {
|
|
|
- if (iscapture) {
|
|
|
- current_audio.default_capture_device_id = new_default_device->instance_id;
|
|
|
+ if (recording) {
|
|
|
+ current_audio.default_recording_device_id = new_default_device->instance_id;
|
|
|
} else {
|
|
|
- current_audio.default_output_device_id = new_default_device->instance_id;
|
|
|
+ current_audio.default_playback_device_id = new_default_device->instance_id;
|
|
|
}
|
|
|
}
|
|
|
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
|
@@ -2122,7 +2122,7 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
|
|
|
if (current_default_device) {
|
|
|
// migrate any logical devices that were opened as a default to the new physical device...
|
|
|
|
|
|
- SDL_assert(current_default_device->iscapture == iscapture);
|
|
|
+ SDL_assert(current_default_device->recording == recording);
|
|
|
|
|
|
// See if we have to open the new physical device, and if so, find the best audiospec for it.
|
|
|
SDL_AudioSpec spec;
|
|
@@ -2133,7 +2133,7 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
|
|
|
if (logdev->opened_as_default) {
|
|
|
needs_migration = SDL_TRUE;
|
|
|
for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) {
|
|
|
- const SDL_AudioSpec *streamspec = iscapture ? &stream->dst_spec : &stream->src_spec;
|
|
|
+ const SDL_AudioSpec *streamspec = recording ? &stream->dst_spec : &stream->src_spec;
|
|
|
if (SDL_AUDIO_BITSIZE(streamspec->format) > SDL_AUDIO_BITSIZE(spec.format)) {
|
|
|
spec.format = streamspec->format;
|
|
|
}
|
|
@@ -2350,7 +2350,7 @@ void SDL_UpdateAudio(void)
|
|
|
SDL_zero(event);
|
|
|
event.type = i->type;
|
|
|
event.adevice.which = (Uint32) i->devid;
|
|
|
- event.adevice.iscapture = (i->devid & (1<<0)) ? 0 : 1; // bit #0 of devid is set for output devices and unset for capture.
|
|
|
+ event.adevice.recording = (i->devid & (1<<0)) ? 0 : 1; // bit #0 of devid is set for playback devices and unset for recording.
|
|
|
SDL_PushEvent(&event);
|
|
|
}
|
|
|
SDL_free(i);
|