Create and use a MidiSynth on playback devices

This commit is contained in:
Chris Robinson
2013-11-27 18:52:56 -08:00
parent 5554b8cfc9
commit 182b08d8bc
2 changed files with 28 additions and 0 deletions
+25
View File
@@ -30,6 +30,7 @@
#include "alMain.h"
#include "alSource.h"
#include "alListener.h"
#include "alMidi.h"
#include "alThunk.h"
#include "alSource.h"
#include "alBuffer.h"
@@ -1773,6 +1774,8 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->PendingClicks[i] = 0.0f;
}
V(device->Synth,update)(device);
device->Hrtf = NULL;
if(device->Type != Loopback && ConfigValueExists(NULL, "hrtf"))
{
@@ -1899,6 +1902,9 @@ static ALCvoid FreeDevice(ALCdevice *device)
DELETE_OBJ(device->Backend);
device->Backend = NULL;
DELETE_OBJ(device->Synth);
device->Synth = NULL;
if(device->DefaultSlot)
{
ALeffectState *state = device->DefaultSlot->EffectState;
@@ -3024,9 +3030,19 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
device->NumStereoSources = 1;
device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources;
device->Synth = SynthCreate(device);
if(!device->Synth)
{
DELETE_OBJ(device->Backend);
al_free(device);
alcSetError(NULL, ALC_OUT_OF_MEMORY);
return NULL;
}
// Find a playback device to open
if((err=V(device->Backend,open)(deviceName)) != ALC_NO_ERROR)
{
DELETE_OBJ(device->Synth);
DELETE_OBJ(device->Backend);
al_free(device);
alcSetError(NULL, err);
@@ -3344,6 +3360,15 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN
device->NumStereoSources = 1;
device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources;
device->Synth = SynthCreate(device);
if(!device->Synth)
{
DELETE_OBJ(device->Backend);
al_free(device);
alcSetError(NULL, ALC_OUT_OF_MEMORY);
return NULL;
}
// Open the "backend"
V(device->Backend,open)("Loopback");
do {
+3
View File
@@ -31,6 +31,7 @@
#include "alBuffer.h"
#include "alListener.h"
#include "alAuxEffectSlot.h"
#include "alMidi.h"
#include "alu.h"
#include "bs2b.h"
@@ -1028,6 +1029,8 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
memset(device->DryBuffer[c], 0, SamplesToDo*sizeof(ALfloat));
ALCdevice_Lock(device);
V(device->Synth,process)(SamplesToDo, device->DryBuffer);
ctx = device->ContextList;
while(ctx)
{