mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 01:40:15 +00:00
Dynamically open JACK transport as well
This commit is contained in:
@@ -13,10 +13,9 @@ CXXFLAGS = @CXXFLAGS@ $(COMMON_FLAGS) -D_GNU_SOURCE
|
||||
MKDIR_P = mkdir -p
|
||||
CUDA_FLAGS = @CUDA_FLAGS@ @CUDA_COMPUTE_ARGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS += @LIBS@ @JACK_TRANS_LIB@ @MATHLIBS@ -lm -pthread
|
||||
LIBS += @LIBS@ @MATHLIBS@ -lm -pthread
|
||||
INC = -Isrc -I$(srcdir) -I$(srcdir)/src -I$(srcdir)/test -Idxt_compress \
|
||||
@JACK_TRANS_INC@ @SPEEX_INC@ \
|
||||
@CUDA_INC@ @INC@
|
||||
@SPEEX_INC@ @CUDA_INC@ @INC@
|
||||
DECKLINK_PATH = @DECKLINK_PATH@
|
||||
DYLIBBUNDLER = @DYLIBBUNDLER@
|
||||
DYLIBBUNDLER_FLAGS += @DYLIBBUNDLER_FLAGS@
|
||||
|
||||
20
configure.ac
20
configure.ac
@@ -2422,35 +2422,21 @@ jack_trans=no
|
||||
jack=no
|
||||
|
||||
AC_ARG_ENABLE(jack-transport,
|
||||
[ --enable-jack-transport[=force] enable JACK transport (default is auto; disabled in modular build, can be forced)]
|
||||
[ --enable-jack-transport[=force] enable JACK transport (default is auto)]
|
||||
[ Requires: jack],
|
||||
[jack_trans_req=$enableval],
|
||||
[jack_trans_req=$build_default])
|
||||
|
||||
if test $jack_trans_req = yes -a $build_libraries = yes
|
||||
then
|
||||
AC_MSG_ERROR([JACK transport is currently incompatible with modular build]);
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADER(jack/jack.h, FOUND_JACK_H=yes, FOUND_JACK_H=no)
|
||||
AC_CHECK_LIB(jack, jack_client_new, [FOUND_JACK_L=yes]
|
||||
[JACK_LIB=-ljack], FOUND_JACK_L=no)
|
||||
if test $FOUND_JACK_L = no; then
|
||||
# Windows
|
||||
AC_CHECK_LIB(libjack64, jack_client_new, [FOUND_JACK_L=yes]
|
||||
[JACK_LIB=-llibjack64], FOUND_JACK_L=no)
|
||||
fi
|
||||
|
||||
if test $jack_trans_req != no -a $FOUND_JACK_H = yes -a $FOUND_JACK_L = yes -a \( $build_libraries = no -o $jack_trans_req = force \)
|
||||
if test $jack_trans_req != no -a $FOUND_JACK_H = yes
|
||||
then
|
||||
JACK_TRANS_OBJ="src/audio/jack.o"
|
||||
JACK_TRANS_LIB="$JACK_LIB"
|
||||
AC_DEFINE([HAVE_JACK_TRANS], [1], [Build with JACK transport support])
|
||||
jack_trans=yes
|
||||
fi
|
||||
AC_SUBST(JACK_TRANS_OBJ)
|
||||
AC_SUBST(JACK_TRANS_LIB)
|
||||
AC_SUBST(JACK_TRANS_INC)
|
||||
|
||||
# sound system
|
||||
AC_ARG_ENABLE(jack,
|
||||
@@ -2459,7 +2445,7 @@ AC_ARG_ENABLE(jack,
|
||||
[jack_req=$enableval],
|
||||
[jack_req=$build_default])
|
||||
|
||||
if test $jack_req != no -a $FOUND_JACK_H = yes -a $FOUND_JACK_L = yes
|
||||
if test $jack_req != no -a $FOUND_JACK_H = yes
|
||||
then
|
||||
JACK_CAP_OBJ="src/audio/capture/jack.o"
|
||||
JACK_PLAY_OBJ="src/audio/playback/jack.o"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @author Martin Pulec <pulec@cesnet.cz>
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2011-2019 CESNET, z. s. p. o.
|
||||
* Copyright (c) 2011-2020 CESNET, z. s. p. o.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,6 +34,11 @@
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* @todo
|
||||
* It looks like there is no jack_stop()?
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@@ -49,6 +54,7 @@
|
||||
|
||||
#include "audio/audio.h"
|
||||
#include "audio/jack.h"
|
||||
#include "jack_common.h"
|
||||
#include "pthread.h"
|
||||
#include "rtp/rtp.h"
|
||||
#include "rtp/pbuf.h"
|
||||
@@ -59,6 +65,8 @@
|
||||
#define MAX_PORTS 8
|
||||
|
||||
struct state_jack {
|
||||
struct libjack_connection *libjack;
|
||||
|
||||
unsigned int sender:1,
|
||||
receiver:1;
|
||||
|
||||
@@ -102,7 +110,7 @@ int jack_process_callback(jack_nframes_t nframes, void *arg) {
|
||||
|
||||
int to_end = BUFF_SIZE - s->play_buffer_start;
|
||||
jack_default_audio_sample_t *out =
|
||||
jack_port_get_buffer (s->output_port[i], nframes);
|
||||
s->libjack->port_get_buffer (s->output_port[i], nframes);
|
||||
if(to_end > send_b) {
|
||||
memcpy (out, s->play_buffer[i] + s->play_buffer_start,
|
||||
send_b);
|
||||
@@ -119,7 +127,7 @@ int jack_process_callback(jack_nframes_t nframes, void *arg) {
|
||||
for(i = 0; i < s->record.ch_count; ++i) {
|
||||
int j;
|
||||
jack_default_audio_sample_t *in =
|
||||
jack_port_get_buffer (s->input_port[i], nframes);
|
||||
s->libjack->port_get_buffer (s->input_port[i], nframes);
|
||||
for(j = 0; j < (int) nframes; ++j) {
|
||||
*(int *)(void *)(s->rec_buffer + ((s->rec_buffer_end + (j * s->record.ch_count + i) * sizeof(int32_t)) % BUFF_SIZE)) =
|
||||
in[j] * INT_MAX;
|
||||
@@ -146,13 +154,13 @@ void reconfigure_send_ch_count(struct state_jack *s, int ch_count)
|
||||
|
||||
s->out_channel_count = s->out_channel_count_req = ch_count;
|
||||
|
||||
if ((ports = jack_get_ports (s->client, s->out_port_pattern, NULL, JackPortIsInput)) == NULL) {
|
||||
if ((ports = s->libjack->get_ports (s->client, s->out_port_pattern, NULL, JackPortIsInput)) == NULL) {
|
||||
fprintf(stderr, "Cannot find any ports matching pattern '%s'\n", s->out_port_pattern);
|
||||
s->out_channel_count = 0;
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < s->record.ch_count; ++i) {
|
||||
jack_disconnect(s->client, jack_port_name (s->output_port[i]), ports[i]);
|
||||
s->libjack->disconnect(s->client, s->libjack->port_name (s->output_port[i]), ports[i]);
|
||||
free(s->play_buffer[i]);
|
||||
}
|
||||
|
||||
@@ -168,7 +176,7 @@ void reconfigure_send_ch_count(struct state_jack *s, int ch_count)
|
||||
|
||||
for(i = 0; i < s->out_channel_count; ++i) {
|
||||
fprintf(stderr, "%s\n\n\n", ports[i]);
|
||||
if (jack_connect (s->client, jack_port_name (s->output_port[i]), ports[i])) {
|
||||
if (s->libjack->connect (s->client, s->libjack->port_name (s->output_port[i]), ports[i])) {
|
||||
fprintf (stderr, "cannot connect output ports\n");
|
||||
}
|
||||
s->play_buffer[i] = malloc(BUFF_SIZE);
|
||||
@@ -234,7 +242,7 @@ static int attach_input_ports(struct state_jack *s)
|
||||
{
|
||||
int i = 0;
|
||||
const char **ports;
|
||||
if ((ports = jack_get_ports (s->client, s->in_port_pattern, NULL, JackPortIsOutput)) == NULL) {
|
||||
if ((ports = s->libjack->get_ports (s->client, s->in_port_pattern, NULL, JackPortIsOutput)) == NULL) {
|
||||
fprintf(stderr, "Cannot find any ports matching pattern '%s'\n", s->in_port_pattern);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -248,7 +256,7 @@ static int attach_input_ports(struct state_jack *s)
|
||||
}
|
||||
|
||||
for(i = 0; i < s->in_ch_count; ++i) {
|
||||
if (jack_connect (s->client, ports[i], jack_port_name (s->input_port[i]))) {
|
||||
if (s->libjack->connect (s->client, ports[i], s->libjack->port_name (s->input_port[i]))) {
|
||||
fprintf (stderr, "cannot connect input ports\n");
|
||||
}
|
||||
}
|
||||
@@ -262,6 +270,12 @@ void * jack_start(const char *cfg)
|
||||
struct state_jack *s;
|
||||
|
||||
s = (struct state_jack *) malloc(sizeof(struct state_jack));
|
||||
assert (s != NULL);
|
||||
s->libjack = open_libjack();
|
||||
if (s->libjack == NULL) {
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s->in_port_pattern = NULL;
|
||||
s->out_port_pattern = NULL;
|
||||
@@ -277,22 +291,20 @@ void * jack_start(const char *cfg)
|
||||
free(cfg_copy);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Setting JACK failed. Check configuration ('-j' option).\n");
|
||||
free(s);
|
||||
return NULL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(!s->sender && !s->receiver) {
|
||||
free(s);
|
||||
return NULL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
s->client = jack_client_open(CLIENT_NAME, JackNullOption, NULL);
|
||||
if(jack_set_process_callback(s->client, jack_process_callback, (void *) s) != 0) {
|
||||
s->client = s->libjack->client_open(CLIENT_NAME, JackNullOption, NULL);
|
||||
if(s->libjack->set_process_callback(s->client, jack_process_callback, (void *) s) != 0) {
|
||||
fprintf(stderr, "[jack] Callback initialization problem.\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(jack_set_sample_rate_callback(s->client,
|
||||
if(s->libjack->set_sample_rate_callback(s->client,
|
||||
jack_samplerate_changed_callback, (void *) s)) {
|
||||
fprintf(stderr, "[jack] Callback initialization problem.\n");
|
||||
goto error;
|
||||
@@ -306,7 +318,7 @@ void * jack_start(const char *cfg)
|
||||
|
||||
for(i = 0; i < MAX_PORTS; ++i) {
|
||||
snprintf(name, 30, "out_%02u", i);
|
||||
s->output_port[i] = jack_port_register (s->client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
|
||||
s->output_port[i] = s->libjack->port_register (s->client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
|
||||
}
|
||||
|
||||
s->out_channel_count = s->out_channel_count_req = 0;
|
||||
@@ -318,16 +330,16 @@ void * jack_start(const char *cfg)
|
||||
|
||||
for(i = 0; i < s->in_ch_count; ++i) {
|
||||
snprintf(name, 30, "in_%02u", i);
|
||||
s->input_port[i] = jack_port_register (s->client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
|
||||
s->input_port[i] = s->libjack->port_register (s->client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
|
||||
}
|
||||
|
||||
s->record.sample_rate = jack_get_sample_rate (s->client);
|
||||
s->record.sample_rate = s->libjack->get_sample_rate (s->client);
|
||||
s->record.bps = sizeof(int32_t);
|
||||
s->record.ch_count = s->in_ch_count;
|
||||
s->rec_buffer = s->record.data = (void *) malloc(BUFF_SIZE);
|
||||
}
|
||||
|
||||
if (jack_activate (s->client)) {
|
||||
if (s->libjack->activate (s->client)) {
|
||||
fprintf (stderr, "cannot activate client");
|
||||
goto error;
|
||||
}
|
||||
@@ -338,7 +350,9 @@ void * jack_start(const char *cfg)
|
||||
}
|
||||
|
||||
return s;
|
||||
error:
|
||||
error:
|
||||
close_libjack(s->libjack);
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user