From: ljsebald <ljs...@us...> - 2023-11-12 01:11:19
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via eadd3fb6bb7837e7eeec1d81f783f6a4b512a53b (commit) from a15cb4318f5db8f8283e77712ca6316943c502ad (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit eadd3fb6bb7837e7eeec1d81f783f6a4b512a53b Author: Andress Barajas <and...@gm...> Date: Sat Nov 11 09:45:04 2023 -0800 Sound effect number of samples warning (#354) * Added a warning when loading a sfx that is greater than 65534 samples ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/dc/sound/sfxmgr.h | 2 +- kernel/arch/dreamcast/sound/snd_sfxmgr.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h b/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h index 0af3a77..ee8f69e 100644 --- a/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h +++ b/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h @@ -32,7 +32,7 @@ __BEGIN_DECLS Each loaded sound effect will be assigned one of these, which is to be used for operations related to the effect, including playing it or unloading it. */ -typedef uint32 sfxhnd_t; +typedef uint32_t sfxhnd_t; /** \brief Invalid sound effect handle value. diff --git a/kernel/arch/dreamcast/sound/snd_sfxmgr.c b/kernel/arch/dreamcast/sound/snd_sfxmgr.c index ff838af..22f690c 100644 --- a/kernel/arch/dreamcast/sound/snd_sfxmgr.c +++ b/kernel/arch/dreamcast/sound/snd_sfxmgr.c @@ -167,7 +167,7 @@ static int read_wav_header(file_t fd, wavhdr_t *wavhdr) { return 0; } -static uint8_t* read_wav_data(file_t fd, wavhdr_t *wavhdr) { +static uint8_t *read_wav_data(file_t fd, wavhdr_t *wavhdr) { /* Allocate memory for WAV data */ uint8_t *wav_data = memalign(32, wavhdr->chunk.size); @@ -340,8 +340,9 @@ err_occurred: sfxhnd_t snd_sfx_load(const char *fn) { file_t fd; wavhdr_t wavhdr; - uint8_t *wav_data; snd_effect_t *effect; + uint8_t *wav_data; + uint32_t sample_count; dbglog(DBG_DEBUG, "snd_sfx: loading effect %s\n", fn); @@ -366,6 +367,14 @@ sfxhnd_t snd_sfx_load(const char *fn) { wavhdr.chunk.size, wavhdr.fmt.format); + sample_count = wavhdr.fmt.sample_size >= 8 + ? wavhdr.chunk.size / ((wavhdr.fmt.sample_size / 8) * wavhdr.fmt.channels) + : wavhdr.chunk.size / (0.5 * wavhdr.fmt.channels); + + if(sample_count > 65534) { + dbglog(DBG_WARNING, "WAVE file is over 65534 samples\n"); + } + /* Read WAV data */ wav_data = read_wav_data(fd, &wavhdr); fs_close(fd); @@ -388,7 +397,7 @@ sfxhnd_t snd_sfx_load(const char *fn) { int snd_sfx_play_chn(int chn, sfxhnd_t idx, int vol, int pan) { int size; - snd_effect_t * t = (snd_effect_t *)idx; + snd_effect_t *t = (snd_effect_t *)idx; AICA_CMDSTR_CHANNEL(tmp, cmd, chan); size = t->len; @@ -452,7 +461,7 @@ int snd_sfx_play(sfxhnd_t idx, int vol, int pan) { return -1; } else { - sfx_nextchan = (chn + 2) % 64; // in case of stereo + sfx_nextchan = (chn + 2) % 64; /* in case of stereo */ return snd_sfx_play_chn(chn, idx, vol, pan); } } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |