Commit 75da7c35 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

reverted 0.43 backport as its implementation seems unstable when trying to...

reverted 0.43 backport as its implementation seems unstable when trying to (re)connect to jack via audio properties. Fixed a bug where closing jack while having DAC on would hang pd.
parent 0233e4ed
...@@ -42,8 +42,8 @@ int pd_extern_sched(char *flags) ...@@ -42,8 +42,8 @@ int pd_extern_sched(char *flags)
t_binbuf *b = binbuf_new(); t_binbuf *b = binbuf_new();
sys_get_audio_params(&naudioindev, audioindev, chindev, sys_get_audio_params(&naudioindev, audioindev, chindev,
&naudiooutdev, audiooutdev, choutdev, &rate, &advance, &callback, &naudiooutdev, audiooutdev, choutdev, &rate, &advance, &callback); //,
&blocksize); // &blocksize);
chin = (naudioindev < 1 ? 0 : chindev[0]); chin = (naudioindev < 1 ? 0 : chindev[0]);
chout = (naudiooutdev < 1 ? 0 : choutdev[0]); chout = (naudiooutdev < 1 ? 0 : choutdev[0]);
......
...@@ -11,7 +11,7 @@ extern "C" { ...@@ -11,7 +11,7 @@ extern "C" {
#define PD_MAJOR_VERSION 0 #define PD_MAJOR_VERSION 0
#define PD_MINOR_VERSION 42 #define PD_MINOR_VERSION 42
#define PD_BUGFIX_VERSION 6 #define PD_BUGFIX_VERSION 6
#define PD_TEST_VERSION "extended-l2ork-20121005" #define PD_TEST_VERSION "extended-l2ork-20121007"
#define PDL2ORK #define PDL2ORK
/* old name for "MSW" flag -- we have to take it for the sake of many old /* old name for "MSW" flag -- we have to take it for the sake of many old
......
...@@ -6358,6 +6358,7 @@ proc pdtk_audio_dialog {id indev1 indev2 indev3 indev4 \ ...@@ -6358,6 +6358,7 @@ proc pdtk_audio_dialog {id indev1 indev2 indev3 indev4 \
set audio_sr $sr set audio_sr $sr
set audio_advance $advance set audio_advance $advance
set audio_callback $callback set audio_callback $callback
toplevel $id -class [winfo class .] toplevel $id -class [winfo class .]
match_linux_wm [list $id configure] match_linux_wm [list $id configure]
wm title $id {Audio Settings} wm title $id {Audio Settings}
...@@ -6389,6 +6390,7 @@ proc pdtk_audio_dialog {id indev1 indev2 indev3 indev4 \ ...@@ -6389,6 +6390,7 @@ proc pdtk_audio_dialog {id indev1 indev2 indev3 indev4 \
match_linux_wm [list label $id.srf.l2 -text "delay (msec):"] match_linux_wm [list label $id.srf.l2 -text "delay (msec):"]
match_linux_wm [list entry $id.srf.x2 -textvariable audio_advance -width 4] match_linux_wm [list entry $id.srf.x2 -textvariable audio_advance -width 4]
pack $id.srf.l1 $id.srf.x1 $id.srf.l2 $id.srf.x2 -side left -pady 3 pack $id.srf.l1 $id.srf.x1 $id.srf.l2 $id.srf.x2 -side left -pady 3
if {$audio_callback >= 0} { if {$audio_callback >= 0} {
match_linux_wm [list checkbutton $id.srf.x3 -variable audio_callback \ match_linux_wm [list checkbutton $id.srf.x3 -variable audio_callback \
-text {use callbacks} -anchor e] -text {use callbacks} -anchor e]
......
...@@ -6,21 +6,23 @@ ...@@ -6,21 +6,23 @@
audio settings from argparse routine and from dialog window. audio settings from argparse routine and from dialog window.
*/ */
#include "config.h"
#include "m_pd.h" #include "m_pd.h"
#include "s_stuff.h" #include "s_stuff.h"
#include <stdio.h> #include <stdio.h>
#ifdef _WIN32 #ifdef HAVE_UNISTD_H
#include <time.h>
#else
#include <unistd.h> #include <unistd.h>
/* XXX Hack!!! These should be checked for independently of unistd.h ... */
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#endif /* _WIN32 */ #endif
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#define SYS_DEFAULTCH 2 #define SYS_DEFAULTCH 2
#define SYS_MAXCH 100
typedef long t_pa_sample; typedef long t_pa_sample;
#define SYS_SAMPLEWIDTH sizeof(t_pa_sample) #define SYS_SAMPLEWIDTH sizeof(t_pa_sample)
#define SYS_BYTESPERCHAN (DEFDACBLKSIZE * SYS_SAMPLEWIDTH) #define SYS_BYTESPERCHAN (DEFDACBLKSIZE * SYS_SAMPLEWIDTH)
...@@ -38,6 +40,7 @@ static void audio_getdevs(char *indevlist, int *nindevs, ...@@ -38,6 +40,7 @@ static void audio_getdevs(char *indevlist, int *nindevs,
int sys_inchannels; int sys_inchannels;
int sys_outchannels; int sys_outchannels;
int sys_advance_samples; /* scheduler advance in samples */ int sys_advance_samples; /* scheduler advance in samples */
int sys_blocksize = 0; /* audio I/O block size in sample frames */
int sys_audioapi = API_DEFAULT; int sys_audioapi = API_DEFAULT;
int sys_audioapiopened = -1; /* save last API opened for later closing */ int sys_audioapiopened = -1; /* save last API opened for later closing */
static int sys_meters; /* true if we're metering */ static int sys_meters; /* true if we're metering */
...@@ -64,15 +67,19 @@ static int audio_naudiooutdev = -1; ...@@ -64,15 +67,19 @@ static int audio_naudiooutdev = -1;
static int audio_audiooutdev[MAXAUDIOOUTDEV]; static int audio_audiooutdev[MAXAUDIOOUTDEV];
static int audio_audiochoutdev[MAXAUDIOOUTDEV]; static int audio_audiochoutdev[MAXAUDIOOUTDEV];
static int audio_rate; static int audio_rate;
static int audio_advance = -1; static int audio_advance;
static int audio_callback; static int audio_callback;
static int audio_blocksize;
static int audio_callback_is_open; /* reflects true actual state */ static int audio_callback_is_open; /* reflects true actual state */
static int audio_nextinchans, audio_nextoutchans; static int audio_nextinchans, audio_nextoutchans;
void sched_audio_callbackfn(void); void sched_audio_callbackfn(void);
void sched_reopenmeplease(void); void sched_reopenmeplease(void);
#ifdef USEAPI_JACK
/* needed to fix srate when using jack, inclded in s_audio_jack.c */
extern int jack_get_srate(void);
#endif /* JACK */
static int audio_isopen(void) static int audio_isopen(void)
{ {
return (audio_state && return (audio_state &&
...@@ -83,7 +90,7 @@ static int audio_isopen(void) ...@@ -83,7 +90,7 @@ static int audio_isopen(void)
void sys_get_audio_params( void sys_get_audio_params(
int *pnaudioindev, int *paudioindev, int *chindev, int *pnaudioindev, int *paudioindev, int *chindev,
int *pnaudiooutdev, int *paudiooutdev, int *choutdev, int *pnaudiooutdev, int *paudiooutdev, int *choutdev,
int *prate, int *padvance, int *pcallback, int *pblocksize) int *prate, int *padvance, int *pcallback)
{ {
int i; int i;
*pnaudioindev = audio_naudioindev; *pnaudioindev = audio_naudioindev;
...@@ -93,17 +100,23 @@ void sys_get_audio_params( ...@@ -93,17 +100,23 @@ void sys_get_audio_params(
*pnaudiooutdev = audio_naudiooutdev; *pnaudiooutdev = audio_naudiooutdev;
for (i = 0; i < MAXAUDIOOUTDEV; i++) for (i = 0; i < MAXAUDIOOUTDEV; i++)
paudiooutdev[i] = audio_audiooutdev[i], paudiooutdev[i] = audio_audiooutdev[i],
choutdev[i] = audio_audiochoutdev[i]; choutdev[i] = audio_audiochoutdev[i];
#ifdef USEAPI_JACK
if (sys_audioapiopened == API_JACK) {
if (jack_get_srate()) {
audio_rate = jack_get_srate();
}
}
#endif /* JACK */
*prate = audio_rate; *prate = audio_rate;
*padvance = audio_advance; *padvance = audio_advance;
*pcallback = audio_callback; *pcallback = audio_callback;
*pblocksize = audio_blocksize;
} }
void sys_save_audio_params( void sys_save_audio_params(
int naudioindev, int *audioindev, int *chindev, int naudioindev, int *audioindev, int *chindev,
int naudiooutdev, int *audiooutdev, int *choutdev, int naudiooutdev, int *audiooutdev, int *choutdev,
int rate, int advance, int callback, int blocksize) int rate, int advance, int callback)
{ {
int i; int i;
audio_naudioindev = naudioindev; audio_naudioindev = naudioindev;
...@@ -117,7 +130,6 @@ void sys_save_audio_params( ...@@ -117,7 +130,6 @@ void sys_save_audio_params(
audio_rate = rate; audio_rate = rate;
audio_advance = advance; audio_advance = advance;
audio_callback = callback; audio_callback = callback;
audio_blocksize = blocksize;
} }
/* init routines for any API which needs to set stuff up before /* init routines for any API which needs to set stuff up before
...@@ -159,8 +171,8 @@ void sys_setchsr(int chin, int chout, int sr) ...@@ -159,8 +171,8 @@ void sys_setchsr(int chin, int chout, int sr)
sys_outchannels = chout; sys_outchannels = chout;
sys_dacsr = sr; sys_dacsr = sr;
sys_advance_samples = (sys_schedadvance * sys_dacsr) / (1000000.); sys_advance_samples = (sys_schedadvance * sys_dacsr) / (1000000.);
if (sys_advance_samples < DEFDACBLKSIZE) if (sys_advance_samples < 3 * DEFDACBLKSIZE)
sys_advance_samples = DEFDACBLKSIZE; sys_advance_samples = 3 * DEFDACBLKSIZE;
sys_soundin = (t_sample *)getbytes(inbytes); sys_soundin = (t_sample *)getbytes(inbytes);
memset(sys_soundin, 0, inbytes); memset(sys_soundin, 0, inbytes);
...@@ -183,7 +195,7 @@ void sys_setchsr(int chin, int chout, int sr) ...@@ -183,7 +195,7 @@ void sys_setchsr(int chin, int chout, int sr)
void sys_set_audio_settings(int naudioindev, int *audioindev, int nchindev, void sys_set_audio_settings(int naudioindev, int *audioindev, int nchindev,
int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev, int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
int *choutdev, int rate, int advance, int callback, int blocksize) int *choutdev, int rate, int advance, int callback)
{ {
int i, *ip; int i, *ip;
int defaultchannels = SYS_DEFAULTCH; int defaultchannels = SYS_DEFAULTCH;
...@@ -198,10 +210,8 @@ void sys_set_audio_settings(int naudioindev, int *audioindev, int nchindev, ...@@ -198,10 +210,8 @@ void sys_set_audio_settings(int naudioindev, int *audioindev, int nchindev,
if (rate < 1) if (rate < 1)
rate = DEFAULTSRATE; rate = DEFAULTSRATE;
if (advance < 0) if (advance <= 0)
advance = DEFAULTADVANCE; advance = DEFAULTADVANCE;
if (blocksize != (1 << ilog2(blocksize)) || blocksize < DEFDACBLKSIZE)
blocksize = DEFDACBLKSIZE;
audio_init(); audio_init();
/* Since the channel vector might be longer than the /* Since the channel vector might be longer than the
audio device vector, or vice versa, we fill the shorter one audio device vector, or vice versa, we fill the shorter one
...@@ -329,8 +339,7 @@ void sys_set_audio_settings(int naudioindev, int *audioindev, int nchindev, ...@@ -329,8 +339,7 @@ void sys_set_audio_settings(int naudioindev, int *audioindev, int nchindev,
audio_nextinchans = inchans; audio_nextinchans = inchans;
audio_nextoutchans = outchans; audio_nextoutchans = outchans;
sys_save_audio_params(nrealindev, realindev, realinchans, sys_save_audio_params(nrealindev, realindev, realinchans,
nrealoutdev, realoutdev, realoutchans, rate, advance, callback, nrealoutdev, realoutdev, realoutchans, rate, advance, callback);
blocksize);
} }
void sys_close_audio(void) void sys_close_audio(void)
...@@ -365,21 +374,6 @@ void sys_close_audio(void) ...@@ -365,21 +374,6 @@ void sys_close_audio(void)
if (sys_audioapiopened == API_MMIO) if (sys_audioapiopened == API_MMIO)
mmio_close_audio(); mmio_close_audio();
else else
#endif
#ifdef USEAPI_AUDIOUNIT
if (sys_audioapiopened == API_AUDIOUNIT)
audiounit_close_audio();
else
#endif
#ifdef USEAPI_ESD
if (sys_audioapiopened == API_ESD)
esd_close_audio();
else
#endif
#ifdef USEAPI_DUMMY
if (sys_audioapiopened == API_DUMMY)
dummy_close_audio();
else
#endif #endif
post("sys_close_audio: unknown API %d", sys_audioapiopened); post("sys_close_audio: unknown API %d", sys_audioapiopened);
sys_inchannels = sys_outchannels = 0; sys_inchannels = sys_outchannels = 0;
...@@ -387,8 +381,6 @@ void sys_close_audio(void) ...@@ -387,8 +381,6 @@ void sys_close_audio(void)
sched_set_using_audio(SCHED_AUDIO_NONE); sched_set_using_audio(SCHED_AUDIO_NONE);
audio_state = 0; audio_state = 0;
audio_callback_is_open = 0; audio_callback_is_open = 0;
sys_vgui("set pd_whichapi 0\n");
} }
/* open audio using whatever parameters were last used */ /* open audio using whatever parameters were last used */
...@@ -396,10 +388,9 @@ void sys_reopen_audio( void) ...@@ -396,10 +388,9 @@ void sys_reopen_audio( void)
{ {
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV]; int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
int rate, advance, callback, blocksize, outcome = 0; int rate, advance, callback, outcome = 0;
sys_get_audio_params(&naudioindev, audioindev, chindev, sys_get_audio_params(&naudioindev, audioindev, chindev,
&naudiooutdev, audiooutdev, choutdev, &rate, &advance, &callback, &naudiooutdev, audiooutdev, choutdev, &rate, &advance, &callback);
&blocksize);
sys_setchsr(audio_nextinchans, audio_nextoutchans, rate); sys_setchsr(audio_nextinchans, audio_nextoutchans, rate);
if (!naudioindev && !naudiooutdev) if (!naudioindev && !naudiooutdev)
{ {
...@@ -409,9 +400,7 @@ void sys_reopen_audio( void) ...@@ -409,9 +400,7 @@ void sys_reopen_audio( void)
#ifdef USEAPI_PORTAUDIO #ifdef USEAPI_PORTAUDIO
if (sys_audioapi == API_PORTAUDIO) if (sys_audioapi == API_PORTAUDIO)
{ {
int blksize = (audio_blocksize ? audio_blocksize : 64); int blksize = (sys_blocksize ? sys_blocksize : 64);
if (sys_verbose)
fprintf(stderr, "blksize %d, advance %d\n", blksize, sys_advance_samples/blksize);
outcome = pa_open_audio((naudioindev > 0 ? chindev[0] : 0), outcome = pa_open_audio((naudioindev > 0 ? chindev[0] : 0),
(naudiooutdev > 0 ? choutdev[0] : 0), rate, sys_soundin, (naudiooutdev > 0 ? choutdev[0] : 0), rate, sys_soundin,
sys_soundout, blksize, sys_advance_samples/blksize, sys_soundout, blksize, sys_advance_samples/blksize,
...@@ -424,16 +413,14 @@ void sys_reopen_audio( void) ...@@ -424,16 +413,14 @@ void sys_reopen_audio( void)
#ifdef USEAPI_JACK #ifdef USEAPI_JACK
if (sys_audioapi == API_JACK) if (sys_audioapi == API_JACK)
outcome = jack_open_audio((naudioindev > 0 ? chindev[0] : 0), outcome = jack_open_audio((naudioindev > 0 ? chindev[0] : 0),
(naudioindev > 0 ? choutdev[0] : 0), rate, (naudioindev > 0 ? choutdev[0] : 0), rate);
(callback ? sched_audio_callbackfn : 0));
else else
#endif #endif
#ifdef USEAPI_OSS #ifdef USEAPI_OSS
if (sys_audioapi == API_OSS) if (sys_audioapi == API_OSS)
outcome = oss_open_audio(naudioindev, audioindev, naudioindev, outcome = oss_open_audio(naudioindev, audioindev, naudioindev,
chindev, naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, chindev, naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate);
audio_blocksize);
else else
#endif #endif
#ifdef USEAPI_ALSA #ifdef USEAPI_ALSA
...@@ -441,32 +428,13 @@ void sys_reopen_audio( void) ...@@ -441,32 +428,13 @@ void sys_reopen_audio( void)
be open for both input and output. */ be open for both input and output. */
if (sys_audioapi == API_ALSA) if (sys_audioapi == API_ALSA)
outcome = alsa_open_audio(naudioindev, audioindev, naudioindev, outcome = alsa_open_audio(naudioindev, audioindev, naudioindev,
chindev, naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, chindev, naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate);
audio_blocksize);
else else
#endif #endif
#ifdef USEAPI_MMIO #ifdef USEAPI_MMIO
if (sys_audioapi == API_MMIO) if (sys_audioapi == API_MMIO)
outcome = mmio_open_audio(naudioindev, audioindev, naudioindev, outcome = mmio_open_audio(naudioindev, audioindev, naudioindev,
chindev, naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate,
audio_blocksize);
else
#endif
#ifdef USEAPI_AUDIOUNIT
if (sys_audioapi == API_AUDIOUNIT)
outcome = audiounit_open_audio((naudioindev > 0 ? chindev[0] : 0),
(naudioindev > 0 ? choutdev[0] : 0), rate);
else
#endif
#ifdef USEAPI_ESD
if (sys_audioapi == API_ALSA)
outcome = esd_open_audio(naudioindev, audioindev, naudioindev,
chindev, naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate); chindev, naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate);
else
#endif
#ifdef USEAPI_DUMMY
if (sys_audioapi == API_DUMMY)
outcome = dummy_open_audio(naudioindev, naudiooutdev, rate);
else else
#endif #endif
if (sys_audioapi == API_NONE) if (sys_audioapi == API_NONE)
...@@ -539,21 +507,6 @@ int sys_send_dacs(void) ...@@ -539,21 +507,6 @@ int sys_send_dacs(void)
if (sys_audioapi == API_MMIO) if (sys_audioapi == API_MMIO)
return (mmio_send_dacs()); return (mmio_send_dacs());
else else
#endif
#ifdef USEAPI_AUDIOUNIT
if (sys_audioapi == API_AUDIOUNIT)
return (audiounit_send_dacs());
else
#endif
#ifdef USEAPI_ESD
if (sys_audioapi == API_ESD)
return (esd_send_dacs());
else
#endif
#ifdef USEAPI_DUMMY
if (sys_audioapi == API_DUMMY)
return (dummy_send_dacs());
else
#endif #endif
post("unknown API"); post("unknown API");
return (0); return (0);
...@@ -611,7 +564,6 @@ static void audio_getdevs(char *indevlist, int *nindevs, ...@@ -611,7 +564,6 @@ static void audio_getdevs(char *indevlist, int *nindevs,
{ {
jack_getdevs(indevlist, nindevs, outdevlist, noutdevs, canmulti, jack_getdevs(indevlist, nindevs, outdevlist, noutdevs, canmulti,
maxndev, devdescsize); maxndev, devdescsize);
*cancallback = 1;
} }
else else
#endif #endif
...@@ -638,28 +590,6 @@ static void audio_getdevs(char *indevlist, int *nindevs, ...@@ -638,28 +590,6 @@ static void audio_getdevs(char *indevlist, int *nindevs,
maxndev, devdescsize); maxndev, devdescsize);
} }
else else
#endif
#ifdef USEAPI_AUDIOUNIT
if (sys_audioapi == API_AUDIOUNIT)
{
}
else
#endif
#ifdef USEAPI_ESD
if (sys_audioapi == API_ESD)
{
esd_getdevs(indevlist, nindevs, outdevlist, noutdevs, canmulti,
maxndev, devdescsize);
}
else
#endif
#ifdef USEAPI_DUMMY
if (sys_audioapi == API_DUMMY)
{
dummy_getdevs(indevlist, nindevs, outdevlist, noutdevs, canmulti,
maxndev, devdescsize);
}
else
#endif #endif
{ {
/* this shouldn't happen once all the above get filled in. */ /* this shouldn't happen once all the above get filled in. */
...@@ -720,7 +650,7 @@ void glob_audio_properties(t_pd *dummy, t_floatarg flongform) ...@@ -720,7 +650,7 @@ void glob_audio_properties(t_pd *dummy, t_floatarg flongform)
audioinchan1, audioinchan2, audioinchan3, audioinchan4, audioinchan1, audioinchan2, audioinchan3, audioinchan4,
audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4, audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4,
audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4; audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4;
int rate, advance, callback, blocksize; int rate, advance, callback;
/* these are all the devices on your system: */ /* these are all the devices on your system: */
char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE]; char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
int nindevs = 0, noutdevs = 0, canmulti = 0, cancallback = 0, i; int nindevs = 0, noutdevs = 0, canmulti = 0, cancallback = 0, i;
...@@ -739,8 +669,13 @@ void glob_audio_properties(t_pd *dummy, t_floatarg flongform) ...@@ -739,8 +669,13 @@ void glob_audio_properties(t_pd *dummy, t_floatarg flongform)
outdevlist + i * DEVDESCSIZE); outdevlist + i * DEVDESCSIZE);
sys_get_audio_params(&naudioindev, audioindev, chindev, sys_get_audio_params(&naudioindev, audioindev, chindev,
&naudiooutdev, audiooutdev, choutdev, &rate, &advance, &callback, &naudiooutdev, audiooutdev, choutdev, &rate, &advance, &callback);
&blocksize);
#ifdef USEAPI_JACK
if (sys_audioapiopened == API_JACK) {
sys_setchsr(audio_nextinchans, audio_nextoutchans, rate);
}
#endif /* JACK */
/* post("naudioindev %d naudiooutdev %d longform %f", /* post("naudioindev %d naudiooutdev %d longform %f",
naudioindev, naudiooutdev, flongform); */ naudioindev, naudiooutdev, flongform); */
...@@ -767,13 +702,13 @@ void glob_audio_properties(t_pd *dummy, t_floatarg flongform) ...@@ -767,13 +702,13 @@ void glob_audio_properties(t_pd *dummy, t_floatarg flongform)
"pdtk_audio_dialog %%s \ "pdtk_audio_dialog %%s \
%d %d %d %d %d %d %d %d \ %d %d %d %d %d %d %d %d \
%d %d %d %d %d %d %d %d \ %d %d %d %d %d %d %d %d \
%d %d %d %d %d %d\n", %d %d %d %d %d\n",
audioindev1, audioindev2, audioindev3, audioindev4, audioindev1, audioindev2, audioindev3, audioindev4,
audioinchan1, audioinchan2, audioinchan3, audioinchan4, audioinchan1, audioinchan2, audioinchan3, audioinchan4,
audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4, audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4,
audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4, audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4,
rate, advance, canmulti, (cancallback ? callback : -1), rate, advance, canmulti, (cancallback ? callback : -1),
(flongform != 0), blocksize); (flongform != 0));
gfxstub_deleteforkey(0); gfxstub_deleteforkey(0);
gfxstub_new(&glob_pdobject, (void *)glob_audio_properties, buf); gfxstub_new(&glob_pdobject, (void *)glob_audio_properties, buf);
} }
...@@ -792,7 +727,6 @@ void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv) ...@@ -792,7 +727,6 @@ void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
int newrate = atom_getintarg(16, argc, argv); int newrate = atom_getintarg(16, argc, argv);
int newadvance = atom_getintarg(17, argc, argv); int newadvance = atom_getintarg(17, argc, argv);
int newcallback = atom_getintarg(18, argc, argv); int newcallback = atom_getintarg(18, argc, argv);
int newblocksize = atom_getintarg(19, argc, argv);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
...@@ -825,27 +759,14 @@ void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv) ...@@ -825,27 +759,14 @@ void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
} }
} }
sys_set_audio_settings_reopen(nindev, newaudioindev, nindev, newaudioinchan, if (newcallback < 0)
noutdev, newaudiooutdev, noutdev, newaudiooutchan, newcallback = 0;
newrate, newadvance, newcallback, newblocksize); if (!audio_callback_is_open && !newcallback)
}
void sys_set_audio_settings_reopen(int naudioindev, int *audioindev, int nchindev,
int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
int *choutdev, int rate, int advance, int callback, int newblocksize)
{
if (callback < 0)
callback = 0;
if (newblocksize != (1<<ilog2(newblocksize)) ||
newblocksize < DEFDACBLKSIZE || newblocksize > 2048)
newblocksize = DEFDACBLKSIZE;
if (!audio_callback_is_open && !callback)
sys_close_audio(); sys_close_audio();
sys_set_audio_settings(naudioindev, audioindev, nchindev, chindev, sys_set_audio_settings(nindev, newaudioindev, nindev, newaudioinchan,
naudiooutdev, audiooutdev, nchoutdev, choutdev, noutdev, newaudiooutdev, noutdev, newaudiooutchan,
rate, advance, (callback >= 0 ? callback : 0), newblocksize); newrate, newadvance, (newcallback >= 0 ? newcallback : 0));
if (!audio_callback_is_open && !callback) if (!audio_callback_is_open && !newcallback)
sys_reopen_audio(); sys_reopen_audio();
else sched_reopenmeplease(); else sched_reopenmeplease();
} }
...@@ -876,35 +797,20 @@ void sys_listdevs(void ) ...@@ -876,35 +797,20 @@ void sys_listdevs(void )
if (sys_audioapi == API_MMIO) if (sys_audioapi == API_MMIO)
sys_listaudiodevs(); sys_listaudiodevs();
else else
#endif
#ifdef USEAPI_AUDIOUNIT
if (sys_audioapi == API_AUDIOUNIT)
sys_listaudiodevs();
else
#endif
#ifdef USEAPI_ESD
if (sys_audioapi == API_ESD)
sys_listaudiodevs();
else
#endif
#ifdef USEAPI_DUMMY
if (sys_audioapi == API_DUMMY)
sys_listaudiodevs();
else
#endif #endif
post("unknown API"); post("unknown API");
sys_listmididevs(); sys_listmididevs();
} }
void sys_get_audio_devs(char *indevlist, int *nindevs, void sys_setblocksize(int n)
char *outdevlist, int *noutdevs, int *canmulti, int *cancallback,
int maxndev, int devdescsize)
{ {
audio_getdevs(indevlist, nindevs, if (n < 1)