[vlc-devel] [PATCH] Jack: allow to specify a name of the instance through --jack-name
Tristan Matthews
tmatth at videolan.org
Tue Mar 22 04:59:48 CET 2016
On Mon, Mar 21, 2016 at 12:44 PM, Jean-Baptiste Kempf <jb at videolan.org> wrote:
> Ref #16746
> ---
> modules/audio_output/jack.c | 26 +++++++++++++++++++-------
> 1 file changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/modules/audio_output/jack.c b/modules/audio_output/jack.c
> index f2330d6..1464ca1 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,16 @@ 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 )
> + 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 +195,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 )
> {
> --
LGTM
More information about the vlc-devel
mailing list