Skip to content

Commit b8ce6fa

Browse files
committed
Enable sound effect import on SDL platforms
1 parent 47d9a27 commit b8ce6fa

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

src/engine/msnd.cpp

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include "audioman.h"
2929
#endif // HAS_AUDIOMAN
3030

31+
#ifdef KAUAI_SDL
32+
#include "sndsdl.h"
33+
#endif // KAUAI_SDL
34+
3135
ASSERTNAME
3236

3337
RTCLASS(MSND)
@@ -308,11 +312,20 @@ bool MSND::FCopyWave(PFIL pfilSrc, PCFL pcflDest, int32_t sty, CNO *pcno, PSTN p
308312
Assert(sty != styMidi, "Illegal sty argument");
309313
AssertNilOrPo(pstn, 0);
310314

311-
#if defined(KAUAI_WIN32) && defined(HAS_AUDIOMAN)
312-
313315
FNI fniSrc;
314316
STN stnName; // sound name
315317
STN stn; // src file path name
318+
319+
pfilSrc->GetFni(&fniSrc);
320+
if (pvNil == pstn)
321+
fniSrc.GetLeaf(&stnName);
322+
else
323+
stnName = *pstn;
324+
325+
fniSrc.GetStnPath(&stn);
326+
327+
#if defined(KAUAI_WIN32) && defined(HAS_AUDIOMAN)
328+
316329
WAVEFORMATEX wfxSrc;
317330
LPSOUND psnd = pvNil;
318331
LPSOUND psndTemp = pvNil;
@@ -336,13 +349,6 @@ bool MSND::FCopyWave(PFIL pfilSrc, PCFL pcflDest, int32_t sty, CNO *pcno, PSTN p
336349
bool fCompress = fTrue;
337350
int32_t lwProp = 0;
338351

339-
pfilSrc->GetFni(&fniSrc);
340-
if (pvNil == pstn)
341-
fniSrc.GetLeaf(&stnName);
342-
else
343-
stnName = *pstn;
344-
fniSrc.GetStnPath(&stn);
345-
346352
if (!fniNew.FGetTemp())
347353
goto LFail;
348354

@@ -575,9 +581,18 @@ bool MSND::FCopyWave(PFIL pfilSrc, PCFL pcflDest, int32_t sty, CNO *pcno, PSTN p
575581
return fFalse;
576582

577583
#else
578-
// TODO: implement sound import without AudioMan
579-
RawRtn();
580-
return fFalse;
584+
585+
if (!FValidSoundFile(&fniSrc))
586+
{
587+
PushErc(ercSocBadSoundFile);
588+
return fFalse;
589+
}
590+
591+
if (!MSND::FWriteWave(pfilSrc, pcflDest, sty, &stnName, pcno))
592+
return fFalse;
593+
594+
return fTrue;
595+
581596
#endif // KAUAI_WIN32 && HAS_AUDIOMAN
582597
}
583598

0 commit comments

Comments
 (0)