Better report the number of Smacker audio tracks

This commit is contained in:
Chris Robinson 2022-10-02 06:53:44 -07:00 committed by Christoph Oelckers
parent 1a692f5c28
commit 3b6723e6f2
2 changed files with 16 additions and 5 deletions

View file

@ -125,6 +125,7 @@ class SmackerDecoder
void GetPalette(uint8_t *palette);
void GetFrame(uint8_t *frame);
uint32_t GetNumAudioTracks();
SmackerAudioInfo GetAudioTrackDetails(uint32_t trackIndex);
uint32_t GetAudioData(uint32_t trackIndex, int16_t *audioBuffer);
void DisableAudioTrack(uint32_t trackIndex);

View file

@ -94,10 +94,9 @@ void Smacker_Close(SmackerHandle &handle)
handle.isValid = false;
}
uint32_t Smacker_GetNumAudioTracks(SmackerHandle &)
uint32_t Smacker_GetNumAudioTracks(SmackerHandle &handle)
{
// TODO: fixme
return 1;
return classInstances[handle.instanceIndex]->GetNumAudioTracks();
}
SmackerAudioInfo Smacker_GetAudioTrackDetails(SmackerHandle &handle, uint32_t trackIndex)
@ -398,8 +397,9 @@ bool SmackerDecoder::Open(const char *fileName)
audioTracks[i].bufferSize = 0;
audioTracks[i].bytesReadThisFrame = 0;
// FIXME: Only disable non-consecutive enabled tracks
if (i > 0 /*&& !(audioTracks[i-1].flags & SMK_AUD_PRESENT)*/)
// Disable non-consecutive enabled tracks. Not sure how to otherwise report
// them properly for Smacker_GetNumAudioTracks.
if (i > 0 && !(audioTracks[i-1].flags & SMK_AUD_PRESENT))
audioTracks[i].flags &= ~SMK_AUD_PRESENT;
if (audioTracks[i].flags & 0xFFFFFF)
@ -1184,6 +1184,16 @@ void SmackerDecoder::GotoFrame(uint32_t frameNum)
GetNextFrame();
}
uint32_t SmackerDecoder::GetNumAudioTracks()
{
for(uint32_t i = 0;i < kMaxAudioTracks;++i)
{
if (!(audioTracks[i].flags & SMK_AUD_PRESENT))
return i;
}
return kMaxAudioTracks;
}
SmackerAudioInfo SmackerDecoder::GetAudioTrackDetails(uint32_t trackIndex)
{
SmackerAudioInfo info;