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 - Samplerate problems go unnoticed because of ALSA API mismatch
Summary: Samplerate problems go unnoticed because of ALSA API mismatch
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: audio (show other bugs)
Version: 1.2.13
Hardware: x86 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-1.2.14
Depends on:
Blocks:
 
Reported: 2009-05-24 04:46 UTC by Tilman Sauerbeck
Modified: 2009-10-10 00:34 UTC (History)
1 user (show)

See Also:


Attachments
Patch (3.60 KB, patch)
2009-05-24 04:46 UTC, Tilman Sauerbeck
Details | Diff
addresses snd_pcm_hw_params_get_channels as well as not using dlvsym for ALSA 0.9 functions (5.08 KB, patch)
2009-07-23 12:51 UTC, george pee
Details | Diff
check return value correctly (4.83 KB, patch)
2009-07-23 14:14 UTC, george pee
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.