Browse Source

rearrange Jackclient class so that we can pick up default sample rate and bufsize from the JACK server if they are not specified

tags/0.124.0^0
Paul Davis 12 years ago
parent
commit
f1d41e44e4
4 changed files with 67 additions and 17 deletions
  1. +22
    -5
      zalsa/jackclient.cc
  2. +2
    -1
      zalsa/jackclient.h
  3. +22
    -6
      zalsa/zita-a2j.cc
  4. +21
    -5
      zalsa/zita-j2a.cc

+ 22
- 5
zalsa/jackclient.cc View File

@@ -44,8 +44,7 @@ Jackclient::~Jackclient (void)

void Jackclient::init (const char *jserv)
{
int i, spol, flags;
char s [64];
int spol;
jack_status_t stat;
struct sched_param spar;

@@ -66,8 +65,27 @@ void Jackclient::init (const char *jserv)
_bsize = jack_get_buffer_size (_client);
_fsamp = jack_get_sample_rate (_client);

if (_nchan)
{
register_ports (_nchan);
}

_rprio = jack_client_real_time_priority (_client) - sched_get_priority_max (spol);
}

void Jackclient::register_ports (int n)
{
int i, flags;
char s [64];

if (n > sizeof (_ports) / sizeof (_ports[0]))
{
return;
}

flags = JackPortIsTerminal | JackPortIsPhysical;
for (i = 0; i < _nchan; i++)

for (i = 0; i < n; i++)
{
if (_mode == PLAY)
{
@@ -83,11 +101,10 @@ void Jackclient::init (const char *jserv)
}
}

_rprio = jack_client_real_time_priority (_client) - sched_get_priority_max (spol);
_nchan = n;
_buff = new float [_bsize * _nchan];
}


void Jackclient::fini (void)
{
delete[] _buff;


+ 2
- 1
zalsa/jackclient.h View File

@@ -50,6 +50,7 @@ public:
int fsamp (void) const { return _fsamp; }
int bsize (void) const { return _bsize; }
int rprio (void) const { return _rprio; }
void register_ports (int nports);

private:

@@ -78,7 +79,7 @@ private:
int jack_process (int nframes);

jack_client_t *_client;
jack_port_t *_ports [64];
jack_port_t *_ports [256];
const char *_jname;
int _mode;
int _nchan;


+ 22
- 6
zalsa/zita-a2j.cc View File

@@ -39,8 +39,8 @@ static bool v_opt = false;
static bool L_opt = false;
static const char *jname = APPNAME;
static const char *device = 0;
static int fsamp = 48000;
static int bsize = 256;
static int fsamp = 0; // try to get from server if unspecified
static int bsize = 0; // try to get from server if unspecified
static int nfrag = 2;
static int nchan = 2;
static int rqual = 48;
@@ -148,7 +148,6 @@ static int parse_options (const char* load_init)
}
argv[argc++] = token;
fprintf (stderr, "stash argv[%d] as %s\n", argc, token);
ptr = NULL;
}

@@ -216,12 +215,29 @@ jack_initialize (jack_client_t* client, const char* load_init)
if (device == 0) help ();
if (rqual < 16) rqual = 16;
if (rqual > 96) rqual = 96;
if ((fsamp < 8000) || (bsize < 16) || (nfrag < 2) || (nchan < 1))
if ((fsamp && fsamp < 8000) || (bsize && bsize < 16) || (nfrag < 2) || (nchan < 1))
{
fprintf (stderr, "Illegal parameter value(s).\n");
return 1;
}

J = new Jackclient (client, 0, Jackclient::CAPT, 0);
usleep (100000);

/* if SR and/or bufsize are unspecified, use the same values
as the JACK server.
*/
if (fsamp == 0)
{
fsamp = J->fsamp();
}

if (bsize == 0)
{
bsize = J->bsize();
}

opts = 0;
if (v_opt) opts |= Alsa_pcmi::DEBUG_ALL;
if (L_opt) opts |= Alsa_pcmi::FORCE_16B | Alsa_pcmi::FORCE_2CH;
@@ -238,8 +254,8 @@ jack_initialize (jack_client_t* client, const char* load_init)
fprintf (stderr, "Warning: only %d channels are available.\n", nchan);
}
C = new Alsathread (A, Alsathread::CAPT);
J = new Jackclient (client, 0, Jackclient::CAPT, nchan);
usleep (100000);
J->register_ports (nchan);

t_alsa = (double) bsize / fsamp;
if (t_alsa < 1e-3) t_alsa = 1e-3;


+ 21
- 5
zalsa/zita-j2a.cc View File

@@ -39,8 +39,8 @@ static bool v_opt = false;
static bool L_opt = false;
static const char *jname = APPNAME;
static const char *device = 0;
static int fsamp = 48000;
static int bsize = 256;
static int fsamp = 0;
static int bsize = 0;
static int nfrag = 2;
static int nchan = 2;
static int rqual = 48;
@@ -213,12 +213,29 @@ int jack_initialize (jack_client_t* client, const char* load_init)
if (device == 0) help ();
if (rqual < 16) rqual = 16;
if (rqual > 96) rqual = 96;
if ((fsamp < 8000) || (bsize < 16) || (nfrag < 2) || (nchan < 1))
if ((fsamp && fsamp < 8000) || (bsize && bsize < 16) || (nfrag < 2) || (nchan < 1))
{
fprintf (stderr, "Illegal parameter value(s).\n");
return 1;
}

J = new Jackclient (client, 0, Jackclient::PLAY, 0);
usleep (100000);

/* if SR and/or bufsize are unspecified, use the same values
as the JACK server.
*/
if (fsamp == 0)
{
fsamp = J->fsamp();
}

if (bsize == 0)
{
bsize = J->bsize();
}

opts = 0;
if (v_opt) opts |= Alsa_pcmi::DEBUG_ALL;
if (L_opt) opts |= Alsa_pcmi::FORCE_16B | Alsa_pcmi::FORCE_2CH;
@@ -235,8 +252,7 @@ int jack_initialize (jack_client_t* client, const char* load_init)
fprintf (stderr, "Warning: only %d channels are available.\n", nchan);
}
P = new Alsathread (A, Alsathread::PLAY);
J = new Jackclient (client, 0, Jackclient::PLAY, nchan);
usleep (100000);
J->register_ports (nchan);

t_alsa = (double) bsize / fsamp;
if (t_alsa < 1e-3) t_alsa = 1e-3;


Loading…
Cancel
Save