changeset 2272:25a87553a59d

Minor PulseAudio fixes: corrected OpenDevice return code, human-readable error messages if connction to daemon fails.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 20 Aug 2007 02:08:37 +0000
parents 60b4c52a7906
children a25bc0f79557
files src/audio/pulseaudio/SDL_pulseaudio.c
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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) */