Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware …
Browse files Browse the repository at this point in the history
…bug fix.
  • Loading branch information
icculus committed Jun 14, 2007
1 parent 0b94a4c commit 8c96fb2
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/audio/arts/SDL_artsaudio.c
Expand Up @@ -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,
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) }
Expand All @@ -72,7 +72,10 @@ SDL_ARTS_SYM(arts_init),
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
Expand Down Expand Up @@ -259,11 +262,21 @@ ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
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);

Expand Down Expand Up @@ -326,10 +339,13 @@ ARTS_Init(SDL_AudioDriverImpl * impl)
}

/* 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) ();
}

Expand Down

0 comments on commit 8c96fb2

Please sign in to comment.