Skip to content

Commit 47d9a27

Browse files
committed
Add method to check if a sound can be loaded by SDL_Mixer
1 parent 00bc4d7 commit 47d9a27

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

kauai/src/sndsdl.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,28 @@ void SDLSoundDevice::MarkMem()
681681
MarkMemObj(_psdlsn);
682682
}
683683
#endif // DEBUG
684+
685+
bool FValidSoundFile(PFNI pfniSoundFile)
686+
{
687+
AssertPo(pfniSoundFile, 0);
688+
689+
bool fRet = fFalse;
690+
STN stnFilePath;
691+
Mix_Chunk *pchunk = pvNil;
692+
693+
pfniSoundFile->GetStnPath(&stnFilePath);
694+
695+
pchunk = Mix_LoadWAV(stnFilePath.Psz());
696+
if (pchunk != pvNil)
697+
{
698+
fRet = fTrue;
699+
Mix_FreeChunk(pchunk);
700+
pchunk = pvNil;
701+
}
702+
else
703+
{
704+
Bug(Mix_GetError());
705+
}
706+
707+
return fRet;
708+
}

kauai/src/sndsdl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,7 @@ class SDLSoundDevice : public SDLSoundDevice_PAR
6464
void NotifyChannelFinished(int channel);
6565
};
6666

67+
// Return true if this sound can be loaded by SDL_Mixer
68+
bool FValidSoundFile(PFNI pfniSoundFile);
69+
6770
#endif // SNDSDL_H

0 commit comments

Comments
 (0)