Get rid of FMOD

Not only is FMOD neither free (libre) nor free (gratis), the version we
support(ed) is also impossible to legally obtain anymore. So there's no
reason we should keep code around that (pretends to) support a library
nobody can use or test.
shapetextures
Nicolas Hake 2015-10-12 14:17:24 +02:00
parent 9580c2f58c
commit 0c1abe69f9
15 changed files with 16 additions and 508 deletions

View File

@ -99,7 +99,6 @@ else()
# Test for OpenAL
__FINDAUDIO_FINDOPENAL()
__FINDAUDIO_FINDSDLMIXER()
find_package("FMod")
if(OpenAL_FOUND AND Alut_FOUND AND OggVorbis_FOUND)
# Prefer OpenAL
@ -109,8 +108,6 @@ else()
endif()
elseif(SDLMixer_FOUND)
set(Audio_TK "SDL_Mixer")
elseif(FMOD_FOUND)
set(Audio_TK "FMod")
endif()
endif()
@ -133,13 +130,6 @@ elseif(Audio_TK STREQUAL "SDL_Mixer")
set(Audio_LIBRARIES ${SDLMixer_LIBRARIES})
set(Audio_INCLUDE_DIRS ${SDLMixer_INCLUDE_DIRS})
endif()
elseif(Audio_TK STREQUAL "FMod")
find_package("FMod")
if(FMOD_FOUND)
set(Audio_FOUND TRUE)
set(Audio_LIBRARIES ${FMOD_LIBRARIES})
set(Audio_INCLUDE_DIRS ${FMOD_INCLUDE_DIR})
endif()
elseif(Audio_TK STREQUAL "none")
set(Audio_FOUND TRUE)
set(Audio_LIBRARIES "")

View File

@ -1,45 +0,0 @@
# OpenClonk, http://www.openclonk.org
#
# Copyright (c) 2011-2013, The OpenClonk Team and contributors
#
# Distributed under the terms of the ISC license; see accompanying file
# "COPYING" for details.
#
# "Clonk" is a registered trademark of Matthes Bender, used with permission.
# See accompanying file "TRADEMARK" for details.
#
# To redistribute this file separately, substitute the full license texts
# for the above references.
# - Find FMod
# Find the FMod library
# This module defines
# FMOD_INCLUDE_DIR, where to find fmod.h, etc.
# FMOD_LIBRARIES, the libraries needed to use FMod.
# FMOD_FOUND, If false, do not try to use FMod.
find_path(FMOD_INCLUDE_DIR fmod.h)
if(CMAKE_CL_64)
if(MSVC)
set(FMOD_NAMES ${FMOD_NAMES} fmod64vc)
else()
set(FMOD_NAMES ${FMOD_NAMES} fmod64)
endif()
else()
if(MSVC)
set(FMOD_NAMES ${FMOD_NAMES} fmodvc)
else()
set(FMOD_NAMES ${FMOD_NAMES} fmod)
endif()
endif()
find_library(FMOD_LIBRARY NAMES ${FMOD_NAMES})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FMOD DEFAULT_MSG FMOD_LIBRARY FMOD_INCLUDE_DIR)
if(FMOD_FOUND)
set(FMOD_LIBRARIES ${FMOD_LIBRARY})
endif()
mark_as_advanced(FMOD_LIBRARY FMOD_INCLUDE_DIR)

View File

@ -188,7 +188,6 @@
/* Select an audio provider */
#define AUDIO_TK_NONE 0
#define AUDIO_TK_OPENAL 1
#define AUDIO_TK_FMOD 2
#define AUDIO_TK_SDL_MIXER 3
#define AUDIO_TK AUDIO_TK_${Audio_TK_UPPER}

View File

