Commit 8e5b2416 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Minor PulseAudio fixes: corrected OpenDevice return code, human-readable

 error messages if connction to daemon fails.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402634
parent c09d2e0f
...@@ -85,6 +85,7 @@ static pa_channel_map* (*SDL_NAME(pa_channel_map_init_auto))( ...@@ -85,6 +85,7 @@ static pa_channel_map* (*SDL_NAME(pa_channel_map_init_auto))(
unsigned channels, unsigned channels,
pa_channel_map_def_t def pa_channel_map_def_t def
); );
static const char* (*SDL_NAME(pa_strerror))(int error);
#define SDL_PULSEAUDIO_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) } #define SDL_PULSEAUDIO_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
...@@ -98,6 +99,7 @@ static struct { ...@@ -98,6 +99,7 @@ static struct {
SDL_PULSEAUDIO_SYM(pa_simple_drain), SDL_PULSEAUDIO_SYM(pa_simple_drain),
SDL_PULSEAUDIO_SYM(pa_simple_write), SDL_PULSEAUDIO_SYM(pa_simple_write),
SDL_PULSEAUDIO_SYM(pa_channel_map_init_auto), SDL_PULSEAUDIO_SYM(pa_channel_map_init_auto),
SDL_PULSEAUDIO_SYM(pa_strerror),
/* *INDENT-ON* */ /* *INDENT-ON* */
}; };
#undef SDL_PULSEAUDIO_SYM #undef SDL_PULSEAUDIO_SYM
...@@ -253,10 +255,11 @@ static char *get_progname(void) ...@@ -253,10 +255,11 @@ static char *get_progname(void)
static int static int
PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
{ {
Uint16 test_format; Uint16 test_format = 0;
pa_sample_spec paspec; pa_sample_spec paspec;
pa_buffer_attr paattr; pa_buffer_attr paattr;
pa_channel_map pacmap; pa_channel_map pacmap;
int err = 0;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
...@@ -338,12 +341,14 @@ PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) ...@@ -338,12 +341,14 @@ PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
&paspec, /* sample format spec */ &paspec, /* sample format spec */
&pacmap, /* channel map */ &pacmap, /* channel map */
&paattr, /* buffering attributes */ &paattr, /* buffering attributes */
NULL /* error code */ &err /* error code */
); );
if ( this->hidden->stream == NULL ) { if ( this->hidden->stream == NULL ) {
PULSEAUDIO_CloseDevice(this); PULSEAUDIO_CloseDevice(this);
SDL_SetError("Could not connect to PulseAudio"); SDL_SetError("Could not connect to PulseAudio: %s",
return(-1); SDL_NAME(pa_strerror(err)));
return 0;
} }
/* Get the parent process id (we're the parent of the audio thread) */ /* Get the parent process id (we're the parent of the audio thread) */
......
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