[vlc-commits] Open a specific PulseAudio source if specified

Rémi Denis-Courmont git at videolan.org
Sat Oct 8 17:29:18 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct  8 18:28:54 2011 +0300| [2cb0954ed88dd21520c894e511b4bfb678de84fb] | committer: Rémi Denis-Courmont

Open a specific PulseAudio source if specified

(VLC can now record desktop audio!)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2cb0954ed88dd21520c894e511b4bfb678de84fb
---

 modules/access/pulse.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/modules/access/pulse.c b/modules/access/pulse.c
index a0760d8..9618e08 100644
--- a/modules/access/pulse.c
+++ b/modules/access/pulse.c
@@ -31,6 +31,10 @@
 #include <pulse/pulseaudio.h>
 #include "../audio_output/vlcpulse.h"
 
+#define HELP_TEXT N_( \
+    "Pass pulse:// to open the default PulseAudio source, " \
+    "or pulse://SOURCE to open a specific source named SOURCE.")
+
 static int Open(vlc_object_t *);
 static void Close(vlc_object_t *);
 
@@ -40,6 +44,8 @@ vlc_module_begin ()
     set_capability ("access_demux", 0)
     set_category (CAT_INPUT)
     set_subcategory (SUBCAT_INPUT_ACCESS)
+    set_help (HELP_TEXT)
+
     add_shortcut ("pulse", "pulseaudio", "pa")
     set_callbacks (Open, Close)
 vlc_module_end ()
@@ -264,6 +270,11 @@ static int Open(vlc_object_t *obj)
                                   | PA_STREAM_FIX_FORMAT
                                   | PA_STREAM_FIX_RATE
                                   /*| PA_STREAM_FIX_CHANNELS*/;
+
+    const char *dev = NULL;
+    if (demux->psz_location != NULL && demux->psz_location[0] != '\0')
+        dev = demux->psz_location;
+
     const struct pa_buffer_attr attr = {
         .maxlength = -1,
         .fragsize = pa_usec_to_bytes(sys->caching, &ss) / 2,
@@ -288,7 +299,7 @@ static int Open(vlc_object_t *obj)
     pa_stream_set_suspended_callback(s, stream_suspended_cb, demux);
     pa_stream_set_underflow_callback(s, stream_underflow_cb, demux);
 
-    if (pa_stream_connect_record(s, NULL, &attr, flags) < 0
+    if (pa_stream_connect_record(s, dev, &attr, flags) < 0
      || stream_wait(s, sys->mainloop)) {
         vlc_pa_error(obj, "cannot connect record stream", sys->context);
         goto error;



More information about the vlc-commits mailing list