@ -37,10 +37,6 @@ C4StartupAboutDlg::C4StartupAboutDlg() : C4StartupDlg(LoadResStr("IDS_DLG_ABOUT"
C4GUI::ComponentAligner caMain(rcClient, 0,0, true);
C4GUI::ComponentAligner caButtons(caMain.GetFromBottom(caMain.GetHeight()*1/8), 0,0, false);
C4GUI::CallbackButton<C4StartupAboutDlg> *btn;
#if AUDIO_TK == AUDIO_TK_FMOD
AddElement(new C4GUI::Label("Using FMOD Sound System, copyright (c) Firelight Technologies Pty, Ltd., 1994-2010.",
caMain.GetFromBottom(rUseFont.GetLineHeight())));
#endif
int32_t iButtonWidth = caButtons.GetInnerWidth() / 4;
AddElement(btn = new C4GUI::CallbackButton<C4StartupAboutDlg>(LoadResStr("IDS_BTN_BACK"), caButtons.GetGridCell(0,3,0,1,iButtonWidth,C4GUI_ButtonHgt,true), &C4StartupAboutDlg::OnBackBtn));
btn->SetToolTip(LoadResStr("IDS_DLGTIP_BACKMAIN"));

View File

@ -21,10 +21,6 @@
#include <C4Application.h>
#include <C4Log.h>
#if AUDIO_TK == AUDIO_TK_FMOD
#include <fmod_errors.h>
#endif
#if AUDIO_TK == AUDIO_TK_OPENAL
#if defined(__APPLE__)
#import <CoreFoundation/CoreFoundation.h>
@ -74,245 +70,7 @@ bool C4MusicFile::Init(const char *szFile)
return true;
}
#if AUDIO_TK == AUDIO_TK_FMOD
bool C4MusicFileMID::Play(bool loop, double max_resume_time)
{
// check existance
if (!FileExists(FileName))
// try extracting it
if (!ExtractFile())
// doesn't exist - or file is corrupt
return false;
// init fmusic
mod = FMUSIC_LoadSong(SongExtracted ? Config.AtTempPath(C4CFN_TempMusic2) : FileName);
if (!mod)
{
LogF("FMod: %s", FMOD_ErrorString(FSOUND_GetError()));
return false;
}
// Play Song
FMUSIC_PlaySong(mod);
return true;
}
void C4MusicFileMID::Stop(int fadeout_ms)
{
if (mod)
{
FMUSIC_StopSong(mod);
FMUSIC_FreeSong(mod);
mod = NULL;
}
RemTempFile();
}
void C4MusicFileMID::CheckIfPlaying()
{
if (FMUSIC_IsFinished(mod))
Application.MusicSystem.NotifySuccess();
}
void C4MusicFileMID::SetVolume(int iLevel)
{
FMUSIC_SetMasterVolume(mod, Clamp((iLevel * 256) / 100, 0, 255));
}
/* MOD */
C4MusicFileMOD::C4MusicFileMOD()
: mod(NULL), Data(NULL)
{
}
C4MusicFileMOD::~C4MusicFileMOD()
{
Stop();
}
bool C4MusicFileMOD::Play(bool loop, double max_resume_time)
{
// Load Song
size_t iFileSize;
if (!C4Group_ReadFile(FileName, &Data, &iFileSize))
return false;
// init fmusic
mod = FMUSIC_LoadSongEx(Data, 0, iFileSize, FSOUND_LOADMEMORY, 0, 0);
if (!mod)
{
LogF("FMod: %s", FMOD_ErrorString(FSOUND_GetError()));
return false;
}
// Play Song
FMUSIC_PlaySong(mod);
return true;
}
void C4MusicFileMOD::Stop(int fadeout_ms)
{
if (mod)
{
FMUSIC_StopSong(mod);
FMUSIC_FreeSong(mod);
mod = NULL;
}
if (Data) { delete[] Data; Data = NULL; }
}
void C4MusicFileMOD::CheckIfPlaying()
{
if (FMUSIC_IsFinished(mod))
Application.MusicSystem.NotifySuccess();
}
void C4MusicFileMOD::SetVolume(int iLevel)
{
FMUSIC_SetMasterVolume(mod, (int) ((iLevel * 255) / 100));
}
/* MP3 */
C4MusicFileMP3::C4MusicFileMP3()
: stream(NULL), Data(NULL), Channel(-1)
{
}
C4MusicFileMP3::~C4MusicFileMP3()
{
Stop();
}
bool C4MusicFileMP3::Play(bool loop, double max_resume_time)
{
#ifndef USE_MP3
return false;
#endif
// Load Song
size_t iFileSize;
if (!C4Group_ReadFile(FileName, &Data, &iFileSize))
return false;
// init fsound
int loop_flag = loop ? FSOUND_LOOP_NORMAL : 0;
stream = FSOUND_Stream_Open(Data, FSOUND_LOADMEMORY | FSOUND_NORMAL | FSOUND_2D | loop_flag, 0, iFileSize);
if (!stream) return false;
// Play Song
Channel = FSOUND_Stream_Play(FSOUND_FREE, stream);
if (Channel == -1) return false;
// Set highest priority
if (!FSOUND_SetPriority(Channel, 255))
return false;
return true;
}
void C4MusicFileMP3::Stop(int fadeout_ms)
{
if (stream)
{
FSOUND_Stream_Close(stream);
stream = NULL;
}
if (Data) { delete[] Data; Data = NULL; }
}
void C4MusicFileMP3::CheckIfPlaying()
{
if (FSOUND_Stream_GetPosition(stream) >= (unsigned) FSOUND_Stream_GetLength(stream))
Application.MusicSystem.NotifySuccess();
}
void C4MusicFileMP3::SetVolume(int iLevel)
{
FSOUND_SetVolume(Channel, (int) ((iLevel * 255) / 100));
}
/* Ogg Vobis */
C4MusicFileOgg::C4MusicFileOgg()
: stream(NULL), Data(NULL), Channel(-1), Playing(false)
{
}
C4MusicFileOgg::~C4MusicFileOgg()
{
Stop();
}
bool C4MusicFileOgg::Play(bool loop, double max_resume_time)
{
// Load Song
size_t iFileSize;
if (!C4Group_ReadFile(FileName, &Data, &iFileSize))
return false;
// init fsound
int loop_flag = loop ? FSOUND_LOOP_NORMAL : 0;
stream = FSOUND_Stream_Open(Data, FSOUND_LOADMEMORY | FSOUND_NORMAL | FSOUND_2D | loop_flag, 0, iFileSize);
if (!stream) return false;
// Play Song
Channel = FSOUND_Stream_Play(FSOUND_FREE, stream);
if (Channel == -1) return false;
// Set highest priority
if (!FSOUND_SetPriority(Channel, 255))
return false;
Playing = true;
FSOUND_Stream_SetEndCallback(stream, &C4MusicFileOgg::OnEnd, this);
return true;
}
// End Callback
signed char __stdcall C4MusicFileOgg::OnEnd(FSOUND_STREAM* stream, void* buff, int length, void *param)
{
C4MusicFileOgg* pFile = static_cast<C4MusicFileOgg*>(param);
pFile->Playing = false;
return 0;
}
void C4MusicFileOgg::Stop(int fadeout_ms)
{
if (stream)
{
FSOUND_Stream_Close(stream);
stream = NULL;
}
if (Data) { delete[] Data; Data = NULL; }
Playing = false;
}
void C4MusicFileOgg::CheckIfPlaying()
{
if (!Playing)
Application.MusicSystem.NotifySuccess();
}
void C4MusicFileOgg::SetVolume(int iLevel)
{
FSOUND_SetVolume(Channel, (int) ((iLevel * 255) / 100));
}
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
C4MusicFileSDL::C4MusicFileSDL():
Data(NULL),
Music(NULL)

View File

@ -64,74 +64,8 @@ protected:
bool SongExtracted;
};
#if AUDIO_TK == AUDIO_TK_FMOD
class C4MusicFileMID : public C4MusicFile
{
public:
bool Play(bool loop = false, double max_resume_time = 0.0);
bool Extract();
void Stop(int fadeout_ms = 0);
void CheckIfPlaying();
void SetVolume(int);
protected:
FMUSIC_MODULE *mod;
};
/* MOD class */
class C4MusicFileMOD : public C4MusicFile
{
public:
C4MusicFileMOD();
~C4MusicFileMOD();
bool Play(bool loop = false, double max_resume_time = 0.0);
void Stop(int fadeout_ms = 0);
void CheckIfPlaying();
void SetVolume(int);
protected:
FMUSIC_MODULE *mod;
char *Data;
};
/* MP3 class */
class C4MusicFileMP3 : public C4MusicFile
{
public:
C4MusicFileMP3();
~C4MusicFileMP3();
bool Play(bool loop = false, double max_resume_time = 0.0);
void Stop(int fadeout_ms = 0);
void CheckIfPlaying();
void SetVolume(int);
protected:
FSOUND_STREAM *stream;
char *Data;
int Channel;
};
/* Ogg class */
class C4MusicFileOgg : public C4MusicFile
{
public:
C4MusicFileOgg();
~C4MusicFileOgg();
bool Play(bool loop = false, double max_resume_time = 0.0);
void Stop(int fadeout_ms = 0);
void CheckIfPlaying();
void SetVolume(int);
static signed char __stdcall OnEnd(FSOUND_STREAM* stream, void* buff, int length, void* param);
protected:
FSOUND_STREAM *stream;
char *Data;
int Channel;
bool Playing;
};
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
typedef struct _Mix_Music Mix_Music;
class C4MusicFileSDL : public C4MusicFile
{

View File

@ -60,41 +60,7 @@ void C4MusicSystem::SelectContext()
bool C4MusicSystem::InitializeMOD()
{
#if AUDIO_TK == AUDIO_TK_FMOD
#ifdef _WIN32
// Debug code
switch (Config.Sound.FMMode)
{
case 0:
FSOUND_SetOutput(FSOUND_OUTPUT_WINMM);
break;
case 1:
FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
#ifdef USE_WIN32_WINDOWS
FSOUND_SetHWND(Application.pWindow->hWindow);
#endif
break;
case 2:
FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
FSOUND_SetDriver(0);
break;
}
FSOUND_SetMixer(FSOUND_MIXER_QUALITY_AUTODETECT);
#endif
if (FSOUND_GetVersion() < FMOD_VERSION)
{
LogF("FMod: You are using the wrong DLL version! You should be using %.02f", FMOD_VERSION);
return false;
}
if (!FSOUND_Init(44100, 32, 0))
{
LogF("FMod: %s", FMOD_ErrorString(FSOUND_GetError()));
return false;
}
// ok
MODInitialized = true;
return true;
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
SDL_version compile_version;
const SDL_version * link_version;
MIX_VERSION(&compile_version);
@ -143,13 +109,7 @@ bool C4MusicSystem::InitializeMOD()
void C4MusicSystem::DeinitializeMOD()
{
#if AUDIO_TK == AUDIO_TK_FMOD
FSOUND_StopSound(FSOUND_ALL); /* to prevent some hangs in FMOD */
#ifdef DEBUG
Sleep(0);
#endif
FSOUND_Close();
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
Mix_CloseAudio();
SDL_Quit();
#elif AUDIO_TK == AUDIO_TK_OPENAL
@ -237,27 +197,6 @@ void C4MusicSystem::Load(const char *szFile)
// openal: Only ogg supported
const char *szExt = GetExtension(szFile);
if (SEqualNoCase(szExt, "ogg")) NewSong = new C4MusicFileOgg;
#elif AUDIO_TK == AUDIO_TK_FMOD
const char *szExt = GetExtension(szFile);
// get type
switch (GetMusicFileTypeByExtension(GetExtension(szFile)))
{
case MUSICTYPE_MOD:
if (MODInitialized) NewSong = new C4MusicFileMOD;
break;
case MUSICTYPE_MP3:
if (MODInitialized) NewSong = new C4MusicFileMP3;
break;
case MUSICTYPE_OGG:
if (MODInitialized) NewSong = new C4MusicFileOgg;
break;
case MUSICTYPE_MID:
if (MODInitialized)
NewSong = new C4MusicFileMID;
break;
default: return; // safety
}
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
if (GetMusicFileTypeByExtension(GetExtension(szFile)) == MUSICTYPE_UNKNOWN) return;
NewSong = new C4MusicFileSDL;
@ -680,7 +619,7 @@ MusicType GetMusicFileTypeByExtension(const char* ext)
{
if (SEqualNoCase(ext, "mid"))
return MUSICTYPE_MID;
#if AUDIO_TK == AUDIO_TK_FMOD || AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
else if (SEqualNoCase(ext, "xm") || SEqualNoCase(ext, "it") || SEqualNoCase(ext, "s3m") || SEqualNoCase(ext, "mod"))
return MUSICTYPE_MOD;
#ifdef USE_MP3

View File

@ -76,7 +76,7 @@ protected:
bool ScheduleWaitTime();
// FMod / SDL_mixer / OpenAL
// SDL_mixer / OpenAL
bool MODInitialized;
bool InitializeMOD();
void DeinitializeMOD();

View File

@ -18,11 +18,7 @@
#ifndef INC_C4SoundIncludes
#define INC_C4SoundIncludes
#if AUDIO_TK == AUDIO_TK_FMOD
# include <fmod.h>
typedef FSOUND_SAMPLE* C4SoundHandle;
# include <fmod_errors.h>
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
# define USE_RWOPS
# include <SDL_mixer.h>
# undef USE_RWOPS

View File

@ -48,9 +48,7 @@ C4SoundEffect::~C4SoundEffect()
void C4SoundEffect::Clear()
{
while (FirstInst) RemoveInst(FirstInst);
#if AUDIO_TK == AUDIO_TK_FMOD
if (pSample) FSOUND_Sample_Free(pSample);
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
if (pSample) Mix_FreeChunk(pSample);
#elif AUDIO_TK == AUDIO_TK_OPENAL
if (pSample) alDeleteBuffers(1, &pSample);
@ -271,20 +269,7 @@ bool C4SoundInstance::CheckStart()
bool C4SoundInstance::Start()
{
#if AUDIO_TK == AUDIO_TK_FMOD
// Start
if ((iChannel = FSOUND_PlaySound(FSOUND_FREE, pEffect->pSample)) == -1)
return false;
if (!FSOUND_SetLoopMode(iChannel, fLooping ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF))
{ Stop(); return false; }
// set position
if (C4TimeMilliseconds::Now() > tStarted + 20)
{
assert(pEffect->Length > 0);
int32_t iTime = (C4TimeMilliseconds::Now() - tStarted) % pEffect->Length;
FSOUND_SetCurrentPosition(iChannel, iTime / 10 * pEffect->SampleRate / 100);
}
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
// Be paranoid about SDL_Mixer initialisation
if (!Application.MusicSystem.MODInitialized) return false;
if ((iChannel = Mix_PlayChannel(-1, pEffect->pSample, fLooping? -1 : 0)) == -1)
@ -311,10 +296,7 @@ bool C4SoundInstance::Stop()
if (!pEffect) return false;
// Stop sound
bool fRet = true;
#if AUDIO_TK == AUDIO_TK_FMOD
if (Playing())
fRet = !! FSOUND_StopSound(iChannel);
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
// iChannel == -1 will halt all channels. Is that right?
if (Playing())
Mix_HaltChannel(iChannel);
@ -336,10 +318,7 @@ bool C4SoundInstance::Playing()
{
if (!pEffect) return false;
if (fLooping) return true;
#if AUDIO_TK == AUDIO_TK_FMOD
return isStarted() ? FSOUND_GetCurrentSample(iChannel) == pEffect->pSample
: C4TimeMilliseconds::Now() < tStarted + pEffect->Length;
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
return Application.MusicSystem.MODInitialized && (iChannel != -1) && Mix_Playing(iChannel);
#elif AUDIO_TK == AUDIO_TK_OPENAL
if (iChannel == -1)
@ -379,9 +358,7 @@ void C4SoundInstance::Execute()
// stop, if started
if (isStarted())
{
#if AUDIO_TK == AUDIO_TK_FMOD
FSOUND_StopSound(iChannel);
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
Mix_HaltChannel(iChannel);
#elif AUDIO_TK == AUDIO_TK_OPENAL
alDeleteSources(1, (ALuint*)&iChannel);
@ -396,10 +373,7 @@ void C4SoundInstance::Execute()
if (!CheckStart())
return;
// set volume & panning
#if AUDIO_TK == AUDIO_TK_FMOD
FSOUND_SetVolume(iChannel, Clamp(iVol / 100, 0, 255));
FSOUND_SetPan(iChannel, Clamp(256*(iPan+100)/200,0,255));
#elif AUDIO_TK == AUDIO_TK_SDL_MIXER
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
Mix_Volume(iChannel, (iVol * MIX_MAX_VOLUME) / (100 * 256));
Mix_SetPanning(iChannel, Clamp((100 - iPan) * 256 / 100, 0, 255), Clamp((100 + iPan) * 256 / 100, 0, 255));
#elif AUDIO_TK == AUDIO_TK_OPENAL

View File

@ -300,29 +300,4 @@ bool SDLMixerSoundLoader::ReadInfo(SoundInfo* result, BYTE* data, size_t data_le
SDLMixerSoundLoader SDLMixerSoundLoader::singleton;
#elif AUDIO_TK == AUDIO_TK_FMOD
bool FMODSoundLoader::ReadInfo(SoundInfo* result, BYTE* data, size_t data_length, uint32_t options)
{
int32_t iOptions = FSOUND_NORMAL | FSOUND_2D | FSOUND_LOADMEMORY;
if (options & OPTION_Raw)
iOptions |= FSOUND_LOADRAW;
C4SoundHandle pSample;
if (!(pSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, (const char *)data, iOptions, 0, data_length)))
{ return false; }
// get length
int32_t iSamples = FSOUND_Sample_GetLength(pSample);
int iSampleRate = 0;
if (!iSamples || !FSOUND_Sample_GetDefaults(pSample, &iSampleRate, 0, 0, 0))
{
FSOUND_Sample_Free(pSample);
return false;
}
result->sample_rate = iSampleRate;
result->sample_length = static_cast<double>(iSamples) / iSampleRate;
result->final_handle = pSample;
assert(result->sample_length > 0);
return true;
}
FMODSoundLoader FMODSoundLoader::singleton;
#endif

View File

@ -115,14 +115,6 @@ namespace C4SoundLoaders
static SDLMixerSoundLoader singleton;
virtual bool ReadInfo(SoundInfo* result, BYTE* data, size_t data_length, uint32_t);
};
#elif AUDIO_TK == AUDIO_TK_FMOD
class FMODSoundLoader: public SoundLoader
{
public:
static FMODSoundLoader singleton;
virtual bool ReadInfo(SoundInfo* result, BYTE* data, size_t data_length, uint32_t options);
};
#endif
}

View File

@ -15,7 +15,7 @@
* for the above references.
*/
/* Handles the sound bank and plays effects using FMOD */
/* Plays sound effects */
#ifndef INC_C4SoundModifiers
#define INC_C4SoundModifiers

View File

@ -15,7 +15,7 @@
* for the above references.
*/
/* Handles the sound bank and plays effects using FMOD */
/* Handles the sound bank and plays effects */
#ifndef INC_C4SoundSystem
#define INC_C4SoundSystem

View File

@ -296,7 +296,7 @@ BYTE *CStdAVIFile::GetAudioStreamData(size_t *piStreamLength)
if (AVIStreamRead(pAudioStream, 0, AVIStreamLength(pAudioStream), NULL, 0, &iAudioDataLength, NULL)) return NULL;
if (iAudioDataLength<=0) return NULL;
// make sure current audio data buffer is large enoiugh to hold the data
// preceding return data with the RIFF+waveformat structure here, so it can be easily loaded by fmod
// preceding return data with the RIFF+waveformat structure here
uint32_t iHeaderLength = iAudioInfoLength + sizeof(FOURCC) * 4 + 3 * sizeof(uint32_t);
LONG iReturnDataLength = iAudioDataLength + iHeaderLength;
if (iAudioBufferLength < iReturnDataLength)