[pulseaudio-commits] r1071 - /trunk/src/utils/pabrowse.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Thu Jul 13 10:35:11 PDT 2006


Author: lennart
Date: Thu Jul 13 19:35:10 2006
New Revision: 1071

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1071&root=pulseaudio&view=rev
Log:
* add proper error handling to pabrowse.c
* properly destroy pa_browser object on exit

Modified:
    trunk/src/utils/pabrowse.c

Modified: trunk/src/utils/pabrowse.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/utils/pabrowse.c?rev=1071&root=pulseaudio&r1=1070&r2=1071&view=diff
==============================================================================
--- trunk/src/utils/pabrowse.c (original)
+++ trunk/src/utils/pabrowse.c Thu Jul 13 19:35:10 2006
@@ -107,10 +107,18 @@
     }
 }
 
+static void error_callback(pa_browser *b, const char *s, void *userdata) {
+    pa_mainloop_api*m = userdata;
+    
+    fprintf(stderr, "Failure: %s\n", s);
+    m->quit(m, 1);
+}
+
 int main(int argc, char *argv[]) {
     pa_mainloop *mainloop = NULL;
     pa_browser *browser = NULL;
     int ret = 1, r;
+    const char *s;
 
     if (!(mainloop = pa_mainloop_new()))
         goto finish;
@@ -121,15 +129,22 @@
     pa_signal_new(SIGTERM, exit_signal_callback, NULL);
     signal(SIGPIPE, SIG_IGN);
     
-    if (!(browser = pa_browser_new(pa_mainloop_get_api(mainloop))))
+    if (!(browser = pa_browser_new_full(pa_mainloop_get_api(mainloop), PA_BROWSE_FOR_SERVERS|PA_BROWSE_FOR_SINKS|PA_BROWSE_FOR_SOURCES, &s))) {
+        fprintf(stderr, "pa_browse_new_full(): %s\n", s);
         goto finish;
+    }
 
     pa_browser_set_callback(browser, browser_callback, NULL);
+    pa_browser_set_error_callback(browser, error_callback, pa_mainloop_get_api(mainloop));
     
     ret = 0;
     pa_mainloop_run(mainloop, &ret);
 
 finish:
+
+    if (browser)
+        pa_browser_unref(browser);
+
     if (mainloop) {
         pa_signal_done();
         pa_mainloop_free(mainloop);




More information about the pulseaudio-commits mailing list