Skip to content

Commit

Permalink
Next on the list is adding a few more arguments for certain functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachBacon committed Dec 25, 2018
1 parent a8c4436 commit 8939455
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/wx/faudio.cpp
Expand Up @@ -304,11 +304,11 @@ void FAudio_Output::close()

if (sVoice) {
if (playing) {
HRESULT hr = sVoice->FAudioSourceVoice_Stop(0);
HRESULT hr = FAudioSourceVoice_Stop(sVoice, 0);
assert(hr == S_OK);
}

sVoice->FAudioVoice_DestroyVoice();
FAudioVoice_DestroyVoice(sVoice);
sVoice = NULL;
}

Expand All @@ -318,7 +318,7 @@ void FAudio_Output::close()
}

if (mVoice) {
mVoice->FAudioVoice_DestroyVoice();
FAudioVoice_DestroyVoice(mVoice);
mVoice = NULL;
}

Expand Down Expand Up @@ -369,7 +369,8 @@ bool FAudio_Output::init(long sampleRate)
wfx.nBlockAlign = wfx.nChannels * (wfx.wBitsPerSample / 8);
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
// create sound receiver
hr = faud->FAudio_CreateMasteringVoice(
hr = FAudio_CreateMasteringVoice(
faud,
&mVoice,
FAUDIO_DEFAULT_CHANNELS,
FAUDIO_DEFAULT_SAMPLERATE,
Expand All @@ -386,7 +387,7 @@ bool FAudio_Output::init(long sampleRate)
// create sound emitter
//This should be FAudio_CreateSourceVoice()
//hr = faud->CreateSourceVoice(&sVoice, &wfx, 0, 4.0f, &notify);
hr = faud->FAudio_CreateSourceVoice(&sVoice, &wfx, 0, 4.0f, &notify);
hr = FAudio_CreateSourceVoice(faud, &sVoice, &wfx, 0, 4.0f, &notify);

if (hr != S_OK) {
wxLogError(_("FAudio: Creating source voice failed!"));
Expand All @@ -398,7 +399,7 @@ bool FAudio_Output::init(long sampleRate)
// set up stereo upmixing
FAudioDeviceDetails dd;
ZeroMemory(&dd, sizeof(dd));
hr = faud->FAudio_GetDeviceDetails(0, &dd);
hr = FAudio_GetDeviceDetails(faud, 0, &dd);
assert(hr == S_OK);
float* matrix = NULL;
matrix = (float*)malloc(sizeof(float) * 2 * dd.OutputFormat.Format.nChannels);
Expand Down Expand Up @@ -495,15 +496,15 @@ bool FAudio_Output::init(long sampleRate)
}

if (matrixAvailable) {
hr = sVoice->FAudioVoice_SetOutputMatrix(NULL, 2, dd.OutputFormat.Format.nChannels, matrix);
hr = FAudioVoice_SetOutputMatrix(sVoice, NULL, 2, dd.OutputFormat.Format.nChannels, matrix);
assert(hr == S_OK);
}

free(matrix);
matrix = NULL;
}

hr = sVoice->FAudioSourceVoice_Start(0);
hr = FAudioSourceVoice_Start(sVoice, 0);
assert(hr == S_OK);
playing = true;
currentBuffer = 0;
Expand All @@ -525,7 +526,7 @@ void FAudio_Output::write(uint16_t* finalWave, int length)
return;
}

sVoice->FAudioSourceVoice_GetState(&vState);
FAudioSourceVoice_GetState(sVoice, &vState);
assert(vState.BuffersQueued <= bufferCount);

if (vState.BuffersQueued < bufferCount) {
Expand Down Expand Up @@ -559,7 +560,7 @@ void FAudio_Output::write(uint16_t* finalWave, int length)
buf.pAudioData = &buffers[currentBuffer * soundBufferLen];
currentBuffer++;
currentBuffer %= (bufferCount + 1); // + 1 because we need one temporary buffer
HRESULT hr = sVoice->SubmitSourceBuffer(&buf); // send buffer to queue
HRESULT hr = FAudioSourceVoice_SubmitSourceBuffer(sVoice, &buf); // send buffer to queue
assert(hr == S_OK);
}

Expand All @@ -569,7 +570,7 @@ void FAudio_Output::pause()
return;

if (playing) {
HRESULT hr = sVoice->FAudioSourceVoice_Stop(0);
HRESULT hr = FAudioSourceVoice_Stop(sVoice, 0);
assert(hr == S_OK);
playing = false;
}
Expand All @@ -581,7 +582,7 @@ void FAudio_Output::resume()
return;

if (!playing) {
HRESULT hr = sVoice->FAudioSourceVoice_Start(0);
HRESULT hr = FAudioSourceVoice_Start(sVoice, 0);
assert(hr == S_OK);
playing = true;
}
Expand All @@ -593,12 +594,12 @@ void FAudio_Output::reset()
return;

if (playing) {
HRESULT hr = sVoice->FAudioSourceVoice_Stop(0);
HRESULT hr = FAudioSourceVoice_Stop(sVoice, 0);
assert(hr == S_OK);
}

sVoice->FlushSourceBuffers();
sVoice->FAudioSourceVoice_Start(0);
FAudioSourceVoice_FlushSourceBuffers(sVoice);
FAudioSourceVoice_Start(sVoice, 0);
playing = true;
}

Expand All @@ -610,7 +611,7 @@ void FAudio_Output::setThrottle(unsigned short throttle_)
if (throttle_ == 0)
throttle_ = 100;

HRESULT hr = sVoice->SetFrequencyRatio((float)throttle_ / 100.0f);
HRESULT hr = FAudioSourceVoice_SetFrequencyRatio(sVoice, (float)throttle_ / 100.0f);
assert(hr == S_OK);
}

Expand Down

0 comments on commit 8939455

Please sign in to comment.