From 40c723df79703d7ce3de5a3037d138374d267606 Mon Sep 17 00:00:00 2001 From: vspader Date: Sun, 1 Mar 2009 11:00:46 -0800 Subject: [PATCH] Fixed issues with dreamcast dsf playback. --- Frameworks/AudioOverload/aosdk/eng_dsf/aica.c | 2 ++ .../AudioOverload/aosdk/eng_dsf/dc_hw.c | 7 ++++--- .../AudioOverload/aosdk/eng_dsf/eng_dsf.c | 5 +++++ .../AudioOverload/aosdk/eng_qsf/eng_qsf.c | 4 +++- Plugins/AudioOverload/AODecoder.m | 20 +++++++++++++++---- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Frameworks/AudioOverload/aosdk/eng_dsf/aica.c b/Frameworks/AudioOverload/aosdk/eng_dsf/aica.c index b1dff8901..a9b5e37c9 100644 --- a/Frameworks/AudioOverload/aosdk/eng_dsf/aica.c +++ b/Frameworks/AudioOverload/aosdk/eng_dsf/aica.c @@ -1226,6 +1226,8 @@ void *aica_start(const void *config) void aica_stop(void) { + free(AllocedAICA->buffertmpl); + free(AllocedAICA->buffertmpr); free(AllocedAICA); } diff --git a/Frameworks/AudioOverload/aosdk/eng_dsf/dc_hw.c b/Frameworks/AudioOverload/aosdk/eng_dsf/dc_hw.c index d6b10548e..a82df3931 100644 --- a/Frameworks/AudioOverload/aosdk/eng_dsf/dc_hw.c +++ b/Frameworks/AudioOverload/aosdk/eng_dsf/dc_hw.c @@ -39,13 +39,13 @@ static void aica_irq(int irq) #define MIXER(level,pan) ((level & 0xff) | ((pan & 0x03) << 8)) #define YM3012_VOL(LVol,LPan,RVol,RPan) (MIXER(LVol,LPan)|(MIXER(RVol,RPan) << 16)) -static struct AICAinterface aica_interface = -{ +static struct AICAinterface aica_interface = +{ 1, { dc_ram, }, { YM3012_VOL(100, MIXER_PAN_LEFT, 100, MIXER_PAN_RIGHT) }, { aica_irq, }, -}; +}; uint8 dc_read8(int addr) { @@ -172,3 +172,4 @@ void dc_hw_init(void) aica_start(&aica_interface); } + diff --git a/Frameworks/AudioOverload/aosdk/eng_dsf/eng_dsf.c b/Frameworks/AudioOverload/aosdk/eng_dsf/eng_dsf.c index f6ac91ed7..2138f4708 100644 --- a/Frameworks/AudioOverload/aosdk/eng_dsf/eng_dsf.c +++ b/Frameworks/AudioOverload/aosdk/eng_dsf/eng_dsf.c @@ -33,6 +33,7 @@ static char psfby[256]; static uint32 decaybegin, decayend, total_samples; void *aica_start(const void *config); +void aica_stop(void); void AICA_Update(void *param, INT16 **inputs, INT16 **buf, int samples); int32 dsf_start(uint8 *buffer, uint32 length) @@ -88,6 +89,7 @@ int32 dsf_start(uint8 *buffer, uint32 length) // Dispose the corlett structure for the lib - we don't use it free(lib); + free(lib_decoded); } } @@ -209,6 +211,9 @@ int32 dsf_gen(int16 *buffer, uint32 samples) int32 dsf_stop(void) { + aica_stop(); + free(c); + return AO_SUCCESS; } diff --git a/Frameworks/AudioOverload/aosdk/eng_qsf/eng_qsf.c b/Frameworks/AudioOverload/aosdk/eng_qsf/eng_qsf.c index e2d8f7fdc..9cc86794a 100644 --- a/Frameworks/AudioOverload/aosdk/eng_qsf/eng_qsf.c +++ b/Frameworks/AudioOverload/aosdk/eng_qsf/eng_qsf.c @@ -193,6 +193,7 @@ int32 qsf_start(uint8 *buffer, uint32 length) // Dispose the corlett structure for the lib - we don't use it free(lib); + free(lib_decoded); } // now patch the file into RAM OVER the libraries @@ -305,7 +306,8 @@ int32 qsf_stop(void) { free(Z80ROM); free(QSamples); - + free(c); + return AO_SUCCESS; } diff --git a/Plugins/AudioOverload/AODecoder.m b/Plugins/AudioOverload/AODecoder.m index 4b97fa3f1..18b19e3ac 100644 --- a/Plugins/AudioOverload/AODecoder.m +++ b/Plugins/AudioOverload/AODecoder.m @@ -103,7 +103,7 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; - for (int i =0 ; i < 8; i++) { + for (int i = 1 ; i < 9; i++) { NSString *key = [[NSString alloc] initWithUTF8String:info.title[i]]; NSString *value = [[NSString alloc] initWithUTF8String:info.info[i]]; @@ -137,7 +137,7 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length) ao_display_info info; if ((*types[type].fillinfo)(&info) == AO_SUCCESS) { - for (int i =0 ; i < 8; i++) { + for (int i = 1 ; i < 9; i++) { NSString *key = [[NSString alloc] initWithUTF8String:info.title[i]]; NSString *value = [[NSString alloc] initWithUTF8String:info.info[i]]; @@ -247,7 +247,19 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length) return 0; } - (*types[type].gen)(buf, frames); + const int maxFrames = 1470; // The Dreamcast decoder starts smashing things if you try decoding more than this + + int amountRead = 0; + while (amountRead < frames) { + int requestAmount = frames - amountRead; + if (requestAmount > maxFrames) { + requestAmount = maxFrames; + } + + (*types[type].gen)((int16_t *)((int32_t *)buf + amountRead), requestAmount); + + amountRead += requestAmount; + } framesRead += frames; @@ -319,7 +331,7 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length) + (NSArray *)fileTypes { - return [NSArray arrayWithObjects:@"psf",@"minipsf",@"psf2", @"spu", @"psf2", @"ssf", @"dsf", @"qsf", nil]; + return [NSArray arrayWithObjects:@"psf",@"minipsf",@"psf2", @"spu", @"psf2", @"ssf", @"dsf", @"minidsf", @"qsf", nil]; } + (NSArray *)mimeTypes