Commit Graph

475 Commits

Author SHA1 Message Date
Sam Lantinga
50ea3b77f1 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.
2021-01-08 10:09:37 -08:00
Ozkan Sezer
265a1cc97a 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*
2021-01-05 15:50:02 +03:00
Ozkan Sezer
ed39f2f3f9 SDL_wasapi_win32.c (WASAPI_PlatformThreadInit): use L instead of TEXT()
because AvSetMmThreadCharacteristicsW specifically accepts WCHAR* input
cf. bug #5435.
2021-01-04 01:23:50 +03:00
Ozkan Sezer
01a2f27679 consistently use TEXT() macro with LoadLibrary() and GetModuleHandle()
cf. bug #5435.
2021-01-04 01:23:50 +03:00
Sam Lantinga
9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Ozkan Sezer
8476df3e31 SDL_mixer.c: remove calls to non-existing m68k asm code. 2020-12-30 23:55:10 +03:00
Sam Lantinga
cb36189692 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.
2020-12-09 07:16:22 -08:00
Alistair Leslie-Hughes
a69c61fbfd 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.
2020-08-14 12:08:58 +10:00
Ozkan Sezer
53b166797d SIZE_MAX need not be defined in limits.h
it can be in limits.h (windows) or stdint.h.
2020-11-11 12:33:55 +03:00
Ryan C. Gordon
1b8dee7caf coreaudio: Remove unnecessary include of CoreServices.h 2020-10-31 11:32:40 -04:00
Ozkan Sezer
a4040293dd os2: misc build fixes 2020-10-25 10:10:02 +03:00
Ozkan Sezer
bfc80d83c2 minor coding style cleanup 2020-10-25 03:55:02 +03:00
Manuel V?gele
554037a6f7 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.
2020-09-26 09:30:08 +02:00
Ozkan Sezer
a90f0400a5 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.
2020-10-15 21:37:30 +03:00
Ozkan Sezer
d27238751f os2: integrate the port into main tree. 2020-10-14 23:01:06 +03:00
Ozkan Sezer
1d9cf23e4c os2: updated copyright dates for 2020. header guard fixes. 2020-10-14 23:01:05 +03:00
Ozkan Sezer
a3d7913c07 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.
2020-10-14 23:01:05 +03:00
Ozkan Sezer
e112b776fc SDL_os2audio.c (OS2_OpenDevice): change {0} initializers to SDL_zero() 2020-10-14 23:01:05 +03:00
Ozkan Sezer
72594e255a SDL_os2audio.c (OS2_OpenDevice): remove assignment to wrong spec member
Correct assignment to 'format' member is done below, already.
2020-10-14 23:01:04 +03:00
Ozkan Sezer
222f026899 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
2020-10-14 23:01:03 +03:00
Ozkan Sezer
aa790837eb 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.
2020-10-14 23:01:02 +03:00
Ozkan Sezer
c218861946 os2: added a 2-byte padding to os2 SDL_PrivateAudioData 2020-10-14 23:01:01 +03:00
Ozkan Sezer
74cfb81dbb 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.
2020-10-14 23:01:00 +03:00
Ryan C. Gordon
003a16980c 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.
2020-10-06 11:07:50 -04:00
Ryan C. Gordon
7ef188a1fb jack: Fixed memory leak on device close. 2020-09-19 14:01:57 -04:00
Sam Lantinga
ff53521bc6 Fixed Bluetooth audio output on Apple TV 2020-06-04 12:26:57 -07:00
Ryan C. Gordon
68777406e5 windows: Fix calls to CoCreateInstance() so last parameter is a LPVOID *. 2020-05-20 16:58:33 -04:00
Ryan C. Gordon
8601996fbc 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.
2020-05-03 22:13:48 -04:00
Sam Lantinga
a990a34ac4 Cleanly switch between audio recording, playback, and both, on iOS 2020-04-14 22:26:02 -07:00
Sam Lantinga
2ae1c0f5d0 Allow Bluetooth headphones for iOS playandrecord mode 2020-04-14 09:52:27 -07:00
Ryan C. Gordon
fba081e489 wasapi: Patched to compile on C89 systems, and use SDL_ceilf instead of ceilf. 2020-04-07 14:51:08 -04:00
Ryan C. Gordon
4c2be47207 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.
2020-04-07 14:37:24 -04:00
Sam Lantinga
b6afbe6317 Added SDL_log.h to SDL_internal.h so logging is available everywhere 2020-04-07 09:38:57 -07:00
Sam Lantinga
9525f9729a 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.
2020-04-05 10:44:51 -07:00
Sam Lantinga
f3e609679d 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.
2020-04-02 12:27:29 -07:00
Ryan C. Gordon
55b4f18e1a 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.
2020-03-29 01:54:00 -04:00
Sam Lantinga
abdc5cbf24 Allow background music to play in the "play and record" case on iOS 2020-03-26 19:30:17 -07:00
Ethan Lee
27889d0261 winrt: Wait for EnumerationCompleted before leaving WASAPI_EnumerateEndpoints 2020-03-03 12:31:41 -05:00
Sam Lantinga
e3b0713e40 Don't call setPreferredOutputNumberOfChannels on iOS, it breaks audio output 2020-02-24 12:07:18 -08:00
Sam Lantinga
2c9871a4a8 Fixed surround sound support on Apple TV 2020-02-24 10:25:57 -08:00
Sam Lantinga
f4e23553d7 Fixed audio not coming out of the phone speakers while recording on iOS 2020-02-14 15:19:34 -08:00
Sam Lantinga
922b3dc3e7 Fixed re-setting the audio session category when closing an audio device 2020-02-14 14:18:12 -08:00
Sam Lantinga
14bf532df3 Fixed opening audio on Android from the Steam Link shell activity 2020-02-13 16:10:52 -08:00
Sam Lantinga
4bb95e8403 Implemented OpenSL-ES audio recording on Android 2020-02-11 16:14:02 -08:00
Sam Lantinga
b1c6e7c244 Fixed compile warning 2020-01-23 00:32:34 -08:00
Ryan C. Gordon
f30ef6ed3d audio: Fixed a '//' style comment. 2020-01-21 17:40:16 -05:00
Ryan C. Gordon
dbe5c14b33 audio: Calculate a legitimate SDL_AudioSpec::silence in SDL_LoadWAV_RW(). 2020-01-21 15:49:37 -05:00
Sam Lantinga
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga
3ce56f621c Fixed error formatting 2020-01-13 08:12:10 -08:00
Sam Lantinga
e3cedf967d Add the destination format to the error when conversion isn't possible 2020-01-11 04:38:13 -08:00
Ryan C. Gordon
3da6a0b20e pulseaudio: don't let FlushCapture get stuck in an infinite loop on shutdown.
Fixes Bugzilla #4645.
2019-12-03 03:53:06 -05:00
Sylvain Becker
60d3965ece Readability: remove redundant return, continue, enum declaration 2019-10-30 15:36:17 +01:00
Sylvain Becker
b458d7a28f Readability: remove redundant cast to the same type 2019-10-30 15:13:55 +01:00
Sylvain Becker
ed469fa586 Fixed bug 4842 - Redundant condition in MS_ADPCM_Decode and IMA_ADPCM_Decode
(Thanks!)
2019-10-23 09:36:41 +02:00
Ryan C. Gordon
aef1ed4ac6 audio: Set (something close to) the correct silence value for U16 audio.
Partially fixes Bugzilla #4805.
2019-09-25 15:40:27 -04:00
Ryan C. Gordon
693755f0b2 coreaudio: Apple doesn't support U16 data, so convert in that case. 2019-09-25 15:07:07 -04:00
Sylvain Becker
70dc8d1648 Android: fix corresponding warnings 2019-08-30 08:55:20 +02:00
Sam Lantinga
455944c870 Fixed whitespace 2019-08-22 16:12:16 -07:00
Sam Lantinga
b521df66c3 [SDL][IOS] Audio fix - applies stream to sound data when resampling or reformatting is required. 2019-08-22 16:09:42 -07:00
Sylvain Becker
05f35c2420 Fix audio conversion U16_to_F32_SSE2 (bug 4186) 2019-08-19 21:23:47 +02:00
Sylvain Becker
1d220401ce Fixed bug 4186 - ARM/NEON audio converters cause strange clicking noises
reverse the order when storing ouput buffer
2019-08-19 20:35:02 +02:00
Sylvain Becker
c0fc94f2de Fixed bug 4186 - ARM/NEON audio converters cause strange clicking noises
reverse the order when storing ouput buffer
2019-08-19 16:57:15 +02:00
Ozkan Sezer
4953e050f5 use SDL_zeroa at more places where the argument is an array. 2019-07-31 05:11:40 +03:00
Ozkan Sezer
7a47c292c0 Fix bug 4746 - introduce SDL_zeroa macro. 2019-07-31 01:22:02 +03:00
Ozkan Sezer
fdc67c3c60 MS_ADPCM_Decode: fix assigning an array to a pointer (lose '&'). 2019-07-31 00:10:00 +03:00
Sam Lantinga
680e7937e0 Fixed bug 4710 - audio/alsa: avoid configuring hardware parameters with only a single period
Anthony Pesch

