[PD-cvs] pd/src s_audio_alsa.c,1.5.4.5.2.2.2.9,1.5.4.5.2.2.2.10
Mathieu Bouchard
matju at users.sourceforge.net
Tue Jul 10 18:15:02 CEST 2007
- Previous message: [PD-cvs] pd/src s_audio_jack.c, 1.5.4.8.2.7.2.7, 1.5.4.8.2.7.2.8 s_audio_asio.cpp, 1.1.4.26.2.4.2.2, 1.1.4.26.2.4.2.3 s_stuff.h, 1.5.4.10.2.8.2.11, 1.5.4.10.2.8.2.12
- Next message: [PD-cvs] pd/src s_audio.c, 1.5.4.16.2.20.2.19, 1.5.4.16.2.20.2.20 s_stuff.h, 1.5.4.10.2.8.2.12, 1.5.4.10.2.8.2.13 s_main.c, 1.7.4.17.2.22.2.21, 1.7.4.17.2.22.2.22
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18240
Modified Files:
Tag: desiredata
s_audio_alsa.c
Log Message:
missing decl
Index: s_audio_alsa.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_alsa.c,v
retrieving revision 1.5.4.5.2.2.2.9
retrieving revision 1.5.4.5.2.2.2.10
diff -C2 -d -r1.5.4.5.2.2.2.9 -r1.5.4.5.2.2.2.10
*** s_audio_alsa.c 9 Jul 2007 19:59:42 -0000 1.5.4.5.2.2.2.9
--- s_audio_alsa.c 10 Jul 2007 16:15:00 -0000 1.5.4.5.2.2.2.10
***************
*** 40,43 ****
--- 40,44 ----
static void alsa_numbertoname(int iodev, char *devname, int nchar);
static int alsa_jittermax;
+ static void alsa_close_audio();
#define ALSA_DEFJITTERMAX 3
***************
*** 184,188 ****
int frag_size = (sys_blocksize ? sys_blocksize : ALSA_DEFFRAGSIZE);
int nfrags, i, iodev, dev2;
-
nfrags = int(sys_schedadvance * (float)rate / (1e6 * frag_size));
/* save our belief as to ALSA's buffer size for later */
--- 185,188 ----
***************
*** 190,196 ****
alsa_nindev = alsa_noutdev = 0;
alsa_jittermax = ALSA_DEFJITTERMAX;
-
if (sys_verbose) post("audio buffer set to %d", (int)(0.001 * sys_schedadvance));
-
for (iodev = 0; iodev < naudioindev; iodev++) {
alsa_numbertoname(audioindev[iodev], devname, 512);
--- 190,194 ----
***************
*** 216,222 ****
}
if (!alsa_nindev && !alsa_noutdev) goto blewit;
!
! /* If all the open devices support mmap_noninterleaved, let's call
! Wini's code in s_audio_alsamm.c */
alsa_usemmap = 1;
for (iodev = 0; iodev < alsa_nindev ; iodev++) if (!alsaio_canmmap(&alsa_indev [iodev])) alsa_usemmap = 0;
--- 214,218 ----
}
if (!alsa_nindev && !alsa_noutdev) goto blewit;
! /* If all the open devices support mmap_noninterleaved, let's call Wini's code in s_audio_alsamm.c */
alsa_usemmap = 1;
for (iodev = 0; iodev < alsa_nindev ; iodev++) if (!alsaio_canmmap(&alsa_indev [iodev])) alsa_usemmap = 0;
***************
*** 238,245 ****
if (!inchans && !outchans)
goto blewit;
-
for (iodev = 0; iodev < alsa_nindev ; iodev++) snd_pcm_prepare( alsa_indev[iodev].a_handle);
for (iodev = 0; iodev < alsa_noutdev; iodev++) snd_pcm_prepare(alsa_outdev[iodev].a_handle);
-
/* if duplex we can link the channels so they start together */
for (iodev = 0; iodev < alsa_nindev; iodev++) {
--- 234,239 ----
***************
*** 250,254 ****
}
}
-
/* allocate the status variables */
if (!alsa_status) {
--- 244,247 ----
***************
*** 256,263 ****
check_error(err, "snd_pcm_status_malloc");
}
-
/* fill the buffer with silence */
memset(alsa_snd_buf, 0, alsa_snd_bufsize);
-
if (outchans) {
i = (frag_size * nfrags)/sys_dacblocksize + 1;
--- 249,254 ----
***************
*** 268,273 ****
} else if (inchans) {
for (iodev = 0; iodev < alsa_nindev; iodev++)
! if ((err = snd_pcm_start(alsa_indev[iodev].a_handle)) < 0)
! check_error(err, "input start failed\n");
}
return 0;
--- 259,263 ----
} else if (inchans) {
for (iodev = 0; iodev < alsa_nindev; iodev++)
! if ((err = snd_pcm_start(alsa_indev[iodev].a_handle)) < 0) check_error(err, "input start failed\n");
}
return 0;
***************
*** 280,293 ****
void alsa_close_audio() {
! int err, iodev;
if (alsa_usemmap) {
alsamm_close_audio();
return;
}
! for (iodev = 0; iodev < alsa_nindev; iodev++) {
err = snd_pcm_close(alsa_indev[iodev].a_handle);
check_error(err, "snd_pcm_close (input)");
}
! for (iodev = 0; iodev < alsa_noutdev; iodev++) {
err = snd_pcm_close(alsa_outdev[iodev].a_handle);
check_error(err, "snd_pcm_close (output)");
--- 270,283 ----
void alsa_close_audio() {
! int err;
if (alsa_usemmap) {
alsamm_close_audio();
return;
}
! for (int iodev=0; iodev<alsa_nindev; iodev++) {
err = snd_pcm_close(alsa_indev[iodev].a_handle);
check_error(err, "snd_pcm_close (input)");
}
! for (int iodev=0; iodev<alsa_noutdev; iodev++) {
err = snd_pcm_close(alsa_outdev[iodev].a_handle);
check_error(err, "snd_pcm_close (output)");
***************
*** 307,311 ****
int chansintogo, chansouttogo;
unsigned int transfersize;
-
if (alsa_usemmap) return alsamm_send_dacs();
if (!alsa_nindev && !alsa_noutdev) return SENDDACS_NO;
--- 297,300 ----
***************
*** 315,337 ****
timelast = timenow;
timenow = sys_getrealtime();
-
#ifdef DEBUG_ALSA_XFER
if (timenow - timelast > 0.050) fprintf(stderr, "(%d)", int(1000 * (timenow - timelast))), fflush(stderr);
callno++;
#endif
-
alsa_checkiosync(); /* check I/O are in sync and data not late */
-
for (iodev = 0; iodev < alsa_nindev; iodev++) {
snd_pcm_status(alsa_indev[iodev].a_handle, alsa_status);
! if (snd_pcm_status_get_avail(alsa_status) < transfersize)
! return SENDDACS_NO;
}
for (iodev = 0; iodev < alsa_noutdev; iodev++) {
snd_pcm_status(alsa_outdev[iodev].a_handle, alsa_status);
! if (snd_pcm_status_get_avail(alsa_status) < transfersize)
! return SENDDACS_NO;
}
-
/* do output */
for (iodev = 0, fp1 = sys_soundout, ch = 0; iodev < alsa_noutdev; iodev++) {
--- 304,320 ----
timelast = timenow;
timenow = sys_getrealtime();
#ifdef DEBUG_ALSA_XFER
if (timenow - timelast > 0.050) fprintf(stderr, "(%d)", int(1000 * (timenow - timelast))), fflush(stderr);
callno++;
#endif
alsa_checkiosync(); /* check I/O are in sync and data not late */
for (iodev = 0; iodev < alsa_nindev; iodev++) {
snd_pcm_status(alsa_indev[iodev].a_handle, alsa_status);
! if (snd_pcm_status_get_avail(alsa_status) < transfersize) return SENDDACS_NO;
}
for (iodev = 0; iodev < alsa_noutdev; iodev++) {
snd_pcm_status(alsa_outdev[iodev].a_handle, alsa_status);
! if (snd_pcm_status_get_avail(alsa_status) < transfersize) return SENDDACS_NO;
}
/* do output */
for (iodev = 0, fp1 = sys_soundout, ch = 0; iodev < alsa_noutdev; iodev++) {
***************
*** 339,357 ****
int chans = (chansouttogo < thisdevchans ? chansouttogo : thisdevchans);
chansouttogo -= chans;
-
if (alsa_outdev[iodev].a_sampwidth == 4) {
for (i = 0; i < chans; i++, ch++, fp1 += sys_dacblocksize)
! for (j = ch, k = sys_dacblocksize, fp2 = fp1; k--;
! j += thisdevchans, fp2++) {
float s1 = *fp2 * INT32_MAX;
((t_alsa_sample32 *)alsa_snd_buf)[j] = CLIP32(int(s1));
}
for (; i < thisdevchans; i++, ch++)
! for (j = ch, k = sys_dacblocksize; k--; j += thisdevchans)
! ((t_alsa_sample32 *)alsa_snd_buf)[j] = 0;
} else {
for (i = 0; i < chans; i++, ch++, fp1 += sys_dacblocksize)
! for (j = ch, k = sys_dacblocksize, fp2 = fp1; k--;
! j += thisdevchans, fp2++) {
int s = int(*fp2 * 32767.);
if (s > 32767) s = 32767; else if (s < -32767) s = -32767;
--- 322,336 ----
int chans = (chansouttogo < thisdevchans ? chansouttogo : thisdevchans);
chansouttogo -= chans;
if (alsa_outdev[iodev].a_sampwidth == 4) {
for (i = 0; i < chans; i++, ch++, fp1 += sys_dacblocksize)
! for (j = ch, k = sys_dacblocksize, fp2 = fp1; k--; j += thisdevchans, fp2++) {
float s1 = *fp2 * INT32_MAX;
((t_alsa_sample32 *)alsa_snd_buf)[j] = CLIP32(int(s1));
}
for (; i < thisdevchans; i++, ch++)
! for (j = ch, k = sys_dacblocksize; k--; j += thisdevchans) ((t_alsa_sample32 *)alsa_snd_buf)[j] = 0;
} else {
for (i = 0; i < chans; i++, ch++, fp1 += sys_dacblocksize)
! for (j = ch, k = sys_dacblocksize, fp2 = fp1; k--; j += thisdevchans, fp2++) {
int s = int(*fp2 * 32767.);
if (s > 32767) s = 32767; else if (s < -32767) s = -32767;
***************
*** 359,367 ****
}
for (; i < thisdevchans; i++, ch++)
! for (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);
-
if (result != (int)transfersize) {
#ifdef DEBUG_ALSA_XFER
--- 338,344 ----
}
for (; i < thisdevchans; i++, ch++)
! for (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);
if (result != (int)transfersize) {
#ifdef DEBUG_ALSA_XFER
***************
*** 387,392 ****
}
}
!
! /* do input */
for (iodev = 0, fp1 = sys_soundin, ch = 0; iodev < alsa_nindev; iodev++) {
int thisdevchans = alsa_indev[iodev].a_channels;
--- 364,368 ----
}
}
! /* do input */
for (iodev = 0, fp1 = sys_soundin, ch = 0; iodev < alsa_nindev; iodev++) {
int thisdevchans = alsa_indev[iodev].a_channels;
***************
*** 537,541 ****
at a time, we just ask that the spread be not more than 3/4 of a block. */
if (maxphase <= minphase + (alsa_jittermax * (sys_dacblocksize / 4))) break;
-
if (!alreadylogged)
sys_log_error(ERR_RESYNC), alreadylogged = 1;
--- 513,516 ----
***************
*** 580,585 ****
static void alsa_numbertoname(int devno, char *devname, int nchar) {
int ndev = 0, cardno = -1;
! while (!snd_card_next(&cardno) && cardno >= 0)
! ndev++;
if (devno < 2*ndev) {
if (devno & 1) snprintf(devname, nchar, "plughw:%d", devno/2);
--- 555,559 ----
static void alsa_numbertoname(int devno, char *devname, int nchar) {
int ndev = 0, cardno = -1;
! while (!snd_card_next(&cardno) && cardno >= 0) ndev++;
if (devno < 2*ndev) {
if (devno & 1) snprintf(devname, nchar, "plughw:%d", devno/2);
- Previous message: [PD-cvs] pd/src s_audio_jack.c, 1.5.4.8.2.7.2.7, 1.5.4.8.2.7.2.8 s_audio_asio.cpp, 1.1.4.26.2.4.2.2, 1.1.4.26.2.4.2.3 s_stuff.h, 1.5.4.10.2.8.2.11, 1.5.4.10.2.8.2.12
- Next message: [PD-cvs] pd/src s_audio.c, 1.5.4.16.2.20.2.19, 1.5.4.16.2.20.2.20 s_stuff.h, 1.5.4.10.2.8.2.12, 1.5.4.10.2.8.2.13 s_main.c, 1.7.4.17.2.22.2.21, 1.7.4.17.2.22.2.22
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Pd-cvs
mailing list