From 881d4babce0b7284db1ccb1cb8a4c9606a687785 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 8 Sep 2011 18:10:09 +0900 Subject: [PATCH] Fix some undefined symbols in snd_alsa.c. Serves me right for testing with only my debug build :P --- include/snd_internal.h | 7 +++++-- libs/audio/renderer/snd_dma.c | 17 ++++++++--------- libs/audio/renderer/snd_jack.c | 9 +++------ libs/audio/renderer/snd_mix.c | 3 ++- libs/audio/targets/snd_alsa.c | 21 +++++++++------------ libs/audio/targets/snd_dx.c | 3 ++- libs/audio/targets/snd_sun.c | 3 ++- libs/audio/targets/snd_win.c | 3 ++- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/include/snd_internal.h b/include/snd_internal.h index 4ca22a502..be684f8e3 100644 --- a/include/snd_internal.h +++ b/include/snd_internal.h @@ -78,9 +78,12 @@ struct dma_s { int framepos; //!< position of dma cursor unsigned char *buffer; //!< destination for mixed sound /** Transfer mixed samples to the output. - \param endtime sample end time (count = endtime - snd_paintedtime) + \param paintbuffer The buffer of mixed samples to be transferred. + \param count The number of sample to transfer. + \param volume The gain for the samples. */ - void (*xfer) (int endtime); + void (*xfer) (portable_samplepair_t *paintbuffer, int count, + float volume); /** Optional data for the xfer function. */ void *xfer_data; diff --git a/libs/audio/renderer/snd_dma.c b/libs/audio/renderer/snd_dma.c index 5d95d3bcb..727664112 100644 --- a/libs/audio/renderer/snd_dma.c +++ b/libs/audio/renderer/snd_dma.c @@ -73,26 +73,25 @@ static general_data_t plugin_info_general_data; static snd_output_funcs_t *snd_output_funcs; static void -s_xfer_paint_buffer (int endtime) +s_xfer_paint_buffer (portable_samplepair_t *paintbuffer, int count, + float volume) { - int count, out_idx, out_max, step, val; - float snd_vol; + int out_idx, out_max, step, val; float *p; - p = (float *) snd_paintbuffer; - count = (endtime - snd_paintedtime) * snd_shm->channels; + p = (float *) paintbuffer; + count *= snd_shm->channels; out_max = (snd_shm->frames * snd_shm->channels) - 1; - out_idx = snd_paintedtime * snd_shm->channels; + out_idx = snd_shm->framepos * snd_shm->channels; while (out_idx > out_max) out_idx -= out_max + 1; step = 3 - snd_shm->channels; - snd_vol = snd_volume->value; if (snd_shm->samplebits == 16) { short *out = (short *) snd_shm->buffer; while (count--) { - val = (*p * snd_vol) * 0x8000; + val = (*p * volume) * 0x8000; p += step; if (val > 0x7fff) val = 0x7fff; @@ -106,7 +105,7 @@ s_xfer_paint_buffer (int endtime) unsigned char *out = (unsigned char *) snd_shm->buffer; while (count--) { - val = (*p * snd_vol) * 128; + val = (*p * volume) * 128; p += step; if (val > 0x7f) val = 0x7f; diff --git a/libs/audio/renderer/snd_jack.c b/libs/audio/renderer/snd_jack.c index 664c2e1fd..a0fe9cb5d 100644 --- a/libs/audio/renderer/snd_jack.c +++ b/libs/audio/renderer/snd_jack.c @@ -258,13 +258,10 @@ s_channel_stop (channel_t *chan) } static void -snd_jack_xfer (int endtime) +snd_jack_xfer (portable_samplepair_t *paintbuffer, int count, float volume) { int i; - int count; - float snd_vol = snd_volume->value; - count = endtime - snd_paintedtime; if (snd_blocked) { for (i = 0; i < count; i++) { *output[0]++ = 0; @@ -274,8 +271,8 @@ snd_jack_xfer (int endtime) } for (i = 0; i < count; i++) { /* max is +/- 1.0. need to implement clamping. */ - *output[0]++ = snd_vol * snd_paintbuffer[i].left; - *output[1]++ = snd_vol * snd_paintbuffer[i].right; + *output[0]++ = volume * snd_paintbuffer[i].left; + *output[1]++ = volume * snd_paintbuffer[i].right; } } diff --git a/libs/audio/renderer/snd_mix.c b/libs/audio/renderer/snd_mix.c index dbf347d12..e288ae9d8 100644 --- a/libs/audio/renderer/snd_mix.c +++ b/libs/audio/renderer/snd_mix.c @@ -174,7 +174,8 @@ SND_PaintChannels (unsigned endtime) } // transfer out according to DMA format - snd_shm->xfer (end); + snd_shm->xfer (snd_paintbuffer, end - snd_paintedtime, + snd_volume->value); memmove (snd_paintbuffer, snd_paintbuffer + end - snd_paintedtime, max_overpaint * sizeof (snd_paintbuffer[0])); diff --git a/libs/audio/targets/snd_alsa.c b/libs/audio/targets/snd_alsa.c index 5db3d9afe..e64c8b1d3 100644 --- a/libs/audio/targets/snd_alsa.c +++ b/libs/audio/targets/snd_alsa.c @@ -140,22 +140,19 @@ clamp_8 (int val) } static void -SNDDMA_ni_xfer (int endtime) +SNDDMA_ni_xfer (portable_samplepair_t *paintbuffer, int count, float volume) { const snd_pcm_channel_area_t *areas; - int count, out_idx, out_max; - float snd_vol; + int out_idx, out_max; float *p; areas = sn.xfer_data; - p = (float *) snd_paintbuffer; - count = (endtime - snd_paintedtime); + p = (float *) paintbuffer; out_max = sn.frames - 1; out_idx = sn.framepos; while (out_idx > out_max) out_idx -= out_max + 1; - snd_vol = snd_volume->value; if (sn.samplebits == 16) { short *out_0 = (short *) areas[0].addr; @@ -163,14 +160,14 @@ SNDDMA_ni_xfer (int endtime) if (sn.channels == 2) { while (count--) { - out_0[out_idx] = clamp_16 ((*p++ * snd_vol) * 0x8000); - out_1[out_idx] = clamp_16 ((*p++ * snd_vol) * 0x8000); + out_0[out_idx] = clamp_16 ((*p++ * volume) * 0x8000); + out_1[out_idx] = clamp_16 ((*p++ * volume) * 0x8000); if (out_idx++ > out_max) out_idx = 0; } } else { while (count--) { - out_0[out_idx] = clamp_16 ((*p++ * snd_vol) * 0x8000); + out_0[out_idx] = clamp_16 ((*p++ * volume) * 0x8000); p++; // skip right channel if (out_idx++ > out_max) out_idx = 0; @@ -182,14 +179,14 @@ SNDDMA_ni_xfer (int endtime) if (sn.channels == 2) { while (count--) { - out_0[out_idx] = clamp_8 ((*p++ * snd_vol) * 0x80); - out_1[out_idx] = clamp_8 ((*p++ * snd_vol) * 0x80); + out_0[out_idx] = clamp_8 ((*p++ * volume) * 0x80); + out_1[out_idx] = clamp_8 ((*p++ * volume) * 0x80); if (out_idx++ > out_max) out_idx = 0; } } else { while (count--) { - out_0[out_idx] = clamp_8 ((*p++ * snd_vol) * 0x8000); + out_0[out_idx] = clamp_8 ((*p++ * volume) * 0x8000); p++; // skip right channel if (out_idx++ > out_max) out_idx = 0; diff --git a/libs/audio/targets/snd_dx.c b/libs/audio/targets/snd_dx.c index 0d5721ded..87c8e19a6 100644 --- a/libs/audio/targets/snd_dx.c +++ b/libs/audio/targets/snd_dx.c @@ -406,8 +406,9 @@ SNDDMA_GetDMAPos (void) s /= sn.channels; s %= sn.frames; + sn.framepos = s; - return s; + return sn.framepos; } /* diff --git a/libs/audio/targets/snd_sun.c b/libs/audio/targets/snd_sun.c index 8400487ad..058bff065 100644 --- a/libs/audio/targets/snd_sun.c +++ b/libs/audio/targets/snd_sun.c @@ -171,7 +171,8 @@ SNDDMA_GetDMAPos (void) return (0); } - return ((info.play.samples * sn.channels) % sn.frames); + sn.framepos = ((info.play.samples * sn.channels) % sn.frames); + return sn.framepos; } #if 0 static int diff --git a/libs/audio/targets/snd_win.c b/libs/audio/targets/snd_win.c index df46dcab5..1c319f8f8 100644 --- a/libs/audio/targets/snd_win.c +++ b/libs/audio/targets/snd_win.c @@ -298,8 +298,9 @@ SNDDMA_GetDMAPos (void) s /= sn.channels; s %= sn.frames; + sn.framepos = s; - return s; + return sn.framepos; } /*