Pass the device to aluMixData
This commit is contained in:
parent
12f81bcbb9
commit
9f037e8980
14
Alc/ALu.c
14
Alc/ALu.c
@ -1200,15 +1200,16 @@ another_source:
|
||||
goto another_source;
|
||||
}
|
||||
|
||||
ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum format)
|
||||
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
|
||||
{
|
||||
static float DryBuffer[BUFFERSIZE][OUTPUTCHANNELS];
|
||||
ALuint SamplesToDo;
|
||||
ALeffectslot *ALEffectSlot;
|
||||
ALCcontext *ALContext;
|
||||
int fpuState;
|
||||
ALuint i;
|
||||
|
||||
SuspendContext(ALContext);
|
||||
SuspendContext(NULL);
|
||||
|
||||
#if defined(HAVE_FESETROUND)
|
||||
fpuState = fegetround();
|
||||
@ -1228,6 +1229,7 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
|
||||
/* Clear mixing buffer */
|
||||
memset(DryBuffer, 0, SamplesToDo*OUTPUTCHANNELS*sizeof(ALfloat));
|
||||
|
||||
ALContext = device->Context;
|
||||
if(ALContext)
|
||||
{
|
||||
MixSomeSources(ALContext, DryBuffer, SamplesToDo);
|
||||
@ -1246,7 +1248,7 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
|
||||
}
|
||||
|
||||
//Post processing loop
|
||||
switch(format)
|
||||
switch(device->Format)
|
||||
{
|
||||
#define CHECK_WRITE_FORMAT(bits, type, func, isWin) \
|
||||
case AL_FORMAT_MONO##bits: \
|
||||
@ -1258,14 +1260,14 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
|
||||
} \
|
||||
break; \
|
||||
case AL_FORMAT_STEREO##bits: \
|
||||
if(ALContext && ALContext->Device->Bs2b) \
|
||||
if(device->Bs2b) \
|
||||
{ \
|
||||
for(i = 0;i < SamplesToDo;i++) \
|
||||
{ \
|
||||
float samples[2]; \
|
||||
samples[0] = DryBuffer[i][FRONT_LEFT]; \
|
||||
samples[1] = DryBuffer[i][FRONT_RIGHT]; \
|
||||
bs2b_cross_feed(ALContext->Device->Bs2b, samples); \
|
||||
bs2b_cross_feed(device->Bs2b, samples); \
|
||||
((type*)buffer)[0] = (func)(samples[0]); \
|
||||
((type*)buffer)[1] = (func)(samples[1]); \
|
||||
buffer = ((type*)buffer) + 2; \
|
||||
@ -1374,7 +1376,7 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
|
||||
_controlfp(fpuState, 0xfffff);
|
||||
#endif
|
||||
|
||||
ProcessContext(ALContext);
|
||||
ProcessContext(NULL);
|
||||
}
|
||||
|
||||
ALvoid aluHandleDisconnect(ALCdevice *device)
|
||||
|
14
Alc/alsa.c
14
Alc/alsa.c
@ -217,29 +217,25 @@ static ALuint ALSAProc(ALvoid *ptr)
|
||||
{
|
||||
frames = avail;
|
||||
|
||||
SuspendContext(NULL);
|
||||
err = psnd_pcm_mmap_begin(data->pcmHandle, &areas, &offset, &frames);
|
||||
if (err < 0)
|
||||
{
|
||||
err = xrun_recovery(data->pcmHandle, err);
|
||||
if (err < 0)
|
||||
AL_PRINT("mmap begin error: %s\n", psnd_strerror(err));
|
||||
ProcessContext(NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
WritePtr = (char*)areas->addr + (offset * areas->step / 8);
|
||||
aluMixData(pDevice->Context, WritePtr, frames, pDevice->Format);
|
||||
aluMixData(pDevice, WritePtr, frames);
|
||||
|
||||
commitres = psnd_pcm_mmap_commit(data->pcmHandle, offset, frames);
|
||||
if (commitres < 0 || (commitres-frames) != 0)
|
||||
{
|
||||
AL_PRINT("mmap commit error: %s\n",
|
||||
psnd_strerror(commitres >= 0 ? -EPIPE : commitres));
|
||||
ProcessContext(NULL);
|
||||
break;
|
||||
}
|
||||
ProcessContext(NULL);
|
||||
|
||||
avail -= frames;
|
||||
}
|
||||
@ -265,12 +261,10 @@ static ALuint ALSANoMMapProc(ALvoid *ptr)
|
||||
break;
|
||||
}
|
||||
|
||||
avail = data->size / psnd_pcm_frames_to_bytes(data->pcmHandle, 1);
|
||||
SuspendContext(NULL);
|
||||
aluMixData(pDevice->Context, data->buffer, avail, pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
|
||||
WritePtr = data->buffer;
|
||||
avail = data->size / psnd_pcm_frames_to_bytes(data->pcmHandle, 1);
|
||||
aluMixData(pDevice, WritePtr, avail);
|
||||
|
||||
while(avail > 0)
|
||||
{
|
||||
int ret = psnd_pcm_writei(data->pcmHandle, WritePtr, avail);
|
||||
|
11
Alc/dsound.c
11
Alc/dsound.c
@ -84,6 +84,7 @@ static ALuint DSoundProc(ALvoid *ptr)
|
||||
DWORD PlayCursor;
|
||||
VOID *WritePtr1, *WritePtr2;
|
||||
DWORD WriteCnt1, WriteCnt2;
|
||||
DWORD FrameSize;
|
||||
DWORD FragSize;
|
||||
DWORD avail;
|
||||
HRESULT err;
|
||||
@ -94,10 +95,14 @@ static ALuint DSoundProc(ALvoid *ptr)
|
||||
if(FAILED(err))
|
||||
{
|
||||
AL_PRINT("Failed to get buffer caps: 0x%lx\n", err);
|
||||
aluHandleDisconnect(pDevice);
|
||||
return 1;
|
||||
}
|
||||
FragSize = DSBCaps.dwBufferBytes / num_frags;
|
||||
|
||||
FrameSize = aluChannelsFromFormat(pDevice->Format) *
|
||||
aluBytesFromFormat(pDevice->Format);
|
||||
|
||||
IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer, &LastCursor, NULL);
|
||||
while(!pData->killNow)
|
||||
{
|
||||
@ -131,10 +136,8 @@ static ALuint DSoundProc(ALvoid *ptr)
|
||||
if(SUCCEEDED(err))
|
||||
{
|
||||
// If we have an active context, mix data directly into output buffer otherwise fill with silence
|
||||
SuspendContext(NULL);
|
||||
aluMixData(pDevice->Context, WritePtr1, WriteCnt1/DSBCaps.nBlockAlign, pDevice->Format);
|
||||
aluMixData(pDevice->Context, WritePtr2, WriteCnt2/DSBCaps.nBlockAlign, pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
aluMixData(pDevice, WritePtr1, WriteCnt1/FrameSize);
|
||||
aluMixData(pDevice, WritePtr2, WriteCnt2/FrameSize);
|
||||
|
||||
// Unlock output buffer only when successfully locked
|
||||
IDirectSoundBuffer_Unlock(pData->DSsbuffer, WritePtr1, WriteCnt1, WritePtr2, WriteCnt2);
|
||||
|
@ -90,10 +90,7 @@ static ALuint OSSProc(ALvoid *ptr)
|
||||
ALint len = data->data_size;
|
||||
ALubyte *WritePtr = data->mix_data;
|
||||
|
||||
SuspendContext(NULL);
|
||||
aluMixData(pDevice->Context, WritePtr, len/frameSize, pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
|
||||
aluMixData(pDevice, WritePtr, len/frameSize);
|
||||
while(len > 0 && !data->killNow)
|
||||
{
|
||||
wrote = write(data->fd, WritePtr, len);
|
||||
|
@ -61,10 +61,7 @@ static int pa_callback(const void *inputBuffer, void *outputBuffer,
|
||||
(void)timeInfo;
|
||||
(void)statusFlags;
|
||||
|
||||
SuspendContext(NULL);
|
||||
aluMixData(device->Context, outputBuffer, framesPerBuffer, device->Format);
|
||||
ProcessContext(NULL);
|
||||
|
||||
aluMixData(device, outputBuffer, framesPerBuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -172,10 +172,7 @@ static void stream_write_callback(pa_stream *stream, size_t len, void *pdata) //
|
||||
pulse_data *data = Device->ExtraData;
|
||||
void *buf = ppa_xmalloc0(len);
|
||||
|
||||
SuspendContext(NULL);
|
||||
aluMixData(Device->Context, buf, len/data->frame_size, Device->Format);
|
||||
ProcessContext(NULL);
|
||||
|
||||
aluMixData(Device, buf, len/data->frame_size);
|
||||
ppa_stream_write(stream, buf, len, ppa_xfree, 0, PA_SEEK_RELATIVE);
|
||||
} //}}}
|
||||
|
||||
|
@ -65,10 +65,7 @@ static ALuint SolarisProc(ALvoid *ptr)
|
||||
ALint len = data->data_size;
|
||||
ALubyte *WritePtr = data->mix_data;
|
||||
|
||||
SuspendContext(NULL);
|
||||
aluMixData(pDevice->Context, WritePtr, len/frameSize, pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
|
||||
aluMixData(pDevice, WritePtr, len/frameSize);
|
||||
while(len > 0 && !data->killNow)
|
||||
{
|
||||
wrote = write(data->fd, WritePtr, len);
|
||||
|
@ -74,10 +74,7 @@ static ALuint WaveProc(ALvoid *ptr)
|
||||
|
||||
while(avail >= pDevice->UpdateSize)
|
||||
{
|
||||
SuspendContext(NULL);
|
||||
aluMixData(pDevice->Context, data->buffer, pDevice->UpdateSize,
|
||||
pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
aluMixData(pDevice, data->buffer, pDevice->UpdateSize);
|
||||
|
||||
if(uSB.b[0] != 1 && aluBytesFromFormat(pDevice->Format) > 1)
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ static __inline ALuint aluChannelsFromFormat(ALenum format)
|
||||
}
|
||||
|
||||
ALvoid aluInitPanning(ALCcontext *Context);
|
||||
ALvoid aluMixData(ALCcontext *context,ALvoid *buffer,ALsizei size,ALenum format);
|
||||
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size);
|
||||
ALvoid aluHandleDisconnect(ALCdevice *device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user