forked from Ports/perfect_dark
port: restart currently playing MP3 when needed
there's probably a way to determine reset condition without adding an extra field to g_Mp3Vars, but I can't be arsed to figure it out
This commit is contained in:
1 parent
8494e29075
commit
844139b339
4 files changed
+13
-6
No files matched your search
@@ -34,7 +34,7 @@ void aEnvMixerImpl(uint8_t flags, ENVMIX_STATE state, int16_t some_vol);
|
||||
void aSetVolumeImpl(uint8_t flags, int16_t v, int16_t t, int16_t r);
|
||||
void aPoleFilterImpl(uint8_t flags, int16_t gain, uint32_t t, uint32_t addr);
|
||||
void aDisableImpl(uint16_t outp, uint32_t b, uint32_t c);
|
||||
void aPlayMP3Impl(const void *mp3file, u32 mp3size, void *out);
|
||||
void aPlayMP3Impl(const void *mp3file, u32 mp3size, void *out, int reset);
|
||||
|
||||
#define aDisable(pkt, o, b, c) aDisableImpl(o, b, c)
|
||||
#define aClearBuffer(pkt, d, c) aClearBufferImpl(d, c)
|
||||
@@ -50,6 +50,6 @@ void aPlayMP3Impl(const void *mp3file, u32 mp3size, void *out);
|
||||
#define aEnvMixer(pkt, f, t, s) aEnvMixerImpl(f, (void *)(s), t)
|
||||
#define aSetVolume(pkt, f, v, t, r) aSetVolumeImpl(f, v, t, r)
|
||||
#define aPoleFilter(pkt, f, g, t, s) aPoleFilterImpl(f, g, t, s)
|
||||
#define aPlayMP3(pkt, a, b, c) aPlayMP3Impl((void *)(a), b, (void *)(c))
|
||||
#define aPlayMP3(pkt, a, b, c, r) aPlayMP3Impl((void *)(a), b, (void *)(c), r)
|
||||
|
||||
#endif
|
||||
+2
-2
@@ -681,12 +681,12 @@ void aSetVolumeImpl(uint8_t flags, int16_t v, int16_t t, int16_t r) {
|
||||
}
|
||||
}
|
||||
|
||||
void aPlayMP3Impl(const void *mp3file, u32 mp3size, void *out) {
|
||||
void aPlayMP3Impl(const void *mp3file, u32 mp3size, void *out, int reset) {
|
||||
static mp3dec_t mp3d;
|
||||
static const u8 *curdata = NULL; // pointer to the mp3 we're currently processing
|
||||
static s32 dataptr = 0; // byte index into curdata
|
||||
|
||||
if (mp3file != curdata) {
|
||||
if (mp3file != curdata || reset) {
|
||||
// new mp3, reinit decoder
|
||||
mp3dec_init(&mp3d);
|
||||
curdata = mp3file;
|
||||
|
||||
@@ -5695,6 +5695,9 @@ struct mp3vars {
|
||||
/*0x5e*/ s16 var8009c3ee;
|
||||
/*0x60*/ u8 var8009c3f0;
|
||||
/*0x61*/ u8 var8009c3f1;
|
||||
#ifndef PLATFORM_N64
|
||||
/*0x62*/ u8 reset;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct rdptask {
|
||||
|
||||
+6
-2
@@ -31,7 +31,7 @@
|
||||
|
||||
#include "mixer.h"
|
||||
|
||||
#define acmd07(pkt, a, b, c) aPlayMP3(pkt, a, b, c)
|
||||
#define acmd07(pkt, a, b, c, r) aPlayMP3(pkt, a, b, c, r)
|
||||
#define acmd08(pkt, a) do { } while(0)
|
||||
|
||||
#endif
|
||||
@@ -100,6 +100,9 @@ void mp3PlayFile(s32 romaddr, s32 filesize)
|
||||
g_Mp3Vars.var8009c3e8 = 0;
|
||||
g_Mp3Vars.var8009c3e4 = 0x7fff;
|
||||
g_Mp3Vars.var8009c3f0 = 5;
|
||||
#ifndef PLATFORM_N64
|
||||
g_Mp3Vars.reset = 1;
|
||||
#endif
|
||||
|
||||
mp3Dma();
|
||||
|
||||
@@ -251,7 +254,8 @@ s32 func00037fc0(s32 arg0, Acmd **cmd)
|
||||
acmd07((*cmd)++, g_Mp3Vars.var8009c3d8, osVirtualToPhysical(sp58));
|
||||
#else
|
||||
// hijack the command to pass the entirety of the mp3 data to the mixer
|
||||
acmd07((*cmd)++, g_Mp3Vars.romaddr, g_Mp3Vars.filesize, osVirtualToPhysical(sp58));
|
||||
acmd07((*cmd)++, g_Mp3Vars.romaddr, g_Mp3Vars.filesize, osVirtualToPhysical(sp58), g_Mp3Vars.reset);
|
||||
g_Mp3Vars.reset = 0;
|
||||
#endif
|
||||
|
||||
sp58++;
|
||||
|
||||
Reference in new issue
Block a user