File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,32 @@ static const soundExtToLoaderMap_t soundLoaders[] =
5050
5151static int numSoundLoaders = ARRAY_LEN(soundLoaders);
5252
53+ static bool IsNullSample (std::string& filename)
54+ {
55+ if (Str::IsPrefix (" sound/null" , filename)) {
56+ if (filename == " sound/null" ) {
57+ return true ;
58+ }
59+
60+ std::string basename = FS::Path::StripExtension (filename);
61+
62+ if (basename == " sound/null" ) {
63+ return true ;
64+ }
65+ }
66+
67+ return false ;
68+ }
69+
70+ static AudioData LoadNullSample ()
71+ {
72+ // 16bit mono 8KHz, 1 sample, silence.
73+ unsigned char *null_wav = (unsigned char *) calloc ( 1 , 2 );
74+ AudioData out { 8000 , 2 , 1 };
75+ out.rawSamples .assign ( null_wav, null_wav + 2 );
76+ return out;
77+ }
78+
5379static int FindSoundLoader (std::string filename)
5480{
5581 const FS::PakInfo* bestPak = nullptr ;
@@ -77,6 +103,9 @@ static int FindSoundLoader(std::string filename)
77103
78104AudioData LoadSoundCodec (std::string filename)
79105{
106+ if (IsNullSample (filename)) {
107+ return LoadNullSample ();
108+ }
80109
81110 std::string ext = FS::Path::Extension (filename);
82111
You can’t perform that action at this time.
0 commit comments