src/audio


Log

Author Commit Date CI Message
Ozkan Sezer 58884e4c 2021-05-04T00:23:40 SDL_audiocvt.c: fixed MSVC double->float conversion warnings.
Sylvain 8ac0fb52 2021-04-29T09:29:02 OpenSLES: CloseDevice() is called at higher level, if OpenDevice() fails - explicit initialization of static variables
Sylvain fcbf19b7 2021-04-28T21:04:47 AAudio: make sure stream is not null to prevent crash in RequestStop (see #3710)
Sylvain f8695185 2021-04-27T11:07:51 Audio: normalize conversion Stereo to 5.1, Quad to 7.1, 5.1 to 7.1 (bug #4104)
Sylvain 21349901 2021-04-27T10:57:48 Audio: convert 5.1 to 7.1, use right-surround for r-front and r-back (see #4104)
Ivan Epifanov 058bbe02 2021-04-24T10:17:03 Set volume on device open
Sylvain f1fab24e 2021-04-15T21:00:00 AAudio: add bootstrap in SDL_audio.c
Sylvain 04b2f5f6 2021-04-15T20:54:58 Android: add AAudio back-end, with playback and capture (see #3710) https://developer.android.com/ndk/guides/audio/aaudio/aaudio
Sylvain 4118fe62 2021-04-15T20:52:43 Android: OpenSLES, explicitly initialise the global variable 'bqPlayerPlay', it may be read even if OpenSLES back-end hasn't been intialized
Ryan C. Gordon 0f4aba7b 2021-04-06T18:34:53 audio: Fixed assertion failure if trying to use dummy backend.
Ryan C. Gordon 64853b73 2021-04-06T18:34:17 audio: Changed a disk and dummy backends to use _this instead of this.
Ethan Lee 9d294f1f 2021-03-27T00:53:10 audio: Allow AudioStreamGet to return 0 in RunAudio. While we should normally expect _something_ from the stream based on the AudioStreamAvailable check, it's possible for a device change to flush the stream at an inconvenient time, causing this function to return 0. Thing is, this is harmless. Either data will be NULL and the result won't matter anyway, or the data buffer will be zeroed out and the output will just be silence for the brief moment that the device change is occurring. Both scenarios work themselves out, and testing on Windows shows that this behavior is safe.
Ethan Lee 9b7babf9 2021-03-27T00:47:54 wasapi: Remove assert added by 67e8522d
Frank Praznik 5f9effaa 2021-03-28T17:45:41 audio: pipewire: Block while waiting on stream state info Initializing streams, particularly capture streams, can take many milliseconds, which is a bit much for a busy wait. Use a blocking wait instead.
Frank Praznik 8deb4063 2021-03-28T17:22:59 audio: pipewire: Avoid redundant locking The pw_thread_loop already locks and unlocks the thread mutex at the start and end of each loop iteration, so these locks are unnecessary.
Frank Praznik 5bb2bbd4 2021-03-28T17:17:00 audio: pipewire: Don't use uninitialized variables in callbacks Some of the SDL_AudioDevice struct members aren't initialized until after returning from the OpenDevice function. Since Pipewire uses it's own processing threads, the callbacks can be entered before all members of SDL_AudioDevice are initialized, such as work_buffer, callbackspec and the processing stream, which creates a race condition. Don't use these members when in the paused state to avoid potentially using uninitialized values and memory.
Ryan C. Gordon e7e519a4 2021-03-17T13:04:05 dsp: Refuse to initialize if there aren't any Open Sound System devices. This prevents the dsp target from stealing the audio subsystem but not being able to produce sound, so other audio targets further down the list can make an attempt instead. Thanks to Frank Praznik who did a lot of the research on this problem!
Ryan C. Gordon b98b5adc 2021-03-15T10:21:36 wasapi: Don't use the system's resampler.
nia a5f3ea14 2021-03-10T09:36:46 netbsdaudio: Handle ioctls failing A user reported that the mpv video player hangs after attempting to set an unsupported number of channels with the SDL audio output, because it thinks it's successfully opened the device. This makes the failure graceful.
Frank Praznik 4fbd60b8 2021-03-09T12:22:48 audio: pipewire: Remove the nickname portion of sink/source names Removes the node nickname from sink/source nodes as it doesn't provide any useful information and names now match those used in Pulseaudio, so any stored configuration data will be compatible between the two audio backends.
Ivan Epifanov a4ddb175 2021-03-08T19:28:58 Formatting
Ivan Epifanov 7d89f09f 2020-12-18T14:28:09 ISO C90 fixes
Ivan Epifanov e7edb06e 2020-12-04T00:06:15 Audio fix
Ivan Epifanov 2d64e37e 2020-11-02T18:09:43 Initial rebase of xerpi's port
Cameron Cawley 391bb80b 2021-03-05T16:53:06 Replace duplicate functions and lstrlen/lstrcat with SDL string functions
Ethan Lee 67e8522d 2021-02-27T17:37:25 Add SDL_GetAudioDeviceSpec. This API is supported by pipewire, pulseaudio, coreaudio, wasapi, and disk.
Ozkan Sezer ac8a3fda 2021-03-03T20:33:20 fix prepare_audiospec() possibly missing a bad SDL_AUDIO_CHANNELS env.
Frank Praznik 4de0c74a 2021-03-02T10:02:59 audio: pipewire: Add the application name to the stream properties
Frank Praznik 9ed01da7 2021-03-02T09:47:47 audio: pipewire: Constify and clarify period size calculations Constify the min/max period variables, use a #define for the base clock rate used in the calculations and note that changing the upper limit can have dire side effects as it's a hard limit in Pipewire.
Frank Praznik d7ca855c 2021-03-02T09:33:11 audio: pipewire: Add missing static qualifiers to globals
Oschowa 84c44e01 2021-03-01T12:39:52 audio: pipewire: fix uninitialized variable warnings
Frank Praznik 7001b531 2021-02-27T12:53:08 audio: pipewire: Add vim format lines to files and fix indentation Increase indentation spacing from 2 to 4 to comply with style standards.
Frank Praznik 2fcba50e 2021-02-27T12:08:15 audio: pipewire: Code and comment cleanups Replace "magic numbers" with #defines, explain the requirements when using the userdata pointer in the node_object struct and a few other minor code and comment cleanups.
Frank Praznik 4eadd147 2021-02-25T14:00:23 audio: pipewire: Fix outdated comment
Frank Praznik cd56f1b3 2021-02-24T14:36:58 audio: pipewire: Use "rear" designation for rear channels Use the 'R' (rear) prefixed designations for the rear audio channels instead of 'S' (surround). Surround designated channels are only used in the 8 channel configuration.
Frank Praznik adc0a931 2021-02-24T14:08:08 audio: Move Pipewire bootstrap after Jack Move the Pipewire audio driver below others in the list so it won't be mistakenly initialized when it's not the system mixer.
Frank Praznik 21adec93 2021-02-24T12:02:54 audio: pipewire: Make enumeration structure and function names more descriptive Rename the add/remove/clear list functions and rename connected_device to io_node, as a sink/source node isn't necessarily a device.
Frank Praznik a07f5434 2021-02-21T13:24:20 audio: pipewire: Report default devices first Further refactor the device enumeration code to retrieve the default sink/source node IDs from the metadata node. Use the retrieved IDs to sort the device list so that the default devices are at the beginning and thus are the first reported to SDL.
Frank Praznik 9afd7570 2021-02-20T13:33:12 audio: pipewire: Always buffer source audio The latency of source nodes can change depending on the overall latency of the processing graph. Incoming audio must therefore always be buffered to ensure uninterrupted delivery. The SDL_AudioStream path was removed in the input callback as the only thing it was used for was buffering audio outside of Pipewire's min/max period sizes, and that case is now handled by the omnipresent buffer.
Frank Praznik 106dc009 2021-02-19T17:18:36 audio: pipewire: Pass proper parameter to user audio callback The audio callbacks should pass the callbackspec.userdata parameter to the callback, not spec.userdata Co-authored-by: Oschowa <Oschowa@web.de>
Frank Praznik f3ebbc06 2021-02-19T16:02:20 audio: pipewire: Retrieve the channel count and default sample rate for sinks/sources Extend device enumeration to retrieve the channel count and default sample rate for sink and source nodes. This required a fairly significant rework of the enumeration procedure as multiple callbacks are involved now. Sink/source nodes are tracked in a separate list during the enumeration process so they can be cleaned up if a device is removed before completion. These changes also simplify any future efforts that may be needed to retrieve additional configuration information from the nodes.
Frank Praznik 2f0b99a7 2021-02-13T11:56:05 audio: Add Pipewire playback/capture sink
Oschowa 08547adb 2021-02-20T09:28:03 pulseaudio: Add "zerocopy" playback path
Romain Roffé ef85ed93 2021-02-17T20:53:35 pulseaudio: Initialize fragsize to fix mic recording fragsize wasn't initialized, and it is used for recording. If the value was 0 or -1, pulseaudio configures it itself. But sometimes we can get a random (and large) value that makes pulseaudio give us large sample at a very low frequency. https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/pulse/def.h#L453 https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/v13.0/src/pulsecore/protocol-native.c#L409
Alon Zakai 20be1d63 2020-07-15T09:13:03 emscripten: Automatically resume audio contexts This uses the mechanism added in emscripten-core/emscripten#10843 which was applied to SDL1 and OpenAL. This adds the same for SDL2. This also reverts commit 865eaddffed50dbd13e6564c3f73902472cf74e8 which did something similar, but the new mechanism is more effective.
Jay Petacat f443a6fc 2021-02-11T02:05:02 Fix format string warnings for width-based integers The DJGPP compiler emits many warnings for conflicts between print format specifiers and argument types. To fix the warnings, I added `SDL_PRIx32` macros for use with `Sint32` and `Uint32` types. The macros alias those found in <inttypes.h> or fallback to a reasonable default. As an alternative, print arguments could be cast to plain old integers. I opted slightly for the current solution as it felt more technically correct, despite making the format strings more verbose.
Ozkan Sezer b852590b 2021-01-24T17:02:40 minor clean-up in SDL_os2audio.c
Ozkan Sezer 8f102589 2021-01-23T17:28:10 os2audio: changed backend name from MMOS2 to DART (like SDL-1.2)
Sam Lantinga 50ea3b77 2021-01-08T10:09:37 Fixed bug 5080 - SDL_netbsdaudio: Always use the device's preferred frequency Nia Alarie The NetBSD kernel's audio resampling code is much simpler and lower quality than libsamplerate. Presumably, if SDL always performs I/O on the audio device in its native frequency, we can avoid resampling audio in the kernel and let SDL do it with libsamplerate instead.
Ozkan Sezer 265a1cc9 2021-01-05T15:50:02 use WIN_StringToUTF8W instead of WIN_StringToUTF8 where needed (#2) cf. bug #5435. - SDL_wasapi_win32.c (GetWasapiDeviceName): pwszVal is WCHAR* - windows/SDL_sysfilesystem.c (SDL_GetBasePath, SDL_GetPrefPath) - windows/SDL_sysurl.c (SDL_SYS_OpenURL): wurl is WCHAR* - SDL_windowssensor.c (ConnectSensor): bstr_name is WCHAR* - windows/SDL_systhread.c (SDL_SYS_SetupThread): strw is WCHAR*
Ozkan Sezer ed39f2f3 2021-01-04T01:23:50 SDL_wasapi_win32.c (WASAPI_PlatformThreadInit): use L instead of TEXT() because AvSetMmThreadCharacteristicsW specifically accepts WCHAR* input cf. bug #5435.
Ozkan Sezer 01a2f276 2021-01-04T01:23:50 consistently use TEXT() macro with LoadLibrary() and GetModuleHandle() cf. bug #5435.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Ozkan Sezer 8476df3e 2020-12-30T23:55:10 SDL_mixer.c: remove calls to non-existing m68k asm code.
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Ozkan Sezer 53b16679 2020-11-11T12:33:55 SIZE_MAX need not be defined in limits.h it can be in limits.h (windows) or stdint.h.
Ryan C. Gordon 1b8dee7c 2020-10-31T11:32:40 coreaudio: Remove unnecessary include of CoreServices.h
Ozkan Sezer a4040293 2020-10-25T10:10:02 os2: misc build fixes
Ozkan Sezer bfc80d83 2020-10-25T03:55:02 minor coding style cleanup
Ozkan Sezer a90f0400 2020-10-15T21:37:30 os2: a _lot_ of coding style cleanup, sot that they match the SDL style. also renamed the 'debug' macro to debug_os2: the former was dangerously a common name. the binary (dll) output is precisely the same as before.
Ozkan Sezer d2723875 2020-10-14T23:01:06 os2: integrate the port into main tree.
Ozkan Sezer 1d9cf23e 2020-10-14T23:01:05 os2: updated copyright dates for 2020. header guard fixes.
Ozkan Sezer a3d7913c 2020-10-14T23:01:05 SDL_os2audio.c (OS2_OpenDevice): change spec->samples assignment: Original code assigned MCIMixSetup.ulSamplesPerSec value to it, but it is just the freq... We now change spec->samples only either if it is 0 or we changed the frequency, by picking a default of ~46 ms at desired frequency (code taken from SDL_audio.c:prepare_audiospec()). With this, the crashes I have been experiencing are gone.
Ozkan Sezer e112b776 2020-10-14T23:01:05 SDL_os2audio.c (OS2_OpenDevice): change {0} initializers to SDL_zero()
Ozkan Sezer 72594e25 2020-10-14T23:01:04 SDL_os2audio.c (OS2_OpenDevice): remove assignment to wrong spec member Correct assignment to 'format' member is done below, already.
Ozkan Sezer 222f0268 2020-10-14T23:01:03 os/2: port from SDL2-2.0.4 to SDL2-2.0.5: changes to SDL_os2audio.c, SDL_os2video.c, os2/SDL_systhread.c in order to accomodate SDL2-2.0.5 changes. - audio: WaitDone() is gone, CloseDevice() interface changes. - events / video: DropFile() changes: SDL_DROPBEGIN and SDL_DROPCOMPLETE events, window IDs for drops. - thread: struct SDL_Thread->stacksize
Ozkan Sezer aa790837 2020-10-14T23:01:02 os2: several warning fixes. mostly those "W007: '&array' may not produce intended result" warnings from Watcom, visible only in C++ mode. one or two others here & there.
Ozkan Sezer c2188619 2020-10-14T23:01:01 os2: added a 2-byte padding to os2 SDL_PrivateAudioData
Ozkan Sezer 74cfb81d 2020-10-14T23:01:00 os2: add port files for SDL2-2.0.4 from Andrey Vasilkin only geniconv/iconv.h (was from LGPL libiconv) is replaced with a generic minimal iconv.h based on public knowledge.
Ryan C. Gordon 003a1698 2020-10-06T11:07:50 wav: Make sure the data size is a multiple of blockalign, not an exact match. I _think_ this is a right thing to do; it fixes a .wav file I have here that has blockalign==2 when channels==2 and bitspersample==16, which otherwise would fail.
Manuel V?gele 554037a6 2020-09-26T09:30:08 audio: fix popping sounds caused by signed/unsigned conversion When converting audio from signed to unsigned values of vice-versa the silence value chosen by SDL was the value of the device, not of the stream that the data was being put into. After conversion this would lead to a very high or low value, making the speaker jump to a extreme positon, leading to an audible noise whenever creating, destroying or playing scilence on a device that reqired such conversion.
Ryan C. Gordon 7ef188a1 2020-09-19T14:01:57 jack: Fixed memory leak on device close.
Alistair Leslie-Hughes a69c61fb 2020-08-14T12:08:58 Only assign context and mainloop once we have connected successfully If we fail to connect to the the pa server, we have an assigned context and mainloop that isn't connected. So, when PULSEAUDIO_pa_context_disconnect is called, pa asserts and crashes the application. Assertion 'pa_atomic_load(&(c)->_ref) >= 1' failed at pulse/context.c:1055, function pa_context_disconnect(). Aborting.
Sam Lantinga ff53521b 2020-06-04T12:26:57 Fixed Bluetooth audio output on Apple TV
Ryan C. Gordon 68777406 2020-05-20T16:58:33 windows: Fix calls to CoCreateInstance() so last parameter is a LPVOID *.
Ryan C. Gordon 8601996f 2020-05-03T22:13:48 hints: Allow specifying audio device metadata. This is only supported on PulseAudio. You can set a description when opening your audio device that will show up in pauvcontrol, which lets you set per-stream volume levels. Fixes Bugzilla #4801.
Sam Lantinga a990a34a 2020-04-14T22:26:02 Cleanly switch between audio recording, playback, and both, on iOS
Sam Lantinga 2ae1c0f5 2020-04-14T09:52:27 Allow Bluetooth headphones for iOS playandrecord mode
Ryan C. Gordon fba081e4 2020-04-07T14:51:08 wasapi: Patched to compile on C89 systems, and use SDL_ceilf instead of ceilf.
Ryan C. Gordon 4c2be472 2020-04-07T14:37:24 wasapi: Improve WASAPI audio backend latency (thanks, Anthony!). Anthony Pesch's notes on his patch: "Currently, the WASAPI backend creates a stream in shared mode and sets the device's callback size to be half of the shared stream's total buffer size. This works, but doesn't coordinate will with the actual hardware. The hardware will raise an interrupt after every period which in turn will signal the object being waited on inside of WaitDevice. From my empirical testing, the callback size was often larger than the period size and not a multiple of it, which resulted in poor latency when trying to time an application based on the audio callback. The reason for this looked something like: * The device's callback would be called and and the audio buffer was filled. * WaitDevice would be called. * The hardware would raise an interrupt after one period. * WaitDevice would resume, see that a a full callback had not been played and then wait again. * The hardware would raise an interrupt after another period. * WaitDevice would resume, see that a full callback + some extra amount had been played and then it would again call our callback and this process would repeat. The effect of this is that the pacing between subsequent callbacks is poor - sometimes it's called very quickly, sometimes it's called very late. By matching the callback's size to the stream's period size, the pacing of calls to the user callback is improved substantially. I didn't write an actual test for this, but my use case for this was my Dreamcast emulator (https://redream.io) which uses the audio callback to help drive the emulation speed. Without this change and with the default shared stream buffer (which has a period of ~10ms) I would get frame times that were between ~3-30 milliseconds; after this change I get frame times of ~11-22 milliseconds. Note, this patch also has a change that removes passing a duration to the Initialize call. It seems that the default duration used (when 0 is passed) does typically match up with the duration returned by GetDevicePeriod, however the Initialize docs say: > To set the buffer to the minimum size required by the engine thread, the > client should call Initialize with the hnsBufferDuration parameter set to 0. > Following the Initialize call, the client can get the size of the resulting > buffer by calling IAudioClient::GetBufferSize. This change isn't strictly required, but I made it to hopefully rule out another source of unexpected latency." Fixes Bugzilla #4592.
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Sam Lantinga 9525f972 2020-04-05T10:44:51 Fixed bug 5076 - SDL_netbsdaudio: Add support for 32-bit LPCM Nia Alarie The kernel supports this, make SDL expose it so it can be used.
Sam Lantinga f3e60967 2020-04-02T12:27:29 Fixed setting the "playandrecord" audio hint on Apple TV The Apple TV doesn't have record capability by default, so activating the audio session with AVAudioSessionCategoryPlayAndRecord fails.
Ryan C. Gordon 55b4f18e 2020-03-29T01:54:00 coreaudio: The default SDL audio device now tracks the system output default. So if you go into System Preferences on a MacBook and toggle between a pair of connected bluetooth headphones and built-in internal speakers, SDL will switch the device it is playing sound through, to match this setting, on the fly. Likewise if the default output device is a USB thing and is unplugged; as the default device changes at the system level, SDL will pick this up and carry on with the new default. This is different from our unplug detection for specific devices, as in those cases we want to send the app a disconnect notification, instead of migrating transparently as we now do for default devices. Note that this should also work for capture devices; if the device changes, SDL will start recording from the new default. Fixes Bugzilla #4851.
Sam Lantinga abdc5cbf 2020-03-26T19:30:17 Allow background music to play in the "play and record" case on iOS
Ethan Lee 27889d02 2020-03-03T12:31:41 winrt: Wait for EnumerationCompleted before leaving WASAPI_EnumerateEndpoints
Sam Lantinga e3b0713e 2020-02-24T12:07:18 Don't call setPreferredOutputNumberOfChannels on iOS, it breaks audio output
Sam Lantinga 2c9871a4 2020-02-24T10:25:57 Fixed surround sound support on Apple TV
Sam Lantinga f4e23553 2020-02-14T15:19:34 Fixed audio not coming out of the phone speakers while recording on iOS
Sam Lantinga 922b3dc3 2020-02-14T14:18:12 Fixed re-setting the audio session category when closing an audio device
Sam Lantinga 14bf532d 2020-02-13T16:10:52 Fixed opening audio on Android from the Steam Link shell activity
Sam Lantinga 4bb95e84 2020-02-11T16:14:02 Implemented OpenSL-ES audio recording on Android
Sam Lantinga b1c6e7c2 2020-01-23T00:32:34 Fixed compile warning
Ryan C. Gordon f30ef6ed 2020-01-21T17:40:16 audio: Fixed a '//' style comment.
Ryan C. Gordon dbe5c14b 2020-01-21T15:49:37 audio: Calculate a legitimate SDL_AudioSpec::silence in SDL_LoadWAV_RW().
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 3ce56f62 2020-01-13T08:12:10 Fixed error formatting
Sam Lantinga e3cedf96 2020-01-11T04:38:13 Add the destination format to the error when conversion isn't possible
Ryan C. Gordon 3da6a0b2 2019-12-03T03:53:06 pulseaudio: don't let FlushCapture get stuck in an infinite loop on shutdown. Fixes Bugzilla #4645.
Sylvain Becker 60d3965e 2019-10-30T15:36:17 Readability: remove redundant return, continue, enum declaration