From 50c12df7e2632fe0abdbe48821036ca9be67b7a3 Mon Sep 17 00:00:00 2001 From: joq Date: Sun, 28 Sep 2003 03:31:10 +0000 Subject: [PATCH] [0.83.2] jack_set_buffer_size() "alpha test" version git-svn-id: svn+ssh://jackaudio.org/trunk/jack@513 0c269be4-1314-0410-8aa9-9f06e86f4224 --- configure.in | 2 +- example-clients/.cvsignore | 1 + example-clients/Makefile.am | 5 ++ example-clients/bufsize.c | 96 +++++++++++++++++++++++++++++++++++++ jackd/engine.c | 9 ++-- 5 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 example-clients/bufsize.c diff --git a/configure.in b/configure.in index d50a77c..c440f53 100644 --- a/configure.in +++ b/configure.in @@ -14,7 +14,7 @@ dnl changes are made dnl --- JACK_MAJOR_VERSION=0 JACK_MINOR_VERSION=83 -JACK_MICRO_VERSION=1 +JACK_MICRO_VERSION=2 dnl --- dnl HOWTO: updating the jack protocal version diff --git a/example-clients/.cvsignore b/example-clients/.cvsignore index dd43b81..a204f88 100644 --- a/example-clients/.cvsignore +++ b/example-clients/.cvsignore @@ -10,6 +10,7 @@ jack_impulse_grabber jack_monitor_client jack_simple_client jackrec +jack_bufsize jack_showtime jack_lsp jack_metro diff --git a/example-clients/Makefile.am b/example-clients/Makefile.am index 7f38cb7..48333d8 100644 --- a/example-clients/Makefile.am +++ b/example-clients/Makefile.am @@ -33,6 +33,7 @@ bin_PROGRAMS = jack_load \ jack_disconnect \ jack_metro \ jack_showtime \ + jack_bufsize \ jack_lsp \ $(JACKREC) \ $(JACK_TRANSPORT) @@ -73,6 +74,10 @@ jack_showtime_SOURCES = showtime.c jack_showtime_LDFLAGS = -lrt -ldl -lpthread jack_showtime_LDADD = ../libjack/libjack.la +jack_bufsize_SOURCES = bufsize.c +jack_bufsize_LDFLAGS = +jack_bufsize_LDADD = ../libjack/libjack.la + if HAVE_SNDFILE jackrec_SOURCES = capture_client.c ringbuffer.c ringbuffer.h diff --git a/example-clients/bufsize.c b/example-clients/bufsize.c new file mode 100644 index 0000000..39e6718 --- /dev/null +++ b/example-clients/bufsize.c @@ -0,0 +1,96 @@ +/* + * bufsize.c -- change JACK buffer size. + * + * Copyright (C) 2003 Jack O'Quin. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +char *package; /* program name */ +jack_client_t *client; +jack_nframes_t nframes; + +void jack_shutdown(void *arg) +{ + fprintf(stderr, "JACK shut down, exiting ...\n"); + exit(1); +} + +void signal_handler(int sig) +{ + jack_client_close(client); + fprintf(stderr, "signal received, exiting ...\n"); + exit(0); +} + +void parse_arguments(int argc, char *argv[]) +{ + + /* basename $0 */ + package = strrchr(argv[0], '/'); + if (package == 0) + package = argv[0]; + else + package++; + + if (argc < 2) { + fprintf(stderr, "usage: %s \n", package); + exit(9); + } + + nframes = strtoul(argv[1], NULL, 0); + if (errno == ERANGE) { + fprintf(stderr, "%s: invalid buffer size: %s\n", + package, argv[1]); + exit(2); + } +} + +int main(int argc, char *argv[]) +{ + int rc; + + parse_arguments(argc, argv); + + /* become a JACK client */ + if ((client = jack_client_new(package)) == 0) { + fprintf(stderr, "JACK server not running?\n"); + exit(1); + } + + signal(SIGQUIT, signal_handler); + signal(SIGTERM, signal_handler); + signal(SIGHUP, signal_handler); + signal(SIGINT, signal_handler); + + jack_on_shutdown(client, jack_shutdown, 0); + + rc = jack_set_buffer_size(client, nframes); + if (rc) + fprintf(stderr, "jack_set_buffer_size() returns %d\n", rc); + + jack_client_close(client); + + return rc; +} diff --git a/jackd/engine.c b/jackd/engine.c index aa11c4b..21954c2 100644 --- a/jackd/engine.c +++ b/jackd/engine.c @@ -395,10 +395,13 @@ jack_resize_port_segment (jack_engine_t *engine, /* update any existing output port offsets */ for (i = 0; i < engine->port_max; i++) { - if (engine->control->ports[i].flags|JackPortIsOutput && - engine->control->ports[i].ptype_id == ptid) { + if (engine->control->ports[i].flags & JackPortIsOutput + && engine->control->ports[i].ptype_id == ptid) { bi = engine->internal_ports[i].buffer_info; - engine->control->ports[i].offset = bi->offset; + if (bi) { + engine->control->ports[i].offset = + bi->offset; + } } } pthread_mutex_unlock (&pti->buffer_lock);