99fccde5bc
of trying to dlopen() it. also fix a couple bugs in the artsd output module: when artsd is "suspended", it only means that it it not accessing the soundcard at the moment, not that it will not accept data. fix output latency by setting parameters that actually are settable, instead of trying to set read-only(!) parameters. - allow the default audio output method to be chosen with the SDL_AUDIO_DRIVER environment variable. choices are 'arts', 'esd' and 'audio'. 'audio' selects audio(4) output, and is the default if SDL_AUDIO_DRIVER is not set. ok pvalchev@
55 lines
2.0 KiB
Plaintext
55 lines
2.0 KiB
Plaintext
$OpenBSD: patch-src_audio_SDL_audio_c,v 1.13 2008/03/19 13:33:29 jakemsr Exp $
|
|
--- src/audio/SDL_audio.c.orig Sun Dec 30 20:47:59 2007
|
|
+++ src/audio/SDL_audio.c Mon Feb 18 01:41:22 2008
|
|
@@ -341,6 +341,7 @@ int SDL_AudioInit(const char *driver_name)
|
|
}
|
|
#endif /* SDL_AUDIO_DRIVER_ESD */
|
|
if ( audio == NULL ) {
|
|
+ char *env_driver = getenv("SDL_AUDIO_DRIVER");
|
|
if ( driver_name != NULL ) {
|
|
#if 0 /* This will be replaced with a better driver selection API */
|
|
if ( SDL_strrchr(driver_name, ':') != NULL ) {
|
|
@@ -357,12 +358,16 @@ int SDL_AudioInit(const char *driver_name)
|
|
}
|
|
} else {
|
|
for ( i=0; bootstrap[i]; ++i ) {
|
|
- if ( bootstrap[i]->available() ) {
|
|
- audio = bootstrap[i]->create(idx);
|
|
- if ( audio != NULL ) {
|
|
- break;
|
|
- }
|
|
+ if (env_driver != NULL) {
|
|
+ if (SDL_strcasecmp(bootstrap[i]->name, env_driver) == 0)
|
|
+ audio = bootstrap[i]->create(idx);
|
|
+ } else {
|
|
+ if (bootstrap[i]->available())
|
|
+ audio = bootstrap[i]->create(idx);
|
|
}
|
|
+ if ( audio != NULL ) {
|
|
+ break;
|
|
+ }
|
|
}
|
|
}
|
|
if ( audio == NULL ) {
|
|
@@ -518,8 +523,9 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpe
|
|
|
|
/* See if we need to do any conversion */
|
|
if ( obtained != NULL ) {
|
|
- SDL_memcpy(obtained, &audio->spec, sizeof(audio->spec));
|
|
- } else if ( desired->freq != audio->spec.freq ||
|
|
+ SDL_memcpy(obtained, desired, sizeof(audio->spec));
|
|
+ }
|
|
+ if ( desired->freq != audio->spec.freq ||
|
|
desired->format != audio->spec.format ||
|
|
desired->channels != audio->spec.channels ) {
|
|
/* Build an audio conversion block */
|
|
@@ -532,7 +538,7 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpe
|
|
return(-1);
|
|
}
|
|
if ( audio->convert.needed ) {
|
|
- audio->convert.len = (int) ( ((double) desired->size) /
|
|
+ audio->convert.len = (int) ( ((double) audio->spec.size) /
|
|
audio->convert.len_ratio );
|
|
audio->convert.buf =(Uint8 *)SDL_AllocAudioMem(
|
|
audio->convert.len*audio->convert.len_mult);
|