1
/* -*- mode: c; c-file-style: "bsd"; -*- */
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
Grame Research Laboratory, 9, rue du Garet 69001 Lyon - France
22
02-09-03 : Modify jack port naming : add the name of the used driver
23
Add the -n option to load a specific driver using it's name
24
04-09-03 : Correct bug in -n option management : input and ouput have to be treated separately
25
08-09-03 : More robust driver loading code : new portaudio_load_default and portaudio_load_driver functions.
26
24-09-03 : Does not tries to load default device if the required one is not found, returns and error.
27
14-10-03 : After jack port name size extension, does not use fixed length for CoreAudio driver name anymore
28
09-01-04 : Handle different value for channel in and channel out (using -i and -o)
29
12-01-04 : Connect port names (inverse "in" and "out")
30
13-01-04 : Correct the length of jack port : use JACK_PORT_NAME_SIZE
31
22-03-04 : Remove jack_init_time, rename input and ouput ports using "capture" and "playback"
32
10-11-04 : S. Letz: Add management of -I option for use with JackPilot.
33
17-11-04 : S. Letz: Better debug code.
34
03-02-05 : S. Letz: fix several driver detection bugs on OSX.
35
06-08-05 : S.Letz: Remove the "-I" parameter, change the semantic of "-n" parameter on OSX : -n (driver name) now correctly uses the PropertyDeviceUID
36
(persistent accross reboot...) as the identifier for the used coreaudio driver.
45
#include <jack/engine.h>
46
#include "portaudio_driver.h"
48
#ifdef JACK_USE_MACH_THREADS
50
#include <CoreAudio/CoreAudio.h>
51
#include <CoreFoundation/CFString.h>
53
static OSStatus get_device_name_from_id(AudioDeviceID id, char name[60])
55
UInt32 size = sizeof(char) * 60;
56
OSStatus stat = AudioDeviceGetProperty(id, 0, false,
57
kAudioDevicePropertyDeviceName,
63
static OSStatus get_device_id_from_num(int i, AudioDeviceID * id)
68
AudioDeviceID *theDeviceList;
71
AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices,
73
nDevices = theSize / sizeof(AudioDeviceID);
75
(AudioDeviceID *) malloc(nDevices * sizeof(AudioDeviceID));
77
AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &theSize,
80
*id = theDeviceList[i];
84
static OSStatus get_device_id_from_uid(char* UID, AudioDeviceID* id)
86
UInt32 size = sizeof(AudioValueTranslation);
87
CFStringRef inIUD = CFStringCreateWithCString(NULL, UID, CFStringGetSystemEncoding());
88
AudioValueTranslation value = { &inIUD, sizeof(CFStringRef), id, sizeof(AudioDeviceID) };
90
return kAudioHardwareUnspecifiedError;
92
OSStatus res = AudioHardwareGetProperty(kAudioHardwarePropertyDeviceForUID, &size, &value);
99
typedef unsigned int AudioDeviceID;
104
void PALog(char *fmt, ...)
109
fprintf(stderr, "JCA: ");
110
vfprintf(stderr, fmt, ap);
116
paCallback(void *inputBuffer, void *outputBuffer,
117
unsigned long framesPerBuffer,
118
PaTimestamp outTime, void *userData)
120
portaudio_driver_t * driver = (portaudio_driver_t*)userData;
122
driver->inPortAudio = (float*)inputBuffer;
123
driver->outPortAudio = (float*)outputBuffer;
124
driver->last_wait_ust = jack_get_microseconds();
125
return driver->engine->run_cycle(driver->engine, framesPerBuffer, 0);
129
portaudio_driver_attach (portaudio_driver_t *driver, jack_engine_t *engine)
134
char buf[JACK_PORT_NAME_SIZE];
136
driver->engine = engine;
138
driver->engine->set_buffer_size (engine, driver->frames_per_cycle);
139
driver->engine->set_sample_rate (engine, driver->frame_rate);
141
port_flags = JackPortIsOutput|JackPortIsPhysical|JackPortIsTerminal;
144
if (driver->has_hw_monitoring) {
145
port_flags |= JackPortCanMonitor;
149
for (chn = 0; chn < driver->capture_nchannels; chn++) {
150
//snprintf (buf, sizeof(buf) - 1, "%s:capture%lu", driver->driver_name, chn+1);
151
snprintf (buf, sizeof(buf) - 1, "%s:out%lu", driver->driver_name, chn+1);
153
if ((port = jack_port_register (driver->client, buf, JACK_DEFAULT_AUDIO_TYPE, port_flags, 0)) == NULL) {
154
jack_error ("portaudio: cannot register port for %s", buf);
158
/* XXX fix this so that it can handle: systemic (external) latency
161
jack_port_set_latency (port, driver->frames_per_cycle);
162
driver->capture_ports = jack_slist_append (driver->capture_ports, port);
165
port_flags = JackPortIsInput|JackPortIsPhysical|JackPortIsTerminal;
167
for (chn = 0; chn < driver->playback_nchannels; chn++) {
168
//snprintf (buf, sizeof(buf) - 1, "%s:playback%lu", driver->driver_name, chn+1);
169
snprintf (buf, sizeof(buf) - 1, "%s:in%lu", driver->driver_name, chn+1);
171
if ((port = jack_port_register (driver->client, buf, JACK_DEFAULT_AUDIO_TYPE, port_flags, 0)) == NULL) {
172
jack_error ("portaudio: cannot register port for %s", buf);
176
/* XXX fix this so that it can handle: systemic (external) latency
179
jack_port_set_latency (port, driver->frames_per_cycle);
180
driver->playback_ports = jack_slist_append (driver->playback_ports, port);
183
jack_activate (driver->client);
188
portaudio_driver_detach (portaudio_driver_t *driver, jack_engine_t *engine)
192
if (driver->engine == 0) {
196
for (node = driver->capture_ports; node; node = jack_slist_next (node)) {
197
jack_port_unregister (driver->client, ((jack_port_t *) node->data));
200
jack_slist_free (driver->capture_ports);
201
driver->capture_ports = 0;
203
for (node = driver->playback_ports; node; node = jack_slist_next (node)) {
204
jack_port_unregister (driver->client, ((jack_port_t *) node->data));
207
jack_slist_free (driver->playback_ports);
208
driver->playback_ports = 0;
215
portaudio_driver_null_cycle (portaudio_driver_t* driver, jack_nframes_t nframes)
217
memset(driver->outPortAudio, 0, (driver->playback_nchannels * nframes * sizeof(float)));
222
portaudio_driver_read (portaudio_driver_t *driver, jack_nframes_t nframes)
224
jack_default_audio_sample_t *buf;
230
for (chn = 0, node = driver->capture_ports; node; node = jack_slist_next (node), chn++) {
232
port = (jack_port_t *)node->data;
234
if (jack_port_connected (port) && (driver->inPortAudio != NULL)) {
235
int channels = driver->capture_nchannels;
236
float* in = driver->inPortAudio;
237
buf = jack_port_get_buffer (port, nframes);
238
for (i = 0; i< nframes; i++) buf[i] = in[channels*i+chn];
243
driver->engine->transport_cycle_start (driver->engine,
244
jack_get_microseconds ());
250
portaudio_driver_write (portaudio_driver_t *driver, jack_nframes_t nframes)
252
jack_default_audio_sample_t *buf;
256
int i,bytes = nframes*sizeof(float);
258
/* Clear in case of nothing is connected */
259
memset(driver->outPortAudio, 0, driver->playback_nchannels*bytes);
261
for (chn = 0, node = driver->playback_ports; node; node = jack_slist_next (node), chn++) {
263
port = (jack_port_t *)node->data;
265
if (jack_port_connected (port) && (driver->outPortAudio != NULL)) {
266
int channels = driver->playback_nchannels;
267
float* out = driver->outPortAudio;
268
buf = jack_port_get_buffer (port, nframes);
269
for (i = 0; i< nframes; i++) out[channels*i+chn] = buf[i];
277
portaudio_driver_audio_start (portaudio_driver_t *driver)
279
PaError err = Pa_StartStream(driver->stream);
280
return (err != paNoError) ? -1 : 0;
284
portaudio_driver_audio_stop (portaudio_driver_t *driver)
286
PaError err = Pa_StopStream(driver->stream);
287
return (err != paNoError) ? -1 : 0;
291
portaudio_driver_set_parameters (portaudio_driver_t* driver,
292
jack_nframes_t nframes,
295
int capturing = driver->capturing;
296
int playing = driver->playing;
298
int err = Pa_OpenStream(
300
((capturing) ? Pa_GetDefaultInputDeviceID() : paNoDevice),
301
((capturing) ? driver->capture_nchannels : 0),
302
paFloat32, /* 32-bit float input */
304
((playing) ? Pa_GetDefaultOutputDeviceID() : paNoDevice),
305
((playing) ? driver->playback_nchannels : 0),
306
paFloat32, /* 32-bit float output */
308
rate, /* sample rate */
309
nframes, /* frames per buffer */
310
0, /* number of buffers = default min */
311
paClipOff, /* we won't output out of
312
* range samples so don't
313
* bother clipping them */
317
if (err == paNoError) {
319
driver->period_usecs = (((float) driver->frames_per_cycle)
320
/ driver->frame_rate) * 1000000.0f;
321
driver->frame_rate = rate;
322
driver->frames_per_cycle = nframes;
324
/* tell engine about buffer size */
325
if (driver->engine) {
326
driver->engine->set_buffer_size (
327
driver->engine, driver->frames_per_cycle);
333
// JOQ: this driver is dead. How do we terminate it?
335
jack_error("Unable to set portaudio parameters");
336
jack_error("Error number: %d", err);
337
jack_error("Error message: %s", Pa_GetErrorText(err));
343
portaudio_driver_reset_parameters (portaudio_driver_t* driver,
344
jack_nframes_t nframes,
347
if (!jack_power_of_two(nframes)) {
348
jack_error("PA: frames must be a power of two "
349
"(64, 512, 1024, ...)");
353
Pa_CloseStream(driver->stream);
354
return portaudio_driver_set_parameters (driver, nframes, rate);
358
portaudio_driver_bufsize (portaudio_driver_t* driver, jack_nframes_t nframes)
362
/* This gets called from the engine server thread, so it must
363
* be serialized with the driver thread. Stopping the audio
364
* also stops that thread. */
366
if (portaudio_driver_audio_stop (driver)) {
367
jack_error ("PA: cannot stop to set buffer size");
371
rc = portaudio_driver_reset_parameters (driver, nframes,
374
if (portaudio_driver_audio_start (driver)) {
375
jack_error ("PA: cannot restart after setting buffer size");
382
//== instance creation/destruction =============================================
384
static int portaudio_load_default (portaudio_driver_t *driver,
391
const PaDeviceInfo *pdi;
395
PALog("Look for default driver\n");
397
*inputDeviceID = Pa_GetDefaultInputDeviceID();
398
*outputDeviceID = Pa_GetDefaultOutputDeviceID();
400
for(i=0; i<numDevices; i++)
402
pdi = Pa_GetDeviceInfo(i);
403
PALog("---------------------------------------------- #%d\n", i);
405
if (i == Pa_GetDefaultInputDeviceID()) {
406
driver->capture_nchannels = (capturing) ? pdi->maxInputChannels : 0;
407
strcpy (driver->driver_name,pdi->name);
411
if (i == Pa_GetDefaultOutputDeviceID()){
412
driver->playback_nchannels = (playing) ? pdi->maxOutputChannels : 0;
413
strcpy (driver->driver_name,pdi->name);
417
PALog("\nName = %s\n", pdi->name);
418
PALog("Max Inputs = %d ", pdi->maxInputChannels);
419
PALog("Max Outputs = %d\n", pdi->maxOutputChannels);
420
if( pdi->numSampleRates == -1 ){
421
PALog("Sample Rate Range = %f to %f\n", pdi->sampleRates[0], pdi->sampleRates[1]);
423
PALog("Sample Rates =");
424
for(j=0; j<pdi->numSampleRates; j++){
425
PALog(" %8.2f,", pdi->sampleRates[j]);
430
PALog("Native Sample Formats = ");
431
if (pdi->nativeSampleFormats & paInt8) PALog("paInt8, ");
432
if (pdi->nativeSampleFormats & paUInt8) PALog("paUInt8, ");
433
if (pdi->nativeSampleFormats & paInt16) PALog("paInt16, ");
434
if (pdi->nativeSampleFormats & paInt32) PALog("paInt32, ");
435
if (pdi->nativeSampleFormats & paFloat32) PALog("paFloat32, ");
436
if (pdi->nativeSampleFormats & paInt24) PALog("paInt24, ");
437
if (pdi->nativeSampleFormats & paPackedInt24) PALog("paPackedInt24, ");
444
static int portaudio_load_driver (portaudio_driver_t *driver,
452
const PaDeviceInfo *pdi;
456
PALog("Look for %s driver\n",driver_name);
458
for(i=0; i<numDevices; i++)
460
pdi = Pa_GetDeviceInfo(i);
461
PALog("---------------------------------------------- #%d\n", i);
463
// compare the first character
464
if (strncmp (driver_name, pdi->name,
465
JACK_DRIVER_PARAM_STRING_MAX) == 0) {
466
if (pdi->maxInputChannels > 0) {
468
driver->capture_nchannels =
469
(capturing) ? pdi->maxInputChannels : 0;
470
strcpy(driver->driver_name,pdi->name);
471
PALog("Found input driver = %s\n", driver_name);
474
if (pdi->maxOutputChannels > 0) {
476
driver->playback_nchannels =
477
(playing) ? pdi->maxOutputChannels : 0;
478
strcpy (driver->driver_name,pdi->name);
479
PALog("Found output driver = %s\n", driver_name);
482
PALog("Found driver without input or ouput = %s\n",
487
PALog("\nName = %s\n", pdi->name);
488
PALog("Max Inputs = %d ", pdi->maxInputChannels);
489
PALog("Max Outputs = %d\n", pdi->maxOutputChannels);
490
if( pdi->numSampleRates == -1 ){
491
PALog("Sample Rate Range = %f to %f\n", pdi->sampleRates[0],
492
pdi->sampleRates[1]);
494
PALog("Sample Rates =");
495
for(j=0; j<pdi->numSampleRates; j++){
496
PALog(" %8.2f,", pdi->sampleRates[j]);
501
PALog("Native Sample Formats = ");
502
if (pdi->nativeSampleFormats & paInt8) PALog("paInt8, ");
503
if (pdi->nativeSampleFormats & paUInt8) PALog("paUInt8, ");
504
if (pdi->nativeSampleFormats & paInt16) PALog("paInt16, ");
505
if (pdi->nativeSampleFormats & paInt32) PALog("paInt32, ");
506
if (pdi->nativeSampleFormats & paFloat32) PALog("paFloat32, ");
507
if (pdi->nativeSampleFormats & paInt24) PALog("paInt24, ");
508
if (pdi->nativeSampleFormats & paPackedInt24) PALog("paPackedInt24, ");
515
/** create a new driver instance
517
static jack_driver_t *
518
portaudio_driver_new (char *name,
519
jack_client_t* client,
520
jack_nframes_t frames_per_cycle,
526
DitherAlgorithm dither,
529
portaudio_driver_t *driver;
530
PaError err = paNoError;
532
int inputDeviceID,outputDeviceID;
535
PALog("portaudio driver version : %d\n", kVersion);
536
PALog("creating portaudio driver ... %" PRIu32 "|%" PRIu32 "\n",
537
frames_per_cycle, rate);
539
driver = (portaudio_driver_t *) calloc (1, sizeof (portaudio_driver_t));
541
jack_driver_init ((jack_driver_t *) driver);
543
if (!jack_power_of_two(frames_per_cycle)) {
544
jack_error ("PA: -p must be a power of two.");
548
driver->frames_per_cycle = frames_per_cycle;
549
driver->frame_rate = rate;
550
driver->capturing = capturing;
551
driver->playing = playing;
553
driver->attach = (JackDriverAttachFunction) portaudio_driver_attach;
554
driver->detach = (JackDriverDetachFunction) portaudio_driver_detach;
555
driver->read = (JackDriverReadFunction) portaudio_driver_read;
556
driver->write = (JackDriverReadFunction) portaudio_driver_write;
557
driver->null_cycle = (JackDriverNullCycleFunction) portaudio_driver_null_cycle;
558
driver->bufsize = (JackDriverBufSizeFunction) portaudio_driver_bufsize;
559
driver->start = (JackDriverStartFunction) portaudio_driver_audio_start;
560
driver->stop = (JackDriverStopFunction) portaudio_driver_audio_stop;
561
driver->stream = NULL;
563
#ifdef JACK_USE_MACH_THREADS
564
AudioDeviceID device_id;
566
if (get_device_id_from_uid(driver_name, &device_id) != noErr)
568
if (get_device_name_from_id(device_id, driver->driver_name) != noErr)
571
if (get_device_id_from_num(0, &device_id) != noErr)
573
if (get_device_name_from_id(device_id, driver->driver_name) != noErr)
578
err = Pa_Initialize();
579
PALog("Pa_Initialize OK \n");
581
PALog("Driver name required %s\n",driver->driver_name);
582
numDevices = Pa_CountDevices();
584
if( numDevices < 0 ){
585
PALog("ERROR: Pa_CountDevices returned 0x%x\n", numDevices);
590
PALog("Number of devices = %d\n", numDevices);
592
if (strcmp(driver->driver_name,"") == 0) {
593
found = portaudio_load_default(driver,numDevices,capturing,playing,&inputDeviceID,&outputDeviceID);
595
PALog("ERROR : default driver has not been found\n");
600
found = portaudio_load_driver(driver,numDevices,capturing,playing,&inputDeviceID,&outputDeviceID,driver->driver_name);
602
PALog("ERROR : driver %s has not been found \n",driver->driver_name);
608
if (err != paNoError) goto error;
610
PALog("Pa_GetDefaultOutputDeviceID() %ld\n", (long)Pa_GetDefaultOutputDeviceID());
611
PALog("Pa_GetDefaultInputDeviceID() %ld\n", (long)Pa_GetDefaultInputDeviceID());
613
PALog("--------------------------------------------------\n");
614
PALog("CoreAudio driver %s will be loaded\n", driver->driver_name);
615
PALog("inputDeviceID %ld\n", (long)inputDeviceID);
616
PALog("outputDeviceID %ld\n", (long)outputDeviceID);
617
PALog("driver->capture_nchannels %ld\n", driver->capture_nchannels);
618
PALog("driver->playback_nchannels %ld\n", driver->playback_nchannels);
620
PALog("chan_in, chan_out %ld %ld\n", (long)chan_in, (long)chan_out);
623
driver->capture_nchannels = (driver->capture_nchannels < chan_in) ? driver->capture_nchannels : chan_in;
626
driver->playback_nchannels = (driver->playback_nchannels < chan_out) ? driver->playback_nchannels : chan_out;
628
PALog("driver->capture_nchannels %ld\n", driver->capture_nchannels);
629
PALog("driver->playback_nchannels %ld\n", driver->playback_nchannels);
631
err = Pa_OpenStream(&driver->stream,
632
((capturing && (driver->capture_nchannels > 0)) ? inputDeviceID : paNoDevice),
633
((capturing) ? driver->capture_nchannels : 0),
634
paFloat32, // 32 bit floating point input
636
((playing && (driver->playback_nchannels > 0)) ? outputDeviceID : paNoDevice),
637
((playing) ? driver->playback_nchannels : 0),
638
paFloat32, // 32 bit floating point output
641
frames_per_cycle, // frames per buffer
642
0, // number of buffers, if zero then use default minimum
643
paClipOff, // we won't output out of range samples so don't bother clipping them
647
if (err != paNoError) goto error;
649
driver->client = client;
650
driver->period_usecs = (((float) driver->frames_per_cycle) / driver->frame_rate) * 1000000.0f;
651
return((jack_driver_t *) driver);
656
jack_error("An error occured while using the portaudio stream");
657
jack_error("Error number: %d", err);
658
jack_error("Error message: %s", Pa_GetErrorText(err));
663
/** free all memory allocated by a driver instance
666
portaudio_driver_delete (portaudio_driver_t *driver)
668
/* Close PortAudio stream and terminate */
669
Pa_CloseStream(driver->stream);
674
//== driver "plugin" interface =================================================
676
/* DRIVER "PLUGIN" INTERFACE */
679
driver_get_descriptor ()
681
jack_driver_desc_t * desc;
683
desc = calloc (1, sizeof (jack_driver_desc_t));
685
strcpy (desc->name, "portaudio");
687
desc->params = calloc (desc->nparams,
688
sizeof (jack_driver_param_desc_t));
691
strcpy (desc->params[i].name, "channel");
692
desc->params[i].character = 'c';
693
desc->params[i].type = JackDriverParamInt;
694
desc->params[i].value.ui = 0;
695
strcpy (desc->params[i].short_desc, "Maximum number of channels");
696
strcpy (desc->params[i].long_desc, desc->params[i].short_desc);
699
strcpy (desc->params[i].name, "channelin");
700
desc->params[i].character = 'i';
701
desc->params[i].type = JackDriverParamInt;
702
desc->params[i].value.ui = 0;
703
strcpy (desc->params[i].short_desc, "Maximum number of input channels");
704
strcpy (desc->params[i].long_desc, desc->params[i].short_desc);
707
strcpy (desc->params[i].name, "channelout");
708
desc->params[i].character = 'o';
709
desc->params[i].type = JackDriverParamInt;
710
desc->params[i].value.ui = 0;
711
strcpy (desc->params[i].short_desc, "Maximum number of ouput channels");
712
strcpy (desc->params[i].long_desc, desc->params[i].short_desc);
715
strcpy (desc->params[i].name, "capture");
716
desc->params[i].character = 'C';
717
desc->params[i].type = JackDriverParamBool;
718
desc->params[i].value.i = TRUE;
719
strcpy (desc->params[i].short_desc, "Whether or not to capture");
720
strcpy (desc->params[i].long_desc, desc->params[i].short_desc);
723
strcpy (desc->params[i].name, "playback");
724
desc->params[i].character = 'P';
725
desc->params[i].type = JackDriverParamBool;
726
desc->params[i].value.i = TRUE;
727
strcpy (desc->params[i].short_desc, "Whether or not to playback");
728
strcpy (desc->params[i].long_desc, desc->params[i].short_desc);
731
strcpy (desc->params[i].name, "duplex");
732
desc->params[i].character = 'D';
733
desc->params[i].type = JackDriverParamBool;
734
desc->params[i].value.i = TRUE;
735
strcpy (desc->params[i].short_desc, "Capture and playback");
736
strcpy (desc->params[i].long_desc, desc->params[i].short_desc);
739
strcpy (desc->params[i].name, "rate");
740
desc->params[i].character = 'r';
741
desc->params[i].type = JackDriverParamUInt;
742
desc->params[i].value.ui = 48000U;
743
strcpy (desc->params[i].short_desc, "Sample rate");
744
strcpy (desc->params[i].long_desc, desc->params[i].short_desc);
747
strcpy (desc->params[i].name, "period");
748
desc->params[i].character = 'p';
749
desc->params[i].type = JackDriverParamUInt;
750
desc->params[i].value.ui = 1024U;
751
strcpy (desc->params[i].short_desc, "Frames per period");
752
strcpy (desc->params[i].long_desc, desc->params[i].short_desc);
755
strcpy (desc->params[i].name, "name");
756
desc->params[i].character = 'n';
757
desc->params[i].type = JackDriverParamString;
758
desc->params[i].value.ui = 128U;
759
strcpy (desc->params[i].short_desc, "Driver name");
760
strcpy (desc->params[i].long_desc, desc->params[i].short_desc);
763
strcpy (desc->params[i].name, "dither");
764
desc->params[i].character = 'z';
765
desc->params[i].type = JackDriverParamChar;
766
desc->params[i].value.c = '-';
767
strcpy (desc->params[i].short_desc, "Dithering mode");
768
strcpy (desc->params[i].long_desc,
773
" - : no dithering");
778
const char driver_client_name[] = "portaudio";
781
driver_initialize (jack_client_t *client, const JSList * params)
783
jack_nframes_t srate = 48000;
784
jack_nframes_t frames_per_interrupt = 1024;
785
AudioDeviceID deviceID = 0;
787
int playback = FALSE;
790
DitherAlgorithm dither = None;
792
const jack_driver_param_t * param;
795
#ifdef JACK_USE_MACH_THREADS
796
get_device_id_from_num(0,&deviceID); // takes a default value (first device)
799
for (node = params; node; node = jack_slist_next (node)) {
800
param = (const jack_driver_param_t *) node->data;
802
switch (param->character) {
805
name = (char *) param->value.str;
806
PALog("Driver name found %s\n",name);
815
chan_in = (int) param->value.ui;
816
chan_out = (int) param->value.ui;
820
chan_in = (int) param->value.ui;
824
chan_out = (int) param->value.ui;
828
capture = param->value.i;
832
playback = param->value.i;
836
srate = param->value.ui;
840
frames_per_interrupt = (unsigned int) param->value.ui;
844
switch ((int) param->value.c) {
850
dither = Rectangular;
866
/* duplex is the default */
867
if (!capture && !playback) {
872
return portaudio_driver_new ("portaudio", client, frames_per_interrupt,
873
srate, capture, playback, chan_in,
874
chan_out, dither, name);
878
driver_finish (jack_driver_t *driver)
880
portaudio_driver_delete ((portaudio_driver_t *) driver);