From 2adf24bbf23c144f2446816cc70910262bb4b5da Mon Sep 17 00:00:00 2001 From: "N.N." Date: Thu, 28 May 2009 01:30:22 +0000 Subject: reformat (rename variables) svn path=/trunk/; revision=11539 --- desiredata/src/s_audio_alsa.c | 197 ++++++++++++++++++++-------------------- desiredata/src/s_audio_alsa.h | 14 +-- desiredata/src/s_audio_alsamm.c | 112 +++++++++++------------ 3 files changed, 159 insertions(+), 164 deletions(-) (limited to 'desiredata') diff --git a/desiredata/src/s_audio_alsa.c b/desiredata/src/s_audio_alsa.c index 21119641..0271e440 100644 --- a/desiredata/src/s_audio_alsa.c +++ b/desiredata/src/s_audio_alsa.c @@ -9,7 +9,7 @@ #include -#include "m_pd.h" +#include "desire.h" #include "s_stuff.h" #include #include @@ -51,11 +51,7 @@ static int alsa_snd_bufsize; static int alsa_buf_samps; static snd_pcm_status_t *alsa_status; static int alsa_usemmap; - -t_alsa_dev alsa_indev[ALSA_MAXDEV]; -t_alsa_dev alsa_outdev[ALSA_MAXDEV]; -int alsa_nindev; -int alsa_noutdev; +t_alsa alsai,alsao; static void check_error(int err, const char *why) {if (err<0) error("%s: %s", why, snd_strerror(err));} @@ -177,57 +173,57 @@ int naudiooutdev, int *audiooutdev, int nchoutdev, int *choutdev, int rate, int nfrags = int(sys_schedadvance * (float)rate / (1e6 * frag_size)); /* save our belief as to ALSA's buffer size for later */ alsa_buf_samps = nfrags * frag_size; - alsa_nindev = alsa_noutdev = 0; + alsai.ndev = alsao.ndev = 0; alsa_jittermax = ALSA_DEFJITTERMAX; if (sys_verbose) post("audio buffer set to %d", (int)(0.001 * sys_schedadvance)); - for (int iodev=0; iodev 32767) s = 32767; else if (s < -32767) s = -32767; - ((t_alsa_sample16 *)alsa_snd_buf)[j] = s; + for (i=0; i 32767) s = 32767; else if (s < -32767) s = -32767; + ((t_alsa_sample16 *)alsa_snd_buf)[j] = s; + } } for (; i < thisdevchans; i++, ch++) - for (j = ch, k = sys_dacblocksize; k--; j += thisdevchans) ((t_alsa_sample16 *)alsa_snd_buf)[j] = 0; + for (int j = ch, k = sys_dacblocksize; k--; j += thisdevchans) ((t_alsa_sample16 *)alsa_snd_buf)[j] = 0; } - result = snd_pcm_writei(alsa_outdev[iodev].a_handle, alsa_snd_buf, transfersize); + result = snd_pcm_writei(alsao.dev[iodev].a_handle, alsa_snd_buf, transfersize); if (result != (int)transfersize) { #ifdef DEBUG_ALSA_XFER if (result >= 0 || errno == EAGAIN) post("ALSA: write returned %d of %d", result, transfersize); else error("ALSA: write: %s", snd_strerror(errno)); post("inputcount %d, outputcount %d, outbufsize %d", - inputcount, outputcount, (ALSA_EXTRABUFFER + sys_advance_samples) * alsa_outdev[iodev].a_sampwidth * outchannels); + inputcount, outputcount, (ALSA_EXTRABUFFER + sys_advance_samples) * alsao.dev[iodev].a_sampwidth * outchannels); #endif sys_log_error(ERR_DACSLEPT); return SENDDACS_NO; @@ -345,22 +346,22 @@ int alsa_send_dacs() { } } /* do input */ - for (iodev = 0, fp1 = sys_soundin, ch = 0; iodev < alsa_nindev; iodev++) { - int thisdevchans = alsa_indev[iodev].a_channels; + for (iodev = 0, fp1 = sys_soundin, ch = 0; iodev < alsai.ndev; iodev++) { + int thisdevchans = alsai.dev[iodev].a_channels; int chans = (chansintogo < thisdevchans ? chansintogo : thisdevchans); chansouttogo -= chans; - result = snd_pcm_readi(alsa_indev[iodev].a_handle, alsa_snd_buf, transfersize); + result = snd_pcm_readi(alsai.dev[iodev].a_handle, alsa_snd_buf, transfersize); if (result < (int)transfersize) { #ifdef DEBUG_ALSA_XFER if (result<0) error("snd_pcm_read %d %d: %s", callno, xferno, snd_strerror(errno)); else post("snd_pcm_read %d %d returned only %d", callno, xferno, result); post("inputcount %d, outputcount %d, inbufsize %d", - inputcount, outputcount, (ALSA_EXTRABUFFER + sys_advance_samples) * alsa_indev[iodev].a_sampwidth * inchannels); + inputcount, outputcount, (ALSA_EXTRABUFFER + sys_advance_samples) * alsai.dev[iodev].a_sampwidth * inchannels); #endif sys_log_error(ERR_ADCSLEPT); return SENDDACS_NO; } - if (alsa_indev[iodev].a_sampwidth == 4) { + if (alsai.dev[iodev].a_sampwidth == 4) { for (int i=0; i minphase + sys_dacblocksize) { - alsa_putzeros(iodev, 1); + alsa_putzeros(i,1); #if DEBUGSYNC post("putz %d %d", (int)thisphase, (int)minphase); #endif } } - for (int iodev=0; iodev minphase + sys_dacblocksize) { - alsa_getzeros(iodev, 1); + alsa_getzeros(i, 1); #if DEBUGSYNC post("getz %d %d", (int)thisphase, (int)minphase); #endif @@ -521,7 +522,7 @@ static void alsa_getdevs(char *indevlist, int *nindevs, char *outdevlist, int *n snd_ctl_card_info_t *info; char devname[80]; char *desc; - if (2 * ndev + 2 > maxndev) break; + if (2*ndev + 2 > maxndev) break; /* apparently, "cardno" is just a counter; but check that here */ if (ndev != cardno) post("oops: ALSA cards not reported in order?"); sprintf(devname, "hw:%d", cardno); @@ -542,7 +543,7 @@ static void alsa_getdevs(char *indevlist, int *nindevs, char *outdevlist, int *n ndev++; free(desc); } - for (i = 0, j = 2*ndev; i < alsa_nnames; i++, j++) { + for (i=0, j=2*ndev; i= maxndev) break; snprintf(indevlist + j * devdescsize, devdescsize, "%s", alsa_names[i]); } diff --git a/desiredata/src/s_audio_alsa.h b/desiredata/src/s_audio_alsa.h index 986bc1f5..4d67f78f 100644 --- a/desiredata/src/s_audio_alsa.h +++ b/desiredata/src/s_audio_alsa.h @@ -20,20 +20,20 @@ typedef int32_t t_alsa_sample32; #define INT32_MAX 0x7fffffff #endif -typedef struct _alsa_dev -{ +struct t_alsa_dev { snd_pcm_t *a_handle; int a_devno; int a_sampwidth; int a_channels; char **a_addr; int a_synced; -} t_alsa_dev; +}; -extern t_alsa_dev alsa_indev[ALSA_MAXDEV]; -extern t_alsa_dev alsa_outdev[ALSA_MAXDEV]; -extern int alsa_nindev; -extern int alsa_noutdev; +struct t_alsa { + t_alsa_dev dev[ALSA_MAXDEV]; + int ndev; +}; +extern t_alsa alsai, alsao; int alsamm_open_audio(int rate); void alsamm_close_audio(void); diff --git a/desiredata/src/s_audio_alsamm.c b/desiredata/src/s_audio_alsamm.c index 3a57691d..5ee76e3d 100644 --- a/desiredata/src/s_audio_alsamm.c +++ b/desiredata/src/s_audio_alsamm.c @@ -146,8 +146,8 @@ int alsamm_open_audio(int rate) { /* first have a look which cards we can get and set up device infos for them */ /* init some structures */ for(int i=0; ia_handle); if (err<0) {check_error(err,"outcard prepare error for playback"); return;} @@ -436,9 +435,9 @@ static void alsamm_start() { err = snd_pcm_start (dev->a_handle); if (err<0) check_error(err,"could not start playback"); } - for (int devno=0; devnoa_synced == 0) { err = snd_pcm_prepare (dev->a_handle); @@ -467,14 +466,12 @@ static void alsamm_start() { } static void alsamm_stop() { - for (int devno=0; devnoa_handle)); } - for (int devno=0; devnoa_handle)); } if (debug) show_availist(); @@ -529,8 +526,8 @@ int alsamm_send_dacs() { so we don't make a precheck of insamples here and let outsample check be the first of the first card. */ /* OUTPUT Transfer */ fpo = sys_soundout; - for(devno = 0;devno < alsa_noutdev;devno++) { - t_alsa_dev *dev = &alsa_outdev[devno]; + for(devno = 0;devno < alsao.ndev;devno++) { + t_alsa_dev *dev = &alsao.dev[devno]; snd_pcm_t *out = dev->a_handle; int ochannels =dev->a_channels; /* how much samples available ??? */ @@ -603,17 +600,14 @@ int alsamm_send_dacs() { fpo += ochannels*sys_dacblocksize; }/* for devno */ fpi = sys_soundin; /* star first card first channel */ - for(devno = 0;devno < alsa_nindev;devno++) { - t_alsa_dev *dev = &alsa_indev[devno]; + for(devno = 0;devno < alsai.ndev;devno++) { + t_alsa_dev *dev = &alsai.dev[devno]; snd_pcm_t *in = dev->a_handle; int ichannels = dev->a_channels; iavail = snd_pcm_avail_update(in); if (iavail < 0) { err = xrun_recovery(in, iavail); - if (err < 0) { - check_error(err,"input avail update failed"); - return SENDDACS_NO; - } + if (err < 0) {check_error(err,"input avail update failed"); return SENDDACS_NO;} iavail=snd_pcm_avail_update(in); } state = snd_pcm_state(in); @@ -664,7 +658,7 @@ int alsamm_send_dacs() { size -= iframes; } fpi += ichannels*sys_dacblocksize; - } /* for out devno < alsamm_outcards*/ + } /* for out devno < alsamm_outcards */ if ((timenow = sys_getrealtime()) > (timelast + sleep_time)) { if(debug && dac_send < 10 && sys_verbose) post("slept %f > %f + %f (=%f)", timenow,timelast,sleep_time,(timelast + sleep_time)); -- cgit v1.2.1