Commit Graph

836 Commits

Author SHA1 Message Date
Ryan C. Gordon
79cc29ba35 wave: Don't check if format->channels > INT_MAX, it's a Uint16. 2023-07-30 11:56:09 -04:00
Ryan C. Gordon
1bfe97c235 pspaudio: Updated for SDL3 audio API.
However, this still blocks in PlayDevice and leaves WaitDevice as a no-op,
which isn't ideal, since the device lock is held during PlayDevice.

Ideally, this should be fixed.
2023-07-30 11:56:09 -04:00
Ryan C. Gordon
121a2dce15 audio: Make sure device->hidden is NULL after CloseDevice 2023-07-30 11:56:09 -04:00
Ryan C. Gordon
3d6ba0cafd ps2audio: Removed free of buffer that hasn't been allocated yet. 2023-07-30 11:56:08 -04:00
Ryan C. Gordon
6f12f68ec9 ps2audio: SDL3ified the style 2023-07-30 11:56:08 -04:00
Ryan C. Gordon
4993743a02 ps2audio: Renamed _this to device 2023-07-30 11:56:08 -04:00
Ryan C. Gordon
74568cdb2b ps2audio: Updated (but untested) for SDL3 audio API. 2023-07-30 11:56:08 -04:00
Ryan C. Gordon
c83b68ef26 jack: renamed _this to device. 2023-07-30 11:56:07 -04:00
Ryan C. Gordon
3f4f004794 audio: Remove an assertion that no longer makes sense.
One may happen to call SDL_AudioThreadFinalize when thread_alive is not set.
2023-07-30 11:56:07 -04:00
Ryan C. Gordon
86243b2589 jack: Use ProvidesOwnCallbackThread.
We were firing a semaphore from the JACK-provided thread to otherwise work
within the standard SDL2 device thread, but there's no need for this in SDL3.
2023-07-30 11:56:07 -04:00
Ryan C. Gordon
18906a32b8 jack: First shot at updating for SDL3 audio API. 2023-07-30 11:56:07 -04:00
Ryan C. Gordon
a2b488359e dsp: Removed debug logging 2023-07-30 11:56:06 -04:00
Ryan C. Gordon
6fd71185cd dsp: Updated for new SDL3 audio API. 2023-07-30 11:56:06 -04:00
Ryan C. Gordon
3482d1215a alsa: Don't ever block in CaptureFromDevice. 2023-07-30 11:56:06 -04:00
Ryan C. Gordon
65d296ef1a audio: Use SDL_powerof2 instead of reinventing it. 2023-07-30 11:56:06 -04:00
Ryan C. Gordon
409b544505 alsa: Updated for new SDL3 audio API 2023-07-30 11:56:06 -04:00
Ryan C. Gordon
0999a090a7 audio: More tweaking of device->thread_alive 2023-07-30 11:56:05 -04:00
Ryan C. Gordon
f94ffd6092 audio: Fixed logic error 2023-07-30 11:56:05 -04:00
Ryan C. Gordon
4deb2970c9 alsa: Renamed _this to device 2023-07-30 11:56:05 -04:00
Ryan C. Gordon
0fb9e4baae audio: Remove no-longer-used SupportsNonPow2Samples 2023-07-30 11:56:05 -04:00
Ryan C. Gordon
c653e57768 coreaudio: rewritten for SDL3 audio redesign! 2023-07-30 11:56:04 -04:00
Ryan C. Gordon
533777eff5 audio: SDL_sysaudio.h comment conversion. 2023-07-30 11:56:04 -04:00
Ryan C. Gordon
8473e522e0 audio: unify device thread naming. 2023-07-30 11:56:04 -04:00
Ryan C. Gordon
258bc9efed audio: PlayDevice now passes the buffer, too, for convenience. 2023-07-30 11:56:04 -04:00
Ryan C. Gordon
e518149d14 audio: Fixed locking in SDL_AudioDeviceDisconnected 2023-07-30 11:56:03 -04:00
Ryan C. Gordon
22afa5735f audio: FreeDeviceHandle should pass the whole device, for convenience. 2023-07-30 11:56:03 -04:00
Ryan C. Gordon
9e3c5f93e0 coreaudio: Change _this to device 2023-07-30 11:56:03 -04:00
Ryan C. Gordon
e969160de0 audio: unset a freed variable to NULL 2023-07-30 11:56:03 -04:00
Ryan C. Gordon
1fc01b0300 audio: Try to definitely have a default device set up. 2023-07-30 11:56:03 -04:00
Ryan C. Gordon
b60a56d368 audio: take first reported device if no default was specified. 2023-07-30 11:56:02 -04:00
Ryan C. Gordon
a8323ebe68 audio: Better handling of ProvidesOwnCallbackThread backends. 2023-07-30 11:56:02 -04:00
Ryan C. Gordon
1dffb72c1d pipewire: Hooked up default device change notifications. 2023-07-30 11:56:02 -04:00
Ryan C. Gordon
a93fcf2444 audio: fixed flushed stream reporting bytes but not being able to get them.
This would happen when you had ~1 frame of audio left in the stream, and
resampling needs would cause this to not be enough to produce audio.

