Commit d097a3fa authored by Ryan C. Gordon's avatar Ryan C. Gordon

Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402347
parent 554147b6
...@@ -57,7 +57,7 @@ static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s, ...@@ -57,7 +57,7 @@ static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s,
static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer, static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer,
int count); 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 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); static const char *(*SDL_NAME(arts_error_text)) (int errorcode);
#define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) } #define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
...@@ -72,7 +72,10 @@ SDL_ARTS_SYM(arts_init), ...@@ -72,7 +72,10 @@ SDL_ARTS_SYM(arts_init),
SDL_ARTS_SYM(arts_stream_set), SDL_ARTS_SYM(arts_stream_set),
SDL_ARTS_SYM(arts_stream_get), SDL_ARTS_SYM(arts_stream_get),
SDL_ARTS_SYM(arts_write), 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 #undef SDL_ARTS_SYM
static void static void
...@@ -259,11 +262,21 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -259,11 +262,21 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
SDL_NAME(arts_error_text) (rc)); SDL_NAME(arts_error_text) (rc));
return 0; 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, this->hidden->stream = SDL_NAME(arts_play_stream) (this->spec.freq,
bits, bits,
this->spec.channels, this->spec.channels,
"SDL"); "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 */ /* Calculate the final parameters for this audio specification */
SDL_CalculateAudioSpec(&this->spec); SDL_CalculateAudioSpec(&this->spec);
...@@ -326,10 +339,13 @@ ARTS_Init(SDL_AudioDriverImpl * impl) ...@@ -326,10 +339,13 @@ ARTS_Init(SDL_AudioDriverImpl * impl)
} }
/* Play a stream so aRts doesn't crash */ /* Play a stream so aRts doesn't crash */
arts_stream_t stream; if ( SDL_NAME(arts_suspended)() ) {
stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL"); arts_stream_t stream;
SDL_NAME(arts_write) (stream, "", 0); stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL");
SDL_NAME(arts_close_stream) (stream); SDL_NAME(arts_write) (stream, "", 0);
SDL_NAME(arts_close_stream) (stream);
}
SDL_NAME(arts_free) (); SDL_NAME(arts_free) ();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment