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 745

Summary: Samplerate problems go unnoticed because of ALSA API mismatch
Product: SDL Reporter: Tilman Sauerbeck <tilman>
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: 1.2.13Keywords: target-1.2.14
Hardware: x86   
OS: Linux   
Attachments: Patch
addresses snd_pcm_hw_params_get_channels as well as not using dlvsym for ALSA 0.9 functions
check return value correctly

Description Tilman Sauerbeck 2009-05-24 04:46:55 UTC
Created attachment 327 [details]
Patch

The prototype for the current snd_pcm_hw_params_set_rate_near function looks like this:

int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);

According to the ALSA docs, "val" is:
 	val 	approximate target rate / returned approximate set rate 

SDL 1.2.13 however tries to use the old ALSA API, which used to return the actual samplerate from the function so SDL 1.2.13 doesn't work correctly with the current ALSA libraries.

AFAIK, the current ALSA API has been in use for several years now. Please consider updating SDL to use that new API so samplerate problems don't go undetected anymore. I'm attaching a patch to fix this problem.
Comment 1 george pee 2009-07-23 12:51:31 UTC
Created attachment 340 [details]
addresses snd_pcm_hw_params_get_channels as well as not using dlvsym for ALSA 0.9 functions

Part of the previous patch removes the ALSA_PCM_OLD_HW_PARAMS_API & ALSA_PCM_OLD_SW_PARAMS_API, and with that, (using pcm.h instead of pcm_old.h)

static int (*SDL_NAME(snd_pcm_hw_params_get_channels))(const snd_pcm_hw_params_t *params);

needs to be changed to:

static int (*SDL_NAME(snd_pcm_hw_params_get_channels))(const snd_pcm_hw_params_t *params, unsigned int *val);

Attached is a patch with a few more changes.  Getting closer to the using the new ALSA API....
Comment 2 george pee 2009-07-23 14:14:20 UTC
Created attachment 341 [details]
check return value correctly
Comment 3 Ryan C. Gordon 2009-09-13 16:33:21 UTC
Tagging this bug with "target-1.2.14" so we can try to resolve it for SDL 1.2.14.

Please note that we may choose to resolve it as WONTFIX. This tag is largely so we have a comprehensive wishlist of bugs to examine for 1.2.14 (and so we can close bugs that we'll never fix, rather than have them live forever in Bugzilla).

--ryan.
Comment 4 Sam Lantinga 2009-09-21 03:01:37 UTC
Ryan, can you evaluate this patch for 1.2 and 1.3?

Thanks!
Comment 5 Ryan C. Gordon 2009-10-10 00:34:32 UTC
Fixed in svn revision #4991 for the 1.2 branch, and #4992 for the 1.3 branch.

Thanks!

--ryan.