mirror of https://github.com/encounter/SDL.git
arts: backed out audio capture support.
Turns out that libartsc isn't thread-safe, so if we run a capture and playback device at the same time, it often crashes in arts's internal event loop. We could throw mutexes around the read/write calls, but these are meant to block, so one device could cause serious latency and stutter in the other. Since this audio target isn't in high-demand (Ubuntu hasn't offered a libartsc package for years), I'm just backing out the capture support. If someone needs it, they can pull it out of the revision history.
This commit is contained in:
parent
20cd5e44ce
commit
30a9139bc3
|
@ -54,16 +54,12 @@ static void (*SDL_NAME(arts_free)) (void);
|
||||||
static arts_stream_t(*SDL_NAME(arts_play_stream)) (int rate, int bits,
|
static arts_stream_t(*SDL_NAME(arts_play_stream)) (int rate, int bits,
|
||||||
int channels,
|
int channels,
|
||||||
const char *name);
|
const char *name);
|
||||||
static arts_stream_t(*SDL_NAME(arts_record_stream)) (int rate, int bits,
|
|
||||||
int channels,
|
|
||||||
const char *name);
|
|
||||||
static int (*SDL_NAME(arts_stream_set)) (arts_stream_t s,
|
static int (*SDL_NAME(arts_stream_set)) (arts_stream_t s,
|
||||||
arts_parameter_t param, int value);
|
arts_parameter_t param, int value);
|
||||||
static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s,
|
static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s,
|
||||||
arts_parameter_t param);
|
arts_parameter_t param);
|
||||||
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 int (*SDL_NAME(arts_read)) (arts_stream_t s, 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_suspend))(void);
|
static int (*SDL_NAME(arts_suspend))(void);
|
||||||
static int (*SDL_NAME(arts_suspended)) (void);
|
static int (*SDL_NAME(arts_suspended)) (void);
|
||||||
|
@ -79,11 +75,9 @@ static struct
|
||||||
SDL_ARTS_SYM(arts_init),
|
SDL_ARTS_SYM(arts_init),
|
||||||
SDL_ARTS_SYM(arts_free),
|
SDL_ARTS_SYM(arts_free),
|
||||||
SDL_ARTS_SYM(arts_play_stream),
|
SDL_ARTS_SYM(arts_play_stream),
|
||||||
SDL_ARTS_SYM(arts_record_stream),
|
|
||||||
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_read),
|
|
||||||
SDL_ARTS_SYM(arts_close_stream),
|
SDL_ARTS_SYM(arts_close_stream),
|
||||||
SDL_ARTS_SYM(arts_suspend),
|
SDL_ARTS_SYM(arts_suspend),
|
||||||
SDL_ARTS_SYM(arts_suspended),
|
SDL_ARTS_SYM(arts_suspended),
|
||||||
|
@ -205,27 +199,6 @@ ARTS_GetDeviceBuf(_THIS)
|
||||||
return (this->hidden->mixbuf);
|
return (this->hidden->mixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
ARTS_CaptureFromDevice(_THIS, void *buffer, int buflen)
|
|
||||||
{
|
|
||||||
return SDL_NAME(arts_read) (this->hidden->stream, buffer, buflen);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ARTS_FlushCapture(_THIS)
|
|
||||||
{
|
|
||||||
arts_stream_t stream = this->hidden->stream;
|
|
||||||
int remain = SDL_NAME(arts_stream_get)(stream, ARTS_P_BUFFER_SPACE);
|
|
||||||
Uint8 buf[512];
|
|
||||||
while (remain > 0) {
|
|
||||||
const int len = SDL_min(sizeof (buf), remain);
|
|
||||||
const int br = SDL_NAME(arts_read)(stream, buf, len);
|
|
||||||
if (br <= 0) {
|
|
||||||
return; /* oh well. */
|
|
||||||
}
|
|
||||||
remain -= br;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ARTS_CloseDevice(_THIS)
|
ARTS_CloseDevice(_THIS)
|
||||||
|
@ -305,20 +278,19 @@ ARTS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||||
SDL_NAME(arts_error_text) (rc));
|
SDL_NAME(arts_error_text) (rc));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iscapture) {
|
if (!ARTS_Suspend()) {
|
||||||
this->hidden->stream = SDL_NAME(arts_record_stream) (this->spec.freq,
|
ARTS_CloseDevice(this);
|
||||||
bits,
|
return SDL_SetError("ARTS can not open audio device");
|
||||||
this->spec.channels,
|
|
||||||
"SDL");
|
|
||||||
} else {
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 */
|
/* Calculate the final parameters for this audio specification */
|
||||||
SDL_CalculateAudioSpec(&this->spec);
|
SDL_CalculateAudioSpec(&this->spec);
|
||||||
|
|
||||||
|
@ -397,12 +369,7 @@ ARTS_Init(SDL_AudioDriverImpl * impl)
|
||||||
impl->CloseDevice = ARTS_CloseDevice;
|
impl->CloseDevice = ARTS_CloseDevice;
|
||||||
impl->WaitDone = ARTS_WaitDone;
|
impl->WaitDone = ARTS_WaitDone;
|
||||||
impl->Deinitialize = ARTS_Deinitialize;
|
impl->Deinitialize = ARTS_Deinitialize;
|
||||||
impl->CaptureFromDevice = ARTS_CaptureFromDevice;
|
|
||||||
impl->FlushCapture = ARTS_FlushCapture;
|
|
||||||
|
|
||||||
impl->OnlyHasDefaultOutputDevice = 1;
|
impl->OnlyHasDefaultOutputDevice = 1;
|
||||||
impl->OnlyHasDefaultInputDevice = 1;
|
|
||||||
impl->HasCaptureSupport = 1;
|
|
||||||
|
|
||||||
return 1; /* this audio target is available. */
|
return 1; /* this audio target is available. */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue