1
當初始化FMOD時,Im有一個奇怪的問題,FMOD進入某種'無限循環'並且程序停止。我做錯了什麼? 這是函數:初始化FMOD時出現錯誤
FMOD::System *fmodsyst = 0;
FMOD::Sound *sound = 0;
FMOD::Channel *channel = 0;
FMOD_RESULT result = FMOD_OK;
unsigned int version = 0;
unsigned int soundlength = 0;
bool dspenabled = false;
void *extradriverdata = 0;
unsigned int recordpos = 0;
unsigned int recorddelta = 0;
unsigned int minrecorddelta = (unsigned int)-1;
unsigned int lastrecordpos = 0;
unsigned int samplesrecorded = 0;
unsigned int playpos = 0;
float smootheddelta = 0;
int recordrate = 0;
int recordchannels = 0;
unsigned int adjustedlatency = 0;
unsigned int driftthreshold = 0;
FMOD_CREATESOUNDEXINFO exinfo;
bool Basics::InitializeFMOD()
{
FMOD_RESULT result;
unsigned int version;
result = FMOD::System_Create(&fmodsyst);
FMOD_ERRCHECK(result);
result = fmodsyst->getVersion(&version);
FMOD_ERRCHECK(result);
if (version < FMOD_VERSION)
{
return false;
}
result = fmodsyst->init(100, FMOD_INIT_NORMAL, extradriverdata); //this is the line which crashes the .dll
FMOD_ERRCHECK(result);
result = fmodsyst->getRecordDriverInfo(0, NULL, NULL, 0, 0, &recordrate, 0, &recordchannels);
FMOD_ERRCHECK(result);
adjustedlatency = (recordrate * LATENCY_MS)/1000;
driftthreshold = adjustedlatency/2;
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = recordchannels;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.defaultfrequency = recordrate;
exinfo.length = exinfo.defaultfrequency * sizeof(short)* exinfo.numchannels * 5; /* 5 second buffer, doesnt really matter how big this is, but not too small of course. */
result = fmodsyst->createSound(0, FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);
FMOD_ERRCHECK(result);
result = fmodsyst->recordStart(0, sound, true);
FMOD_ERRCHECK(result);
result = sound->getLength(&soundlength, FMOD_TIMEUNIT_PCM);
FMOD_ERRCHECK(result);
return true;
}
而且功能FMOD_ERRCHECK犯規說什麼。
這實際線導致的嗎?嘗試減少你的代碼一個簡短的自包含的例子,只是一個主要的初始化代碼,看看你是否仍然有同樣的問題。 –
這是導致問題的線路:result = fmodsyst-> init(100,FMOD_INIT_NORMAL,extradriverdata); //這是導致.dll崩潰的那一行 - 我使用WriteToLog函數應用了一些調試,並且這部分被拖動。 – user3145274
您沒有提供'extradriverdata'的定義,但您提供了許多不相關的代碼。請編輯您的問題到最低_complete_代碼來重現問題。 –