Hi Cal,

On Sat, 5 Sep 2009, cal wrote:

I can't quite figure it out, can anyone tell me the circumstances that would
lead to jack reporting a change to samplerate/buffersize on the fly?

cheers, Cal

It's part of the API of JACK... so any application can cause it to happen for any reason. It usually doesn't happen automatically, but as the result of a user's interaction.

For example, the attached C++ program gives you a command-line tool to change the buffersize on the fly. Compile & run it like this:

   $ g++ -o jack_set_buffer_size jack_set_buffer_size.cpp -ljack
   $ ./jack_set_buffer_size 1024

It's pretty simple to write a similar app. for samplerate.

HTH,
Gabriel
/**********************************************-*- indent-tabs-mode:nil; -*-
 *                                                                         *
 *   Jack Transport Audit Utils                                            *
 *                                                                         *
 *   Copyright (C) 2009 by Gabriel M. Beddingfield                         *
 *   [email protected]                                                    *
 *                                                                         *
 *   "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 <cstdlib>
#include <iostream>
#include <jack/jack.h>

using namespace std;

void usage()
{
    cout << "usage: jack_set_buffer_size <N>" << 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;
}
_______________________________________________
Linux-audio-dev mailing list
[email protected]
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev

Reply via email to