Fri, 07 Oct 2016 14:42:24 -0400audio: better way to calculate buffer drain wait times.
Ryan C. Gordon <icculus@icculus.org> [Fri, 07 Oct 2016 14:42:24 -0400] rev 10472
audio: better way to calculate buffer drain wait times.

Fri, 07 Oct 2016 14:35:25 -0400audio: threading and device hang improvements.
Ryan C. Gordon <icculus@icculus.org> [Fri, 07 Oct 2016 14:35:25 -0400] rev 10471
audio: threading and device hang improvements.

This tries to make SDL robust against device drivers that have hung up,
apps don't freeze in catastrophic (but not necessarily uncommon) conditions.

Now we detach the audio thread and let it clean up and don't care if it
never actually runs to completion.

Fri, 07 Oct 2016 11:18:55 -0700Some systems include both "default:" and "hw:" for the same usb device
Sam Lantinga <slouken@libsdl.org> [Fri, 07 Oct 2016 11:18:55 -0700] rev 10470
Some systems include both "default:" and "hw:" for the same usb device

Thu, 06 Oct 2016 06:08:16 -0700fix for finding ALSA hotplug devices on Steam Link
Sam Lantinga <slouken@libsdl.org> [Thu, 06 Oct 2016 06:08:16 -0700] rev 10469
fix for finding ALSA hotplug devices on Steam Link

James Zipperer

The device names show up as "default:", not "hw:"

Wed, 05 Oct 2016 00:12:16 -0700Backed out a very unsafe change that was trying to prevent audio hang at quit.
Sam Lantinga <slouken@libsdl.org> [Wed, 05 Oct 2016 00:12:16 -0700] rev 10468
Backed out a very unsafe change that was trying to prevent audio hang at quit.

Ryan and I have ideas on a better way to handle this.

Tue, 04 Oct 2016 06:48:07 -0700ensure SDL_AUDIODEVICEREMOVED gets sent when hotplug removes a device
Sam Lantinga <slouken@libsdl.org> [Tue, 04 Oct 2016 06:48:07 -0700] rev 10467
ensure SDL_AUDIODEVICEREMOVED gets sent when hotplug removes a device

James Zipperer

The problem I was seeing was that the the ALSA hotplug thread would call SDL_RemoveAudioDevice, but my application code was not seeing an SDL_AUDIODEVICEREMOVED event to go along with it. To fix it, I added some code into SDL_RemoveAudioDevice to call SDL_OpenedAudioDeviceDisconnected on the corresponding open audio device. There didn't appear to be a way to cross reference the handle that SDL_RemoveAudioDevice gets and the SDL_AudioDevice pointer that SDL_OpenedAudioDeviceDisconnected needs, so I ended up adding a void *handle field to struct SDL_AudioDevice so that I could do the cross reference.

Is there some other way beside adding a void *handle field to the struct to get the proper information for SDL_OpenedAudioDeviceDisconnected?

Tue, 04 Oct 2016 06:46:46 -0700fix deadlock on close device
Sam Lantinga <slouken@libsdl.org> [Tue, 04 Oct 2016 06:46:46 -0700] rev 10466
fix deadlock on close device

James Zipperer

snd_pcm_drain doesn't always drain when you unplug a usb device. Use snd_pcm_drop instead

Tue, 04 Oct 2016 06:45:28 -0700fix audio deadlock
Sam Lantinga <slouken@libsdl.org> [Tue, 04 Oct 2016 06:45:28 -0700] rev 10465
fix audio deadlock

James Zipperer

Close the audio device before waiting for the audio thread to complete, which fixes a situation where the audio thread never completes

Add an additional check in the audio thread to see if the device is enabled and bail out if the device is no longer enabled

Tue, 04 Oct 2016 04:08:02 -0700Modified the custom cursor test to be able to load BMP files as cursors
Sam Lantinga <slouken@libsdl.org> [Tue, 04 Oct 2016 04:08:02 -0700] rev 10464
Modified the custom cursor test to be able to load BMP files as cursors

Tue, 04 Oct 2016 03:50:28 -0700Fixed bug 3021 - HapticOpenFromJoystick() problems
Sam Lantinga <slouken@libsdl.org> [Tue, 04 Oct 2016 03:50:28 -0700] rev 10463
Fixed bug 3021 - HapticOpenFromJoystick() problems

Joe Thompson

With Direct Input device (MOMO Steering Wheel w/FF)
with SDL 2.0.3,
SDL_HapticOpenFromJoystick() would fail. (Can't set exclusive mode)
Now with 2.0.4 rc1,
SDL_HapticOpenFromJoystick() succeeds but the the returned SDL_Haptic* cannot be used. Calls to SDL_HapticNewEffect() fail with "Haptic error Unable to create effect"

If SDL_HapticOpen() is used instead of HapticOpenFromJoystick(), the device is usable. Calls to HapticNewEffect() succeed with the exact same parameters as the previous failing call.

I have attached a proposed patch for this issue.

When using SDL_HapticOpenFromJoystick(), the original code did not (re)enumerate the axes. This returned a new haptic device with 0 axes. Later, when a new effect is created, SDL_SYS_SetDirection() would set the flags to include DIEFF_SPHERICAL, regardless of what the caller actually set. (see Line 566 in SDL_dinputhaptic.c). This would cause the SDL_HapticNewEffect() to fail (or interpret the coordinates incorreclty.)

The patch moves the call to IDirectInputDevice8_EnumObjects() outside of the if() block so that the axes are (re)enumerated for the new haptic device.

Note: For steering wheels it is common for the joystick to have multiple axes (ie steering, throttle, brake), but the haptic portion of the joystick usually only applies to steering.