]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/pulse.c
x264: add options for opengop
[vlc] / modules / audio_output / pulse.c
index adc32d636d2805868c6dc9792a32101e92df8c9c..48d531486dcfad244d246b1dd3c714763b05e92e 100644 (file)
 #include <vlc_cpu.h>
 
 #include <pulse/pulseaudio.h>
-#ifdef HAVE_X11_XLIB_H
-# include <X11/Xlib.h>
+#ifdef X_DISPLAY_MISSING
+# error Xlib required due to PulseAudio bug 799!
 #endif
+#include <vlc_xlib.h>
 
 #include <assert.h>
 
@@ -62,8 +63,6 @@ struct aout_sys_t
     mtime_t start_date;
 };
 
-#define    PULSE_CLIENT_NAME N_("VLC media player")
-
 #if 0
 #define PULSE_DEBUG( ...) \
     msg_Dbg( p_aout, __VA_ARGS__ )
@@ -104,10 +103,8 @@ vlc_module_begin ()
     set_capability( "audio output", 160 )
     set_category( CAT_AUDIO )
     set_subcategory( SUBCAT_AUDIO_AOUT )
-    add_shortcut( "pulseaudio" )
-    add_shortcut( "pa" )
+    add_shortcut( "pulseaudio", "pa" )
     set_callbacks( Open, Close )
-    linked_with_a_crap_library_which_uses_atexit()
 vlc_module_end ()
 
 /*****************************************************************************
@@ -121,11 +118,11 @@ static int Open ( vlc_object_t *p_this )
     const struct pa_buffer_attr *buffer_attr;
     struct pa_buffer_attr a;
     struct pa_channel_map map;
+    char * p_client_name = NULL;
 
-#ifdef HAVE_X11_XLIB_H
-    if( !XInitThreads() )
+    if( !vlc_xlib_init( p_this ) )
         return VLC_EGENERIC;
-#endif
+
     /* Allocate structures */
     p_aout->output.p_sys = p_sys = calloc( 1, sizeof( aout_sys_t ) );
     if( p_sys == NULL )
@@ -211,7 +208,12 @@ static int Open ( vlc_object_t *p_this )
         goto fail;
     }
 
-    if (!(p_sys->context = pa_context_new(pa_threaded_mainloop_get_api(p_sys->mainloop), _( PULSE_CLIENT_NAME )))) {
+    if ((p_client_name = var_InheritString(p_aout, "user-agent")) == NULL) {
+        msg_Err(p_aout, "No user-agent string available.");
+        goto fail;
+    }
+
+    if (!(p_sys->context = pa_context_new(pa_threaded_mainloop_get_api(p_sys->mainloop), p_client_name))) {
         msg_Err(p_aout, "Failed to allocate context");
         goto fail;
     }
@@ -304,6 +306,7 @@ unlock_and_fail:
     if (p_sys->mainloop)
         pa_threaded_mainloop_unlock(p_sys->mainloop);
 fail:
+    free(p_client_name);
     msg_Dbg(p_aout, "Pulse initialization failed");
     uninit(p_aout);
     return VLC_EGENERIC;