/**********************************************-*- indent-tabs-mode:nil; -*- * * * Jack Transport Audit Utils * * * * Copyright (C) 2009 by Gabriel M. Beddingfield * * gabriel@teuton.org * * * * "For of him [God], and through him, and unto him, are all things. * * To him be the glory for ever. Amen." (Romans 11:36) * * * * 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; version 2 of the License, or 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., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ /* jack_set_buffer_size.cpp * * Command-line utility to change the buffer-size (samples per period) on a * running jack server. */ #include #include #include using namespace std; void usage() { cout << "usage: jack_set_buffer_size " << endl << "\tWhere N is an integer that is a power of two" << endl << "\tThe JACK server must already be running" << endl << endl; } int main(int argc, char* argv[]) { jack_client_t *client = 0; jack_nframes_t nframes = 0; cout << "jack_set_buffer_size " "Copyright (C)2009 by Gabriel M. Beddingfield" << endl; /* Parse command line... */ if( argc != 2 ) { usage(); exit(EXIT_SUCCESS); } long tmp_i = atol(argv[1]); if( tmp_i > 0 ) nframes = (jack_nframes_t)tmp_i; /* Check value given by user. */ if( (nframes == 0) || ( 0 != (nframes & (nframes-1)) ) ) { usage(); cout << "Error: N (" << argv[1] << ") must be" "a non-zero integer that is a power of two " "(2, 4, 8, 16, 32, etc.)" << endl << "Exiting..." << endl; exit(EXIT_FAILURE); } client = jack_client_open("jack_set_buffer_size", JackNoStartServer, 0); if( !client ) { cout << "Error connecting to jack server." << endl << "Exiting..." << endl; exit(EXIT_FAILURE); } int rv = jack_set_buffer_size(client, nframes); if( rv ) { cout << "Error setting buffer size, JACK did not accept it." << endl; rv = EXIT_FAILURE; } else { rv = EXIT_SUCCESS; } jack_client_close(client); return rv; }