[vlc-commits] Jack: allow to specify a name of the instance through --jack-name
Jean-Baptiste Kempf
git at videolan.org
Fri Mar 25 08:42:03 CET 2016
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Mar 21 17:38:13 2016 +0100| [035f11c8bf84b8f8331c475557b4ee18974912e7] | committer: Jean-Baptiste Kempf
Jack: allow to specify a name of the instance through --jack-name
Ref #16746
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=035f11c8bf84b8f8331c475557b4ee18974912e7
---
modules/audio_output/jack.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/modules/audio_output/jack.c b/modules/audio_output/jack.c
index f2330d6..d83137b 100644
--- a/modules/audio_output/jack.c
+++ b/modules/audio_output/jack.c
@@ -28,7 +28,6 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <unistd.h> /* write(), close() */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -41,6 +40,9 @@
#include <jack/jack.h>
#include <jack/ringbuffer.h>
+#include <stdio.h>
+#include <unistd.h> /* write(), close() */
+
typedef jack_default_audio_sample_t jack_sample_t;
/*****************************************************************************
@@ -89,6 +91,8 @@ static int GraphChange ( void *p_arg );
"If automatic connection is enabled, only JACK clients whose names " \
"match this regular expression will be considered for connection." )
+#define JACK_NAME_TEXT N_( "Jack client name" )
+
/*****************************************************************************
* Module descriptor
*****************************************************************************/
@@ -102,6 +106,8 @@ vlc_module_begin ()
AUTO_CONNECT_LONGTEXT, false )
add_string( CONNECT_REGEX_OPTION, "system", CONNECT_REGEX_TEXT,
CONNECT_REGEX_LONGTEXT, false )
+ add_string( "jack-name", "", JACK_NAME_TEXT, JACK_NAME_TEXT, false)
+
add_sw_gain( )
set_callbacks( Open, Close )
vlc_module_end ()
@@ -109,7 +115,8 @@ vlc_module_end ()
static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
{
- char psz_name[32];
+ char *psz_name;
+ char psz_name_output[32];
struct aout_sys_t *p_sys = p_aout->sys;
int status = VLC_SUCCESS;
unsigned int i;
@@ -119,11 +126,19 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
p_sys->paused = VLC_TS_INVALID;
/* Connect to the JACK server */
- snprintf( psz_name, sizeof(psz_name), "vlc_%d", getpid());
- psz_name[sizeof(psz_name) - 1] = '\0';
+ psz_name = var_InheritString( p_aout, "jack-name" );
+ if( !psz_name || !*psz_name )
+ {
+ free( psz_name );
+ if( asprintf( &psz_name, "vlc_%d", getpid()) == -1 )
+ return VLC_ENOMEM;
+ }
+
p_sys->p_jack_client = jack_client_open( psz_name,
JackNullOption | JackNoStartServer,
NULL );
+ free( psz_name );
+
if( p_sys->p_jack_client == NULL )
{
msg_Err( p_aout, "failed to connect to JACK server" );
@@ -183,10 +198,10 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
/* Create the output ports */
for( i = 0; i < p_sys->i_channels; i++ )
{
- snprintf( psz_name, sizeof(psz_name), "out_%d", i + 1);
- psz_name[sizeof(psz_name) - 1] = '\0';
+ snprintf( psz_name_output, sizeof(psz_name_output), "out_%d", i + 1);
+ psz_name_output[sizeof(psz_name_output) - 1] = '\0';
p_sys->p_jack_ports[i] = jack_port_register( p_sys->p_jack_client,
- psz_name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 );
+ psz_name_output, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 );
if( p_sys->p_jack_ports[i] == NULL )
{
More information about the vlc-commits
mailing list