• R/O
  • SSH

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

This is a fork of Zandronum for Mac Os (Silicon and Intel)


コミットメタ情報

リビジョンee76712daadefef8642448c0cc8f7ef826f0f914 (tree)
日時2023-01-24 04:25:06
作者Joshua Surace <doomjoshuaboy@live...>
コミッターJoshua Surace

ログメッセージ

Fixed up CMake and related sound issues.

変更サマリ

差分

diff -r 04d296eb008f -r ee76712daade src/CMakeLists.txt
--- a/src/CMakeLists.txt Mon Jan 23 20:50:09 2023 +1100
+++ b/src/CMakeLists.txt Tue Jan 24 06:25:06 2023 +1100
@@ -188,6 +188,8 @@
188188 # [BB] The server doesn't need sound, GTK or OpenGL.
189189 if( SERVERONLY )
190190 set( NO_SOUND ON )
191+ set( NO_FMOD ON )
192+ set( NO_OPENAL ON )
191193 set( NO_GTK ON )
192194 set( NO_GL ON )
193195 add_definitions ( -DSERVER_ONLY=1 )
@@ -351,7 +353,7 @@
351353 set( NO_FMOD ON )
352354 endif( FMOD_LIBRARY )
353355 endif( NOT NO_FMOD )
354-
356+
355357 if( NO_FMOD )
356358 add_definitions( -DNO_FMOD=1 )
357359 endif( NO_FMOD )
@@ -370,50 +372,6 @@
370372
371373 find_package( MPG123 )
372374 endif()
373-# Search for FMOD include files
374-
375-if( NOT WIN32 )
376- find_path( FMOD_INCLUDE_DIR fmod.hpp
377- PATHS ${FMOD_LOCAL_INC_DIRS} )
378-endif( NOT WIN32 )
379-
380-if( NOT FMOD_INCLUDE_DIR )
381- find_path( FMOD_INCLUDE_DIR fmod.hpp
382- PATHS ${FMOD_SEARCH_PATHS}
383- ${FMOD_INC_PATH_SUFFIXES} )
384-endif( NOT FMOD_INCLUDE_DIR )
385-
386-if( FMOD_INCLUDE_DIR )
387- message( STATUS "FMOD include files found at ${FMOD_INCLUDE_DIR}" )
388-else( FMOD_INCLUDE_DIR )
389- # [BB] Without sound, we don't need FMOD.
390- if ( NOT NO_SOUND )
391- message( SEND_ERROR "Could not find FMOD include files" )
392- endif ( NOT NO_SOUND )
393-endif( FMOD_INCLUDE_DIR )
394-
395-
396-# Search for FMOD library
397-
398-if( WIN32 OR APPLE )
399- find_library( FMOD_LIBRARY ${FMOD_LIB_NAME}
400- PATHS ${FMOD_SEARCH_PATHS}
401- ${FMOD_LIB_PATH_SUFFIXES} )
402-else( WIN32 OR APPLE )
403- find_library( FMOD_LIBRARY
404- NAMES ${FMOD_VERSIONS}
405- PATHS ${FMOD_LOCAL_LIB_DIRS} )
406-endif( WIN32 OR APPLE )
407-
408-if( FMOD_LIBRARY )
409- message( STATUS "FMOD library found at ${FMOD_LIBRARY}" )
410-else( FMOD_LIBRARY )
411- # [BB] Without sound, we don't need FMOD.
412- if ( NOT NO_SOUND )
413- message( SEND_ERROR "Could not find FMOD library" )
414- endif ( NOT NO_SOUND )
415-endif( FMOD_LIBRARY )
416-
417375
418376 # Search for FluidSynth
419377
@@ -1405,8 +1363,9 @@
14051363 resourcefiles/resourcefile.cpp
14061364 sfmt/SFMT.cpp
14071365 sound/fmodsound.cpp
1366+ sound/oalsound.cpp
14081367 sound/i_music.cpp
1409- sound/i_sound.cpp
1368+ sound/i_sound.cpp
14101369 sound/music_cd.cpp
14111370 sound/music_dumb.cpp
14121371 sound/music_gme.cpp
diff -r 04d296eb008f -r ee76712daade src/sound/fmodsound.cpp
--- a/src/sound/fmodsound.cpp Mon Jan 23 20:50:09 2023 +1100
+++ b/src/sound/fmodsound.cpp Tue Jan 24 06:25:06 2023 +1100
@@ -54,7 +54,7 @@
5454 #endif
5555
5656 #include "templates.h"
57-#ifndef NO_SOUND
57+#ifndef NO_FMOD
5858 #include "fmodsound.h"
5959 #endif
6060 #include "c_cvars.h"
@@ -145,7 +145,7 @@
145145 }
146146 }
147147
148-#ifndef NO_SOUND
148+#ifndef NO_FMOD
149149
150150 // PRIVATE DATA DEFINITIONS ------------------------------------------------
151151
diff -r 04d296eb008f -r ee76712daade src/sound/fmodsound.h
--- a/src/sound/fmodsound.h Mon Jan 23 20:50:09 2023 +1100
+++ b/src/sound/fmodsound.h Tue Jan 24 06:25:06 2023 +1100
@@ -1,8 +1,9 @@
11 #ifndef FMODSOUND_H
22 #define FMODSOUND_H
33
4-#ifndef NO_SOUND
54 #include "i_sound.h"
5+
6+#ifndef NO_FMOD
67 #include "fmod_wrap.h"
78
89 class FMODSoundRenderer : public SoundRenderer
diff -r 04d296eb008f -r ee76712daade src/sound/i_sound.cpp
--- a/src/sound/i_sound.cpp Mon Jan 23 20:50:09 2023 +1100
+++ b/src/sound/i_sound.cpp Tue Jan 24 06:25:06 2023 +1100
@@ -60,9 +60,11 @@
6060 #include "doomtype.h"
6161 #include <math.h>
6262
63-#ifndef NO_SOUND
6463 #include "fmodsound.h"
65-#endif
64+#include "oalsound.h"
65+
66+#include "mpg123_decoder.h"
67+#include "sndfile_decoder.h"
6668
6769 #include "m_swap.h"
6870 #include "stats.h"
@@ -87,6 +89,14 @@
8789 CVAR (Int, snd_buffersize, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
8890 CVAR (String, snd_output, "default", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
8991
92+#ifndef NO_FMOD
93+CVAR (String, snd_backend, "fmod", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
94+#elif !defined(NO_OPENAL)
95+CVAR (String, snd_backend, "openal", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
96+#else
97+CVAR (String, snd_backend, "null", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
98+#endif
99+
90100 // killough 2/21/98: optionally use varying pitched sounds
91101 CVAR (Bool, snd_pitched, false, CVAR_ARCHIVE)
92102
@@ -248,10 +258,6 @@
248258
249259 void I_InitSound ()
250260 {
251-#ifdef NO_SOUND
252- GSnd = new NullSoundRenderer;
253- I_InitMusic ();
254-#else
255261 /* Get command line options: */
256262 nosound = !!Args->CheckParm ("-nosound") || !!Args->CheckParm("-host"); // [BB] No sound for the server
257263 nosfx = !!Args->CheckParm ("-nosfx") || !!Args->CheckParm("-host"); // [BB]
@@ -263,17 +269,25 @@
263269 return;
264270 }
265271
266- GSnd = new FMODSoundRenderer;
272+ if(stricmp(snd_backend, "null") == 0)
273+ GSnd = new NullSoundRenderer;
274+ #ifndef NO_FMOD
275+ else if(stricmp(snd_backend, "fmod") == 0)
276+ GSnd = new FMODSoundRenderer;
277+ #endif
278+ #ifndef NO_OPENAL
279+ else if(stricmp(snd_backend, "openal") == 0)
280+ GSnd = new OpenALSoundRenderer;
281+ #endif
267282
268283 if (!GSnd->IsValid ())
269284 {
270285 I_CloseSound();
271286 GSnd = new NullSoundRenderer;
272- Printf (TEXTCOLOR_RED"Sound init failed. Using nosound.\n");
287+ Printf ( TEXTCOLOR_RED "Sound init failed. Using nosound.\n");
273288 }
274289 I_InitMusic ();
275290 snd_sfxvolume.Callback ();
276-#endif
277291 }
278292
279293
@@ -336,9 +350,28 @@
336350 return "No stats for this sound renderer.";
337351 }
338352
339-short *SoundRenderer::DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType type)
353+short *SoundRenderer::DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType ctype)
340354 {
341- return NULL;
355+ MemoryReader reader((const char*)coded, sizebytes);
356+ short *samples = (short*)calloc(1, outlen);
357+ ChannelConfig chans;
358+ SampleType type;
359+ int srate;
360+
361+ SoundDecoder *decoder = CreateDecoder(&reader);
362+ if(!decoder) return samples;
363+
364+ decoder->getInfo(&srate, &chans, &type);
365+ if(chans != ChannelConfig_Mono || type != SampleType_Int16)
366+ {
367+ DPrintf("Sample is not 16-bit mono\n");
368+ delete decoder;
369+ return samples;
370+ }
371+
372+ decoder->read((char*)samples, outlen);
373+ delete decoder;
374+ return samples;
342375 }
343376
344377 void SoundRenderer::DrawWaveDebug(int mode)
@@ -519,3 +552,46 @@
519552 return retval;
520553 }
521554
555+SoundDecoder *SoundRenderer::CreateDecoder(FileReader *reader)
556+{
557+ SoundDecoder *decoder = NULL;
558+ int pos = reader->Tell();
559+
560+#ifdef HAVE_MPG123
561+ decoder = new MPG123Decoder;
562+ if (decoder->open(reader))
563+ return decoder;
564+ reader->Seek(pos, SEEK_SET);
565+
566+ delete decoder;
567+ decoder = NULL;
568+#endif
569+#ifdef HAVE_SNDFILE
570+ decoder = new SndFileDecoder;
571+ if (decoder->open(reader))
572+ return decoder;
573+ reader->Seek(pos, SEEK_SET);
574+
575+ delete decoder;
576+ decoder = NULL;
577+#endif
578+ return decoder;
579+}
580+
581+
582+// Default readAll implementation, for decoders that can't do anything better
583+TArray<char> SoundDecoder::readAll()
584+{
585+ TArray<char> output;
586+ size_t total = 0;
587+ size_t got;
588+
589+ output.Resize(total+32768);
590+ while((got=read(&output[total], output.Size()-total)) > 0)
591+ {
592+ total += got;
593+ output.Resize(total*2);
594+ }
595+ output.Resize(total);
596+ return output;
597+}
diff -r 04d296eb008f -r ee76712daade src/sound/i_sound.h
--- a/src/sound/i_sound.h Mon Jan 23 20:50:09 2023 +1100
+++ b/src/sound/i_sound.h Tue Jan 24 06:25:06 2023 +1100
@@ -40,44 +40,44 @@
4040
4141 enum ECodecType
4242 {
43- CODEC_Unknown,
44- CODEC_Vorbis,
43+ CODEC_Unknown,
44+ CODEC_Vorbis,
4545 };
4646
4747 enum EStartSoundFlags
4848 {
49- SNDF_LOOP=1,
50- SNDF_NOPAUSE=2,
51- SNDF_AREA=4,
52- SNDF_ABSTIME=8,
53- SNDF_NOREVERB=16,
49+ SNDF_LOOP=1,
50+ SNDF_NOPAUSE=2,
51+ SNDF_AREA=4,
52+ SNDF_ABSTIME=8,
53+ SNDF_NOREVERB=16,
5454 };
5555
5656 class SoundStream
5757 {
5858 public:
59- virtual ~SoundStream ();
60-
61- enum
62- { // For CreateStream
63- Mono = 1,
64- Bits8 = 2,
65- Bits32 = 4,
66- Float = 8,
59+ virtual ~SoundStream ();
6760
68- // For OpenStream
69- Loop = 16
70- };
61+ enum
62+ { // For CreateStream
63+ Mono = 1,
64+ Bits8 = 2,
65+ Bits32 = 4,
66+ Float = 8,
7167
72- virtual bool Play(bool looping, float volume) = 0;
73- virtual void Stop() = 0;
74- virtual void SetVolume(float volume) = 0;
75- virtual bool SetPaused(bool paused) = 0;
76- virtual unsigned int GetPosition() = 0;
77- virtual bool IsEnded() = 0;
78- virtual bool SetPosition(unsigned int pos);
79- virtual bool SetOrder(int order);
80- virtual FString GetStats();
68+ // For OpenStream
69+ Loop = 16
70+ };
71+
72+ virtual bool Play(bool looping, float volume) = 0;
73+ virtual void Stop() = 0;
74+ virtual void SetVolume(float volume) = 0;
75+ virtual bool SetPaused(bool paused) = 0;
76+ virtual unsigned int GetPosition() = 0;
77+ virtual bool IsEnded() = 0;
78+ virtual bool SetPosition(unsigned int pos);
79+ virtual bool SetOrder(int order);
80+ virtual FString GetStats();
8181 };
8282
8383 typedef bool (*SoundStreamCallback)(SoundStream *stream, void *buff, int len, void *userdata);
@@ -85,71 +85,73 @@
8585 class SoundRenderer
8686 {
8787 public:
88- SoundRenderer ();
89- virtual ~SoundRenderer ();
90-
91- virtual bool IsNull() { return false; }
92- virtual void SetSfxVolume (float volume) = 0;
93- virtual void SetMusicVolume (float volume) = 0;
94- virtual SoundHandle LoadSound(BYTE *sfxdata, int length) = 0;
95- SoundHandle LoadSoundVoc(BYTE *sfxdata, int length);
96- virtual SoundHandle LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1) = 0;
97- virtual void UnloadSound (SoundHandle sfx) = 0; // unloads a sound from memory
98- virtual unsigned int GetMSLength(SoundHandle sfx) = 0; // Gets the length of a sound at its default frequency
99- virtual unsigned int GetSampleLength(SoundHandle sfx) = 0; // Gets the length of a sound at its default frequency
100- virtual float GetOutputRate() = 0;
101-
102- // Streaming sounds.
103- virtual SoundStream *CreateStream (SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata) = 0;
104- virtual SoundStream *OpenStream (const char *filename, int flags, int offset, int length) = 0;
105-
106- // Starts a sound.
107- virtual FISoundChannel *StartSound (SoundHandle sfx, float vol, int pitch, int chanflags, FISoundChannel *reuse_chan) = 0;
108- virtual FISoundChannel *StartSound3D (SoundHandle sfx, SoundListener *listener, float vol, FRolloffInfo *rolloff, float distscale, int pitch, int priority, const FVector3 &pos, const FVector3 &vel, int channum, int chanflags, FISoundChannel *reuse_chan) = 0;
109-
110- // Stops a sound channel.
111- virtual void StopChannel (FISoundChannel *chan) = 0;
112-
113- // Changes a channel's volume.
114- virtual void ChannelVolume (FISoundChannel *chan, float volume) = 0;
115-
116- // Marks a channel's start time without actually playing it.
117- virtual void MarkStartTime (FISoundChannel *chan) = 0;
88+ SoundRenderer ();
89+ virtual ~SoundRenderer ();
11890
119- // Returns position of sound on this channel, in samples.
120- virtual unsigned int GetPosition(FISoundChannel *chan) = 0;
121-
122- // Gets a channel's audibility (real volume).
123- virtual float GetAudibility(FISoundChannel *chan) = 0;
124-
125- // Synchronizes following sound startups.
126- virtual void Sync (bool sync) = 0;
127-
128- // Pauses or resumes all sound effect channels.
129- virtual void SetSfxPaused (bool paused, int slot) = 0;
91+ virtual bool IsNull() { return false; }
92+ virtual void SetSfxVolume (float volume) = 0;
93+ virtual void SetMusicVolume (float volume) = 0;
94+ virtual SoundHandle LoadSound(BYTE *sfxdata, int length) = 0;
95+ SoundHandle LoadSoundVoc(BYTE *sfxdata, int length);
96+ virtual SoundHandle LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1) = 0;
97+ virtual void UnloadSound (SoundHandle sfx) = 0; // unloads a sound from memory
98+ virtual unsigned int GetMSLength(SoundHandle sfx) = 0; // Gets the length of a sound at its default frequency
99+ virtual unsigned int GetSampleLength(SoundHandle sfx) = 0; // Gets the length of a sound at its default frequency
100+ virtual float GetOutputRate() = 0;
130101
131- // Pauses or resumes *every* channel, including environmental reverb.
132- enum EInactiveState
133- {
134- INACTIVE_Active, // sound is active
135- INACTIVE_Complete, // sound is completely paused
136- INACTIVE_Mute // sound is only muted
137- };
138- virtual void SetInactive(EInactiveState inactive) = 0;
102+ // Streaming sounds.
103+ virtual SoundStream *CreateStream (SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata) = 0;
104+ virtual SoundStream *OpenStream (const char *filename, int flags, int offset, int length) = 0;
139105
140- // Updates the volume, separation, and pitch of a sound channel.
141- virtual void UpdateSoundParams3D (SoundListener *listener, FISoundChannel *chan, bool areasound, const FVector3 &pos, const FVector3 &vel) = 0;
142-
143- virtual void UpdateListener (SoundListener *) = 0;
144- virtual void UpdateSounds () = 0;
106+ // Starts a sound.
107+ virtual FISoundChannel *StartSound (SoundHandle sfx, float vol, int pitch, int chanflags, FISoundChannel *reuse_chan) = 0;
108+ virtual FISoundChannel *StartSound3D (SoundHandle sfx, SoundListener *listener, float vol, FRolloffInfo *rolloff, float distscale, int pitch, int priority, const FVector3 &pos, const FVector3 &vel, int channum, int chanflags, FISoundChannel *reuse_chan) = 0;
145109
146- virtual bool IsValid () = 0;
147- virtual void PrintStatus () = 0;
148- virtual void PrintDriversList () = 0;
149- virtual FString GatherStats ();
150- virtual short *DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType type);
110+ // Stops a sound channel.
111+ virtual void StopChannel (FISoundChannel *chan) = 0;
151112
152- virtual void DrawWaveDebug(int mode);
113+ // Changes a channel's volume.
114+ virtual void ChannelVolume (FISoundChannel *chan, float volume) = 0;
115+
116+ // Marks a channel's start time without actually playing it.
117+ virtual void MarkStartTime (FISoundChannel *chan) = 0;
118+
119+ // Returns position of sound on this channel, in samples.
120+ virtual unsigned int GetPosition(FISoundChannel *chan) = 0;
121+
122+ // Gets a channel's audibility (real volume).
123+ virtual float GetAudibility(FISoundChannel *chan) = 0;
124+
125+ // Synchronizes following sound startups.
126+ virtual void Sync (bool sync) = 0;
127+
128+ // Pauses or resumes all sound effect channels.
129+ virtual void SetSfxPaused (bool paused, int slot) = 0;
130+
131+ // Pauses or resumes *every* channel, including environmental reverb.
132+ enum EInactiveState
133+ {
134+ INACTIVE_Active, // sound is active
135+ INACTIVE_Complete, // sound is completely paused
136+ INACTIVE_Mute // sound is only muted
137+ };
138+ virtual void SetInactive(EInactiveState inactive) = 0;
139+
140+ // Updates the volume, separation, and pitch of a sound channel.
141+ virtual void UpdateSoundParams3D (SoundListener *listener, FISoundChannel *chan, bool areasound, const FVector3 &pos, const FVector3 &vel) = 0;
142+
143+ virtual void UpdateListener (SoundListener *) = 0;
144+ virtual void UpdateSounds () = 0;
145+
146+ virtual bool IsValid () = 0;
147+ virtual void PrintStatus () = 0;
148+ virtual void PrintDriversList () = 0;
149+ virtual FString GatherStats ();
150+ virtual short *DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType type);
151+
152+ virtual void DrawWaveDebug(int mode);
153+protected:
154+ virtual SoundDecoder *CreateDecoder(FileReader *reader);
153155 };
154156
155157 extern SoundRenderer *GSnd;
diff -r 04d296eb008f -r ee76712daade src/sound/i_soundinternal.h
--- a/src/sound/i_soundinternal.h Mon Jan 23 20:50:09 2023 +1100
+++ b/src/sound/i_soundinternal.h Tue Jan 24 06:25:06 2023 +1100
@@ -2,14 +2,18 @@
22 #define __SNDINT_H
33
44 #include "basictypes.h"
5+#include "vectors.h"
6+#include "tarray.h"
7+
8+class FileReader;
59
610 // For convenience, this structure matches FMOD_REVERB_PROPERTIES.
711 // Since I can't very well #include system-specific stuff in the
812 // main game files, I duplicate it here.
913 struct REVERB_PROPERTIES
10-{
11- int Instance;
12- int Environment;
14+{
15+ int Instance;
16+ int Environment;
1317 float EnvSize;
1418 float EnvDiffusion;
1519 int Room;
@@ -21,13 +25,13 @@
2125 int Reflections;
2226 float ReflectionsDelay;
2327 float ReflectionsPan0;
24- float ReflectionsPan1;
25- float ReflectionsPan2;
28+ float ReflectionsPan1;
29+ float ReflectionsPan2;
2630 int Reverb;
2731 float ReverbDelay;
2832 float ReverbPan0;
29- float ReverbPan1;
30- float ReverbPan2;
33+ float ReverbPan1;
34+ float ReverbPan2;
3135 float EchoTime;
3236 float EchoDepth;
3337 float ModulationTime;
@@ -52,52 +56,91 @@
5256
5357 struct ReverbContainer
5458 {
55- ReverbContainer *Next;
56- const char *Name;
57- WORD ID;
58- bool Builtin;
59- bool Modified;
60- REVERB_PROPERTIES Properties;
61- bool SoftwareWater;
59+ ReverbContainer *Next;
60+ const char *Name;
61+ WORD ID;
62+ bool Builtin;
63+ bool Modified;
64+ REVERB_PROPERTIES Properties;
65+ bool SoftwareWater;
6266 };
6367
6468 struct SoundListener
6569 {
66- FVector3 position;
67- FVector3 velocity;
68- float angle;
69- bool underwater;
70- bool valid;
71- ReverbContainer *Environment;
70+ FVector3 position;
71+ FVector3 velocity;
72+ float angle;
73+ bool underwater;
74+ bool valid;
75+ ReverbContainer *Environment;
7276 };
7377
7478 // Default rolloff information.
7579 struct FRolloffInfo
7680 {
77- int RolloffType;
78- float MinDistance;
79- union { float MaxDistance; float RolloffFactor; };
81+ int RolloffType;
82+ float MinDistance;
83+ union { float MaxDistance; float RolloffFactor; };
8084 };
8185
8286 struct SoundHandle
8387 {
84- void *data;
88+ void *data;
8589
86- bool isValid() const { return data != NULL; }
87- void Clear() { data = NULL; }
90+ bool isValid() const { return data != NULL; }
91+ void Clear() { data = NULL; }
8892 };
8993
9094 struct FISoundChannel
9195 {
92- void *SysChannel; // Channel information from the system interface.
93- QWORD_UNION StartTime; // Sound start time in DSP clocks.
96+ void *SysChannel; // Channel information from the system interface.
97+ QWORD_UNION StartTime; // Sound start time in DSP clocks.
9498
95- // The sound interface doesn't use these directly but it needs to pass them to a
96- // callback that can't be passed a sound channel pointer
97- FRolloffInfo Rolloff;
98- float DistanceScale;
99+ // The sound interface doesn't use these directly but it needs to pass them to a
100+ // callback that can't be passed a sound channel pointer
101+ FRolloffInfo Rolloff;
102+ float DistanceScale;
103+ float DistanceSqr;
104+ bool ManualRolloff;
105+};
106+
107+enum SampleType
108+{
109+ SampleType_UInt8,
110+ SampleType_Int16
111+};
112+enum ChannelConfig
113+{
114+ ChannelConfig_Mono,
115+ ChannelConfig_Stereo
116+};
117+
118+const char *GetSampleTypeName(enum SampleType type);
119+const char *GetChannelConfigName(enum ChannelConfig chan);
120+
121+struct SoundDecoder
122+{
123+ virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0;
124+
125+ virtual size_t read(char *buffer, size_t bytes) = 0;
126+ virtual TArray<char> readAll();
127+ virtual bool seek(size_t ms_offset) = 0;
128+ virtual size_t getSampleOffset() = 0;
129+ virtual size_t getSampleLength() { return 0; }
130+
131+ SoundDecoder() { }
132+ virtual ~SoundDecoder() { }
133+
134+protected:
135+ virtual bool open(FileReader *reader) = 0;
136+ friend class SoundRenderer;
137+
138+private:
139+ // Make non-copyable
140+ SoundDecoder(const SoundDecoder &rhs);
141+ SoundDecoder& operator=(const SoundDecoder &rhs);
99142 };
100143
101144
145+#endif
102146
103-#endif
diff -r 04d296eb008f -r ee76712daade src/tarray.h
--- a/src/tarray.h Mon Jan 23 20:50:09 2023 +1100
+++ b/src/tarray.h Tue Jan 24 06:25:06 2023 +1100
@@ -137,8 +137,18 @@
137137 {
138138 return Array[Count-1];
139139 }
140-
141- unsigned int Push (const T &item)
140+
141+ unsigned int Find(const T& item) const
142+ {
143+ unsigned int i;
144+ for(i = 0;i < Count;++i)
145+ {
146+ if(Array[i] == item)
147+ break;
148+ }
149+ return i;
150+ }
151+ unsigned int Push (const T &item)
142152 {
143153 Grow (1);
144154 ::new((void*)&Array[Count]) T(item);