We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3632 - Audio callback change in recent changeset causes call to NULL
Summary: Audio callback change in recent changeset causes call to NULL
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: audio (show other bugs)
Version: HG 2.0
Hardware: All Windows (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-18 06:22 UTC by Simon Hug
Modified: 2017-05-18 19:33 UTC (History)
0 users

See Also:


Attachments
Fixes the userdata pointer in SDL_CaptureAudio which should not be NULL when the queue callbacks are used. (518 bytes, patch)
2017-05-12 01:05 UTC, Simon Hug
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Hug 2017-04-18 06:22:27 UTC
Changeset 3ff1b72962c3 [1] changed which member of SDL_AudioDevice is used for the address of the callback function in SDL_RunAudio [2]. However, open_audio_device still assigns the queue functions (and userdata) to the old member [3]. If the application doesn't provide a callback, SDL will call NULL when the device is unpaused.

I'm guessing open_audio_device should set the queue functions and userdata to callbackspec.callback instead of spec.callback? Or both? There seem to be more functions that rely on the old member.

[1] https://hg.libsdl.org/SDL/rev/3ff1b72962c3
[2] https://hg.libsdl.org/SDL/file/3ff1b72962c3/src/audio/SDL_audio.c#l640
[3] https://hg.libsdl.org/SDL/file/3ff1b72962c3/src/audio/SDL_audio.c#l1347
Comment 1 Simon Hug 2017-04-19 07:09:49 UTC
This issue was partially addressed with changeset 602806fdeba6, though SDL calls NULL in another place now. The function SDL_CaptureAudio still expects the callback and userdata in the old spec.callback and spec.userdata members [1].

I'm guessing this also breaks functions SDL_QueueAudio, SDL_DequeueAudio, and SDL_GetQueuedAudioSize because they check for the queue callback functions in spec.callback.

[1] https://hg.libsdl.org/SDL/file/602806fdeba6/src/audio/SDL_audio.c#l735
Comment 2 Simon Hug 2017-04-21 16:30:09 UTC
The queue functions were fixed with changeset b14856808a3a. SDL_CaptureAudio still calls NULL.
Comment 3 Ryan C. Gordon 2017-04-26 05:44:15 UTC
This last NULL pointer is fixed in https://hg.libsdl.org/SDL/rev/0992354a77aa, tbanks!

--ryan.
Comment 4 Simon Hug 2017-04-26 12:04:39 UTC
Not just yet. The userdata in SDL_CaptureAudio [1] also needs to come from callbackspec or it's going to be NULL. The queue functions object to that with a visit to the zero page.

[1] https://hg.libsdl.org/SDL/file/0992354a77aa/src/audio/SDL_audio.c#l735
Comment 5 Simon Hug 2017-05-12 01:05:06 UTC
Created attachment 2731 [details]
Fixes the userdata pointer in SDL_CaptureAudio which should not be NULL when the queue callbacks are used.

I've read that a release of SDL 2.0.6 might be close. Would be a shame if it shipped with the queued audio capture broken. Attached is a patch that fixes the issue I'm still experiencing.
Comment 6 Ryan C. Gordon 2017-05-18 19:33:57 UTC
(In reply to Simon Hug from comment #5)
> Created attachment 2731 [details]
> Fixes the userdata pointer in SDL_CaptureAudio which should not be NULL when
> the queue callbacks are used.

This patch is now https://hg.libsdl.org/SDL/rev/c923c6eac264, thanks!

--ryan.