revision 1089:a3984d242909
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 1089:a3984d242909 |
parent | 1088:cf3900ae8acc |
child | 1090:71e28626b358 |
author | nkeynes |
date | Mon Dec 07 08:59:50 2009 +1000 (14 years ago) |
Mask audio RAM accesses from the mixer to ensure they're in bounds. Uncertain if
this is correct (vs eg zero-fill), but it's at least consistent with the masking
of the channel start position.
this is correct (vs eg zero-fill), but it's at least consistent with the masking
of the channel start position.
src/aica/audio.c | view | annotate | diff | log | ||
src/aica/audio.h | view | annotate | diff | log |
1.1 --- a/src/aica/audio.c Fri Dec 04 18:06:12 2009 +10001.2 +++ b/src/aica/audio.c Mon Dec 07 08:59:50 2009 +10001.3 @@ -328,7 +328,7 @@1.4 switch( channel->sample_format ) {1.5 case AUDIO_FMT_16BIT:1.6 for( j=0; j<num_samples; j++ ) {1.7 - sample = ((int16_t *)(aica_main_ram + channel->start))[channel->posn];1.8 + sample = *(int16_t *)(aica_main_ram + ((channel->start + channel->posn*2)&AUDIO_MEM_MASK));1.9 result_buf[j][0] += sample * vol_left;1.10 result_buf[j][1] += sample * vol_right;1.12 @@ -352,7 +352,7 @@1.13 break;1.14 case AUDIO_FMT_8BIT:1.15 for( j=0; j<num_samples; j++ ) {1.16 - sample = ((int8_t *)(aica_main_ram + channel->start))[channel->posn] << 8;1.17 + sample = (*(int8_t *)(aica_main_ram + ((channel->start + channel->posn)&AUDIO_MEM_MASK))) << 8;1.18 result_buf[j][0] += sample * vol_left;1.19 result_buf[j][1] += sample * vol_right;1.21 @@ -395,7 +395,7 @@1.22 break;1.23 }1.24 }1.25 - uint8_t data = ((uint8_t *)(aica_main_ram + channel->start))[channel->posn>>1];1.26 + uint8_t data = *(uint8_t *)(aica_main_ram + ((channel->start + (channel->posn>>1))&AUDIO_MEM_MASK));1.27 if( channel->posn&1 ) {1.28 adpcm_yamaha_decode_nibble( channel, (data >> 4) & 0x0F );1.29 } else {
2.1 --- a/src/aica/audio.h Fri Dec 04 18:06:12 2009 +10002.2 +++ b/src/aica/audio.h Mon Dec 07 08:59:50 2009 +10002.3 @@ -43,6 +43,7 @@2.5 #define AUDIO_FMT_16ST (AUDIO_FMT_16BIT|AUDIO_FMT_STEREO)2.6 #define AUDIO_FMT_FLOATST (AUDIO_FMT_FLOAT|AUDIO_FMT_STEREO)2.7 +#define AUDIO_MEM_MASK 0x1FFFFF2.9 #define DEFAULT_SAMPLE_RATE 441002.10 #define DEFAULT_SAMPLE_FORMAT AUDIO_FMT_16ST
.