The previous code first configured the period size using snd_pcm_hw_par-
ams_set_period_size_near. Then, it further narrowed the configuration
space by calling snd_pcm_hw_params_set_buffer_size_near using a buffer
size of 2 times the _requested_ period size in order to try and get a
configuration with only 2 periods. If the configured period size was
larger than the requested size, the second call could inadvertently
narrow the configuration space to contain only a single period.

Rather than fixing the call to snd_pcm_hw_params_set_buffer_size_near
to use a size of 2 times the configured period size, the code has been
changed to use snd_pcm_hw_params_set_periods_min in order to more
clearly explain the intent.
2019-07-07 09:10:56 -07:00
Sam Lantinga
14e8b93e37 Fixed compiler warning 2019-06-18 14:24:24 -07:00
Ryan C. Gordon
90e2dc9891 A few minor changes to placate static analysis. 2019-06-14 18:23:51 -04:00
Ryan C. Gordon
289d109245 audio: Attempt to fix build on ARM versions of Visual Studio. 2019-06-14 16:52:42 -04:00
Ryan C. Gordon
33b235f4c3 audio: Fix ARM NEON audio converter bugs.
(Patch from Sylvain, I'm just applying it.)

Fixes Bugzilla #4186.
2019-06-14 15:52:48 -04:00
Ryan C. Gordon
5c56c88824 audio: patched to compile. 2019-06-14 15:47:32 -04:00
Ethan Lee
5bd9b8b167 Check src alignment for S32_to_F32 conversions 2019-06-14 09:51:22 -04:00
Ryan C. Gordon
2fa33d6f98 wave: Fixed static analysis warning about dead assignment.
(technically, this function never returns an error at this point, but since
it _does_ have an "uhoh, is this corrupt data?" comment that it ignores, we
should probably make sure we handle error cases in the future.  :)  )
2019-06-12 15:43:08 -04:00
Sylvain Becker
cd011bb1e7 SDL_Wave: missing field 'length' initializer 2019-06-12 10:42:02 +02:00
Ryan C. Gordon
254eb67775 windows: Don't let Visual Studio insert an implicit dependency on memset().
Fixes Bugzilla #4662.
2019-06-11 02:08:31 -04:00
Sam Lantinga
d8da33c03f Fixed bug 4662 - SDL failed to build due to error LNK2019: unresolved external symbol _memset referenced in function _IMA_ADPCM_Decode with MSVC on Windows
LinGao

