From f15f8d5f6c0546c9bbba402a83ef3d6d6e39601d Mon Sep 17 00:00:00 2001 From: "N.N." Date: Sat, 30 May 2009 05:09:57 +0000 Subject: reformat svn path=/trunk/; revision=11582 --- desiredata/src/s_audio.c | 108 ++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 67 deletions(-) diff --git a/desiredata/src/s_audio.c b/desiredata/src/s_audio.c index 6839bb5f..2b5072b6 100644 --- a/desiredata/src/s_audio.c +++ b/desiredata/src/s_audio.c @@ -80,9 +80,9 @@ int sys_audioapi = API_DEFAULT; int sys_dacblocksize; int sys_schedblocksize; int sys_meters; /* true if we're metering */ -static float sys_inmax; /* max input amplitude */ -static float sys_outmax; /* max output amplitude */ -int sys_schedadvance; /* scheduler advance in microseconds */ +static float sys_inmax; /* max input amplitude */ +static float sys_outmax; /* max output amplitude */ +int sys_schedadvance; /* scheduler advance in microseconds */ /* the "state" is normally one if we're open and zero otherwise; but if the state is one, we still haven't necessarily opened the audio hardware; see audio_isopen() below. */ @@ -104,8 +104,8 @@ static float (*peak_fp)(t_float*, t_int, t_float) = peakvec; static int audio_isopen() {return audio_state && ((audi.ndev > 0 && audi.chdev[0] > 0) || (audo.ndev > 0 && audo.chdev[0] > 0));} extern "C" void sys_get_audio_params(t_audiodevs *ai, t_audiodevs *ao, int *prate, int *pdacblocksize, int *padvance, int *pscheduler) { - ai->ndev=audi.ndev; for (int i=0; i< MAXAUDIOINDEV; i++) {ai->dev[i] = audi.dev[i]; ai->chdev[i]=audi.chdev[i];} - ao->ndev=audo.ndev; for (int i=0; idev[i] = audo.dev[i]; ao->chdev[i]=audo.chdev[i];} + ai->ndev=audi.ndev; for (int i=0; i< MAXAUDIOINDEV; i++) {ai->dev[i]=audi.dev[i]; ai->chdev[i]=audi.chdev[i];} + ao->ndev=audo.ndev; for (int i=0; idev[i]=audo.dev[i]; ao->chdev[i]=audo.chdev[i];} *prate = audio_rate; *pdacblocksize = audio_dacblocksize; *padvance = audio_advance; @@ -113,12 +113,12 @@ extern "C" void sys_get_audio_params(t_audiodevs *ai, t_audiodevs *ao, int *prat } void sys_save_audio_params( -int nindev, int *indev, int *chindev, -int noutdev, int *outdev, int *choutdev, int rate, int dacblocksize, int advance, int scheduler) { - audi.ndev = nindev; - audo.ndev = noutdev; - for (int i=0; i= 1) { - nchindev=1; chindev[0]=defaultchannels; - nindev=1; indev[0]=DEFAULTAUDIODEV; - } else nindev = nchindev = 0; - } else { - for (int i=0; i= 1) {nidev=nichdev=1; ichdev[0]=defaultchannels; idev[0]=DEFAULTAUDIODEV;} else nidev = nichdev=0; + } else for (int i=0; i nindev) { - for (int i=nindev; i nidev) {for (int i=nidev; i= 1) { - nchoutdev=1; choutdev[0]=defaultchannels; - noutdev=1; outdev[0]=DEFAULTAUDIODEV; - } else nchoutdev = noutdev = 0; - } else { - for (int i=0; i= 1) {nodev=nochdev=1; ochdev[0]=defaultchannels; odev[0]=DEFAULTAUDIODEV;} else nodev = nochdev=0; + } else for (int i=0; i noutdev) { - for (int i=noutdev; i nodev) {for (int i=nodev; i 0 ? chindev[i] : 0)); - for (int i=0; i < noutdev; i++) outchans += (realoutchans[i] = (choutdev[i] > 0 ? choutdev[i] : 0)); + for (int i=0; i 0 ? ichdev[i] : 0)); + for (int i=0; i 0 ? ochdev[i] : 0)); /* if no input or output devices seem to have been specified, this really means just disable audio, which we now do. */ if (!inchans && !outchans) enable = 0; sys_schedadvance = advance * 1000; @@ -249,24 +226,21 @@ int *choutdev, int rate, int dacblocksize, int advance, int schedmode, int enabl /* for alsa, only one device is supported; it may be open for both input and output. */ #ifdef USEAPI_PORTAUDIO if (sys_audioapi == API_PORTAUDIO) - pa_open_audio(inchans, outchans, rate, advance, - (noutdev > 0 ? indev[0] : 0), - (noutdev > 0 ? outdev[0] : 0), schedmode); + pa_open_audio(inchans, outchans, rate, advance, (nodev>0?idev[0]:0), (nodev>0?odev[0]:0), schedmode); else #endif #ifdef USEAPI_JACK if (sys_audioapi == API_JACK) - jack_open_audio((nindev > 0 ? realinchans[0] : 0), - (noutdev > 0 ? realoutchans[0] : 0), rate, schedmode); + jack_open_audio((nidev>0?realich[0]:0), (nodev>0?realoch[0]:0), rate, schedmode); else #endif if (sys_audioapi == API_OSS || sys_audioapi == API_ALSA || sys_audioapi == API_MMIO) - sys_audio()->open_audio(nindev, indev, nchindev, realinchans, noutdev, outdev, nchoutdev, realoutchans, rate, -42); + sys_audio()->open_audio(nidev, idev, nichdev, realich, nodev, odev, nochdev, realoch, rate, -42); else if (sys_audioapi == API_ASIO) - sys_audio()->open_audio(nindev, indev, nchindev, chindev, noutdev, outdev, nchoutdev, choutdev, rate, schedmode); + sys_audio()->open_audio(nidev, idev, nichdev, ichdev, nodev, odev, nochdev, ochdev, rate, schedmode); else post("unknown audio API specified"); } - sys_save_audio_params(nindev, indev, chindev, noutdev, outdev, choutdev, int(sys_dacsr), sys_dacblocksize, advance, schedmode); + sys_save_audio_params(nidev, idev, ichdev, nodev, odev, ochdev, int(sys_dacsr), sys_dacblocksize, advance, schedmode); if (sys_inchannels == 0 && sys_outchannels == 0) enable = 0; audio_state = enable; sys_vgui("set pd_whichapi %d\n", audio_isopen() ? sys_audioapi : 0); @@ -305,7 +279,7 @@ void sys_reopen_audio() { float peakvec(t_float* vec, t_int n, t_float cur_max) { for (int i=0; i cur_max) cur_max = f; + if (+f > cur_max) cur_max = +f; else if (-f > cur_max) cur_max = -f; } return cur_max; -- cgit v1.2.1