But since we're already flushed, we can just add silence padding to let the
app extract these last bits.
2023-07-30 11:56:02 -04:00
Ryan C. Gordon
ad6c1781fc pulseaudio: Minor cleanups. 2023-07-30 11:56:02 -04:00
Ryan C. Gordon
cfc8a0d17d pipewire: First shot at moving to the new SDL3 audio interfaces.
This needs a little work still, but it mostly works.
2023-07-30 11:56:01 -04:00
Ryan C. Gordon
13202642a3 aaudio: Fixed capitialization, plus some minor cleanups. 2023-07-30 11:56:01 -04:00
Ryan C. Gordon
3e9991b535 audio: Make sure we don't write to a NULL pointer.
(This _probably_ never happens in the current codebase, but just in case.)
2023-07-30 11:56:01 -04:00
Ryan C. Gordon
943351affb pulseaudio: GetDefaultAudioInfo isn't a thing anymore. 2023-07-30 11:56:01 -04:00
Ryan C. Gordon
f48cb716c2 pulseaudio: a couple minor tweaks. 2023-07-30 11:55:59 -04:00
Ryan C. Gordon
dac25fe9eb audio: Seperate audio capture into Wait/Read operations.
Before it would just block in read operations, but separating this out
matches what output devices already do, and also lets us separate out the
unlocked waiting part from the fast part that holds the device lock.
2023-07-30 11:55:59 -04:00
Ryan C. Gordon
3e10c0005d audio: Capture devices should respect logical device pausing. 2023-07-30 11:55:59 -04:00
Ryan C. Gordon
7e700531c5 audio: Allow SDL_OpenAudioDevice to accept a NULL spec.
This means "I don't care what format I get at all" and will just use
the device's current (and/or default) format.

This can be useful, since audio streams cover the differences anyhow.
2023-07-30 11:55:59 -04:00
Ryan C. Gordon
883aee32c5 audio: Let default formats differ for output and capture devices. 2023-07-30 11:55:58 -04:00
Ryan C. Gordon
62cf24eeb9 pulseaudio: Listen for server events in addition to sources and sinks.
This gets us default device change notifications more efficiently, presumably.
2023-07-30 11:55:58 -04:00
Ryan C. Gordon
924f370bd7 pulseaudio: Fix deadlock in HotplugThread.
If we wait for context subscription to finish, we might miss the signal
telling us to terminate the thread...this can happen if an app initializes
the audio subsystem and then quits immediately.

So just go right into the main loop of the thread; the subscription will
finish when it finishes and then events will flow.
2023-07-30 11:55:58 -04:00
Ryan C. Gordon
2be5f726d4 audio: Removed debug logging. 2023-07-30 11:55:57 -04:00
Ryan C. Gordon
0e5a1d4f29 pulseaudio: Removed debug logging. 2023-07-30 11:55:57 -04:00
Ryan C. Gordon
fe1daf6fb5 audio: Mark disconnected default devices as "zombies".
Zombie devices just sit there doing nothing until a new default device
is chosen, and then they migrate all their logical devices before being
destroyed.

This lets the system deal with the likely outcome of a USB headset being
the default audio device, and when its cable is yanked out, the backend
will likely announce this _before_ it chooses a new default (or, perhaps,
the only device in the system got yanked out and there _isn't_ a new
default to be had until the user plugs the cable back in).

This lets the audio device hold on without disturbing the app until it can
seamlessly migrate audio, and it also means the backend does not have to
be careful in how it announces device events, since SDL will manage the
time between a device loss and its replacement.

Note that this _only_ applies to things opened as the default device
(SDL_AUDIO_DEVICE_DEFAULT_OUTPUT, etc). If those USB headphones are the
default, and one SDL_OpenAudioDevice() call asked for them specifically and
the other just said "give me the system default," the explicitly requested
open will get a device-lost notification immediately. The other open will
live on as a zombie until it can migrate to the new default.

This drops the complexity of the PulseAudio hotplug thread dramatically,
back to what it was previously, since it no longer needs to fight against
Pulse's asychronous nature, but just report device disconnects and new
default choices as they arrive.

loopwave has been updated to not check for device removals anymore; since
it opens the default device, this is now managed for it; it no longer
needs to close and reopen a device, and as far as it knows, the device
is never lost in the first place.
2023-07-30 11:55:56 -04:00
Ryan C. Gordon
cdd2ba81de audio: Fixed adding new physical devices to a double-linked list.
(Forgot to hook up existing node's `prev` field when adding the new device
to the head of the list. Doh.)
2023-07-30 11:55:55 -04:00
Ryan C. Gordon
db39cbf208 audio: Allow SDL_GetAudioDeviceFormat() to query the default devices.
Officially removed SDL_GetDefaultAudioInfo(), as its functionality that
isn't obsolete is now offered elsewhere.
2023-07-30 11:55:55 -04:00