We build SDL with Visual studio 2017 compiler on Windows Server 2016, but it failed to build due to error LNK2019: unresolved external symbol _memset referenced in function _IMA_ADPCM_Decode on latest default branch. And we found that it can be first reproduced on ca7283111ad0 changeset. Could you please help have a look about this issue? Thanks in advance!
2019-06-10 08:49:26 -07:00
Sam Lantinga
762b788f67 Cleanup on bug 3894 - Fuzzing crashes for SDL_LoadWAV
Simon Hug

Attached is a minor cleanup patch. It changes the option name of one hint to something better, puts one or two more checks in, and adds explicit casting where warnings could appear otherwise.

I hope the naming of the hints and their options is acceptable. It would be kind of awkward to change them after they get released with an official SDL version.
2019-06-09 12:46:10 -07:00
Sam Lantinga
a21b5b3018 Fixed build 2019-06-08 19:09:43 -07:00
Sam Lantinga
990e166a3b Fixed bug 3894 - Fuzzing crashes for SDL_LoadWAV
Simon Hug

I had a look at this and made some additions to SDL_wave.c.

The attached patch adds many checks and error messages. For some reason I also added A-law and ?-law decoders. Forgot exactly why... but hey, they're small.

The WAVE format is seriously underspecified (at least by the documents that are publicly available on the internet) and it's a shame Microsoft never put something better out there. The language used in them is so loose at times, it's not surprising the encoders and decoders behave very differently. The Windows Media Player doesn't even support MS ADPCM correctly.

The patch also adds some hints to make the decoder more strict at the cost of compatibility with weird WAVE files.

