# HG changeset patch # User Ryan C. Gordon # Date 1187575717 0 # Node ID 25a87553a59d8430991007261adcdebfd91cd5ad # Parent 60b4c52a790607c2b506cb3224a25889b30c3bd0 Minor PulseAudio fixes: corrected OpenDevice return code, human-readable error messages if connction to daemon fails. diff -r 60b4c52a7906 -r 25a87553a59d src/audio/pulseaudio/SDL_pulseaudio.c --- a/src/audio/pulseaudio/SDL_pulseaudio.c Mon Aug 20 01:02:37 2007 +0000 +++ b/src/audio/pulseaudio/SDL_pulseaudio.c Mon Aug 20 02:08:37 2007 +0000 @@ -85,6 +85,7 @@ unsigned channels, 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) } @@ -98,6 +99,7 @@ SDL_PULSEAUDIO_SYM(pa_simple_drain), SDL_PULSEAUDIO_SYM(pa_simple_write), SDL_PULSEAUDIO_SYM(pa_channel_map_init_auto), + SDL_PULSEAUDIO_SYM(pa_strerror), /* *INDENT-ON* */ }; #undef SDL_PULSEAUDIO_SYM @@ -253,10 +255,11 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) { - Uint16 test_format; - pa_sample_spec paspec; - pa_buffer_attr paattr; - pa_channel_map pacmap; + Uint16 test_format = 0; + pa_sample_spec paspec; + pa_buffer_attr paattr; + pa_channel_map pacmap; + int err = 0; /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) @@ -338,12 +341,14 @@ &paspec, /* sample format spec */ &pacmap, /* channel map */ &paattr, /* buffering attributes */ - NULL /* error code */ + &err /* error code */ ); + if ( this->hidden->stream == NULL ) { PULSEAUDIO_CloseDevice(this); - SDL_SetError("Could not connect to PulseAudio"); - return(-1); + SDL_SetError("Could not connect to PulseAudio: %s", + SDL_NAME(pa_strerror(err))); + return 0; } /* Get the parent process id (we're the parent of the audio thread) */