# HG changeset patch # User Ryan C. Gordon # Date 1181830974 0 # Node ID 85ed90a755fa76425aa855b7b9f3c1a9e8024f24 # Parent 2c835d58faad209a84be017a7f8bda0f994f6375 Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix. diff -r 2c835d58faad -r 85ed90a755fa src/audio/arts/SDL_artsaudio.c --- a/src/audio/arts/SDL_artsaudio.c Thu Jun 14 13:21:29 2007 +0000 +++ b/src/audio/arts/SDL_artsaudio.c Thu Jun 14 14:22:54 2007 +0000 @@ -57,7 +57,7 @@ static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer, int count); static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s); -static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s); +static int (*SDL_NAME(arts_suspended))(void); static const char *(*SDL_NAME(arts_error_text)) (int errorcode); #define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) } @@ -72,7 +72,10 @@ SDL_ARTS_SYM(arts_stream_set), SDL_ARTS_SYM(arts_stream_get), SDL_ARTS_SYM(arts_write), - SDL_ARTS_SYM(arts_close_stream), SDL_ARTS_SYM(arts_error_text),}; + SDL_ARTS_SYM(arts_close_stream), + SDL_ARTS_SYM(arts_suspended), + SDL_ARTS_SYM(arts_error_text), +}; #undef SDL_ARTS_SYM static void @@ -259,11 +262,21 @@ SDL_NAME(arts_error_text) (rc)); return 0; } + + if ( ! SDL_NAME(arts_suspended)() ) { + ARTS_CloseDevice(this); + SDL_SetError("ARTS can not open audio device"); + return 0; + } + this->hidden->stream = SDL_NAME(arts_play_stream) (this->spec.freq, bits, this->spec.channels, "SDL"); + /* Play nothing so we have at least one write (server bug workaround). */ + SDL_NAME(arts_write) (this->hidden->stream, "", 0); + /* Calculate the final parameters for this audio specification */ SDL_CalculateAudioSpec(&this->spec); @@ -326,10 +339,13 @@ } /* Play a stream so aRts doesn't crash */ - arts_stream_t stream; - stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL"); - SDL_NAME(arts_write) (stream, "", 0); - SDL_NAME(arts_close_stream) (stream); + if ( SDL_NAME(arts_suspended)() ) { + arts_stream_t stream; + stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL"); + SDL_NAME(arts_write) (stream, "", 0); + SDL_NAME(arts_close_stream) (stream); + } + SDL_NAME(arts_free) (); }