I still think it needs a bit of cleaning up (Not happy with the MultiplySize function. Don't like the name and other SDL code may want to use something like this too.) and some duplicated code may be folded together. It does work in this state and I have thrown all kinds of WAVE files at it. The AFL files also pass with it and some even play (obviously just noise). Crafty little fuzzer.

Any critique would be welcome. I have a fork of SDL with a audio-loadwav branch over here if someone wants to use the commenting feature of Bitbucket:

https://bitbucket.org/ChliHug/SDL

I also cobbled some Lua scripts together to create WAVE test files:

https://bitbucket.org/ChliHug/gendat
2019-06-08 19:02:42 -07:00
Sam Lantinga
31765242d6 Fixed bug 4294 - Audio: perform more validation on conversion request
janisozaur

There are many cases which are not able to be handled by SDL's audio conversion routines, including too low (negative) rate, too high rate (impossible to allocate).

This patch aims to report such issues early and handle others in a graceful manner. The "INT32_MAX / RESAMPLER_SAMPLES_PER_ZERO_CROSSING" value is the conservative approach in terms of what can _technically_ be supported, but its value is 4'194'303, or just shy of 4.2MHz. I highly doubt any sane person would use such rates, especially in SDL2, so I would like to drive this limit further down, but would need some assistance to do that, as doing so would have to introduce an arbitrary value. Are you OK with such approach? What would a good value be? Wikipedia (https://en.wikipedia.org/wiki/High-resolution_audio) lists 96kHz as the highest sampling rate in use, even if I quadruple it for a good measure, to 384kHz it's still an order of magnitude lower than 4MHz.
2019-06-08 18:22:18 -07:00
Sam Lantinga
3f19a6d5e8 CVE-2019-7578: Fix a buffer overread in InitIMA_ADPCM
If IMA ADPCM format chunk was too short, InitIMA_ADPCM() parsing it
could read past the end of chunk data. This patch fixes it.

CVE-2019-7578
https://bugzilla.libsdl.org/show_bug.cgi?id=4494

Signed-off-by: Petr P?sa? <ppisar@redhat.com>
2019-06-08 18:07:58 -07:00
Sam Lantinga
8a37848de9 Fixed bug 4605 - WASAPI_WaitDevice hang
Matt Brocklehurst

We've noticed that if you are playing audio on Windows via the WASAPI interface and you unplug and reconnect the device a few times the program hangs.

We've debugged the problem down to

static void
WASAPI_WaitDevice(_THIS)
{

   ... snip ...
 if (WaitForSingleObjectEx(this->hidden->event, INFINITE, FALSE) == WAIT_OBJECT_0) {
   ... snip ...
}

This WaitForSingleObjectEx does not havbe a time out defined, so it hangs there forever.

Our suggested fix we found was to include a time out of say 200mSec

We have done quite a bit of testing with this fix in place on various hardware configurations and it seems to have resolved the issue.
2019-06-08 13:41:46 -07:00
Sam Lantinga
15bae953b1 Fixed bug 4642 - Rework SDL_netbsdaudio to improve performance
Nia Alarie

The NetBSD audio driver has a few problems. Lots of obsolete code, and extremely bad performance and stuttering.

I have a patch in NetBSD's package system to improve it. This is my attempt to upstream it.

The changes include:

* Removing references to defines which are never used.
* Using the correct structures for playback and recording, previously they were the wrong way around.
* Using the correct types ('struct audio_prinfo' in contrast to 'audio_prinfo')
* Removing the use of non-blocking I/O, as suggested in #3177.
* Removing workarounds for driver bugs on systems that don't exist or use this driver any more.
* Removing all usage of SDL_Delay(1)
* Removing pointless use of AUDIO_INITINFO and tests that expect AUDIO_SETINFO to fail when it can't.

These changes bring its performance in line with the DSP audio driver.
2019-06-08 13:03:36 -07:00
Sam Lantinga
03cf24162f OpenSL ES audio cleanup and added a note with low latency audio discussion 2019-06-08 10:21:38 -07:00
Sam Lantinga
166d15fd75 Fixed surround sound channel setup for Android OpenSL ES audio driver 2019-06-07 15:09:15 -07:00
Sam Lantinga
723d014336 Fixed bug 4171 - SDL_GetQueuedAudioSize is broken with WASAPI
Cameron Gutman

I was trying to use SDL_GetQueuedAudioSize() to ensure my audio latency didn't get too high while streaming data in from the network. If I get more than N frames of audio queued, I know that the network is giving me more data than I can play and I need to drop some to keep latency low.

This doesn't work well on WASAPI out of the box, due to the addition of GetPendingBytes() to the amount of queued data. As a terrible hack, I loop 100 times calling SDL_Delay(10) and SDL_GetQueuedAudioSize() before I ever call SDL_QueueAudio() to get a "baseline" amount that I then subtract from SDL_GetQueuedAudioSize() later. However, because this value isn't actually a constant, this hack can cause SDL_GetQueuedAudioSize() - baselineSize to be < 0. This means I have no accurate way of determining how much data is actually queued in SDL's audio buffer queue.

The SDL_GetQueuedAudioSize() documentation says: "This is the number of bytes that have been queued for playback with SDL_QueueAudio(), but have not yet been sent to the hardware." Yet, SDL_GetQueuedAudioSize() returns > 0 value when SDL_QueueAudio() has never been called.

Based on that documentation, I believe the current behavior contradicts the documented behavior of this function and should be changed in line with Boris's patch.

I understand that exposing the IAudioClient::GetCurrentPadding() value is useful, but a solution there needs to take into account what of that data is silence inserted by SDL and what is actual data queued by the user with SDL_QueueAudio(). Until that happens, I think the best approach is to remove the GetPendingBytes() call until SDL is able to keep track of queued data to make sense of it. This would make SDL_GetQueuedAudioSize() possible to use accurately with WASAPI.
2019-06-04 17:32:15 -07:00
Sam Lantinga
f3e76ea1d0 Use the OpenSL ES audio driver by default on Android, as it has the lowest latency. 2019-05-23 13:47:30 -07:00
Sam Lantinga
02f9667a08 Fixed static and buzzing when trying to use floating point audio on the OpenSL ES audio driver. 2019-05-23 13:47:27 -07:00
Sam Lantinga
abcfe80480 [SDL] iOS fix bug with audio interrupted by a phone call not restoring. 2019-05-14 14:20:54 -07:00
Ryan C. Gordon
2fbfe8b912 coreaudio: Set audio callback thread priority.
Fixes Bugzilla #4155.
2019-03-25 12:59:30 -04:00
Ryan C. Gordon
6a3356ab3f Backed out changeset cec31de4e126
This was meant to migrate CoreAudio onto the same SDL_RunAudio() path that
most other audio drivers are on, but it introduced a bug because it doesn't
deal with dropped audio buffers...and fixing that properly just introduces
latency.

I might revisit this later, perhaps by reworking SDL_RunAudio to allow for
this sort of API better, or redesigning the whole subsystem or something, I
don't know. I'm not super-thrilled that this has to exist outside of the usual
codepaths, though.

Fixes Bugzilla #4481.
2019-03-25 12:24:38 -04:00
Sam Lantinga
35255342cd Fixed bug 4525 - Fix crash in ALSA_HotplugThread caused by bad return value check
Anthony Pesch

Fix snd_device_name_hint return value check

According to the ALSA documentation, snd_device_name_hint returns 0 on
success, otherwise a negative error code. The code previously only
considered -1 to be an error, which let other error codes through
resulting in a segfault when hints (which was NULL) was dereferenced
2019-03-16 18:48:21 -07:00
Sylvain Becker
03cbac4040 Android/openslES: fix warnings, comment out un-used interface 2019-02-05 15:14:15 +01:00
Sylvain Becker
614c8aea20 Android/openslES: set number of buffers of DATALOCATOR to internal NUM_BUFFER
If we increase NUM_BUFFER, Enqueue won't fail with SL_RESULT_BUFFER_INSUFFICIENT
2019-02-05 15:09:41 +01:00
Sylvain Becker
bf823bf2dc Android/openslES: prevent to run out of buffers if Enqueue() fails. 2019-02-05 15:05:32 +01:00
Alon Zakai
3b4e369365 Emscripten: No need for Runtime. for dynCalls 2019-01-29 12:21:22 +00:00
Alon Zakai
53ead95e1d Emscripten: Avoid SDL2 in JS global scope
After this fix, closure works with the LLVM wasm backend on SDL2.
2019-01-29 12:19:36 +00:00
Sylvain Becker
1b24b2eca5 Android/openslES: fix Pause/ResumeDevices when openslES is not used 2019-01-14 22:56:57 +01:00
Sylvain Becker
647b1f6a6d Android/openslES: check for non NULL variable, some intialization.
use the previous naming
2019-01-14 14:36:13 +01:00
Sylvain Becker
7b1cc441dd Android/openslES: start playing, after creating ressources 2019-01-14 14:31:06 +01:00