Pass the frame count to aluMixData

This commit is contained in:
Chris Robinson 2009-09-15 18:19:00 -07:00
parent eeea9631ce
commit 6636131d3b
8 changed files with 19 additions and 22 deletions

View File

@ -1205,7 +1205,6 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
static float DryBuffer[BUFFERSIZE][OUTPUTCHANNELS];
ALuint SamplesToDo;
ALeffectslot *ALEffectSlot;
ALuint BlockAlign;
int fpuState;
ALuint i;
@ -1221,11 +1220,6 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
(void)fpuState;
#endif
/* Figure output format variables */
BlockAlign = aluChannelsFromFormat(format);
BlockAlign *= aluBytesFromFormat(format);
size /= BlockAlign;
while(size > 0)
{
/* Setup variables */

View File

@ -166,7 +166,6 @@ static ALuint ALSAProc(ALvoid *ptr)
snd_pcm_sframes_t avail, commitres;
snd_pcm_uframes_t offset, frames;
char *WritePtr;
int WriteCnt;
int err;
while(!data->killNow)
@ -230,8 +229,7 @@ static ALuint ALSAProc(ALvoid *ptr)
}
WritePtr = (char*)areas->addr + (offset * areas->step / 8);
WriteCnt = psnd_pcm_frames_to_bytes(data->pcmHandle, frames);
aluMixData(pDevice->Context, WritePtr, WriteCnt, pDevice->Format);
aluMixData(pDevice->Context, WritePtr, frames, pDevice->Format);
commitres = psnd_pcm_mmap_commit(data->pcmHandle, offset, frames);
if (commitres < 0 || (commitres-frames) != 0)
@ -267,12 +265,12 @@ static ALuint ALSANoMMapProc(ALvoid *ptr)
break;
}
avail = data->size / psnd_pcm_frames_to_bytes(data->pcmHandle, 1);
SuspendContext(NULL);
aluMixData(pDevice->Context, data->buffer, data->size, pDevice->Format);
aluMixData(pDevice->Context, data->buffer, avail, pDevice->Format);
ProcessContext(NULL);
WritePtr = data->buffer;
avail = (snd_pcm_uframes_t)data->size / psnd_pcm_frames_to_bytes(data->pcmHandle, 1);
while(avail > 0)
{
int ret = psnd_pcm_writei(data->pcmHandle, WritePtr, avail);

View File

@ -132,8 +132,8 @@ static ALuint DSoundProc(ALvoid *ptr)
{
// If we have an active context, mix data directly into output buffer otherwise fill with silence
SuspendContext(NULL);
aluMixData(pDevice->Context, WritePtr1, WriteCnt1, pDevice->Format);
aluMixData(pDevice->Context, WritePtr2, WriteCnt2, pDevice->Format);
aluMixData(pDevice->Context, WritePtr1, WriteCnt1/DSBCaps.nBlockAlign, pDevice->Format);
aluMixData(pDevice->Context, WritePtr2, WriteCnt2/DSBCaps.nBlockAlign, pDevice->Format);
ProcessContext(NULL);
// Unlock output buffer only when successfully locked

View File

@ -79,15 +79,19 @@ static ALuint OSSProc(ALvoid *ptr)
{
ALCdevice *pDevice = (ALCdevice*)ptr;
oss_data *data = (oss_data*)pDevice->ExtraData;
ALint frameSize;
int wrote;
frameSize = aluChannelsFromFormat(pDevice->Format) *
aluBytesFromFormat(pDevice->Format);
while(!data->killNow && !pDevice->Connected)
{
ALint len = data->data_size;
ALubyte *WritePtr = data->mix_data;
SuspendContext(NULL);
aluMixData(pDevice->Context, WritePtr, len, pDevice->Format);
aluMixData(pDevice->Context, WritePtr, len/frameSize, pDevice->Format);
ProcessContext(NULL);
while(len > 0 && !data->killNow)

View File

@ -56,17 +56,13 @@ static int pa_callback(const void *inputBuffer, void *outputBuffer,
const PaStreamCallbackFlags statusFlags, void *userData)
{
ALCdevice *device = (ALCdevice*)userData;
int frameSize;
(void)inputBuffer;
(void)timeInfo;
(void)statusFlags;
frameSize = aluBytesFromFormat(device->Format);
frameSize *= aluChannelsFromFormat(device->Format);
SuspendContext(NULL);
aluMixData(device->Context, outputBuffer, framesPerBuffer*frameSize, device->Format);
aluMixData(device->Context, outputBuffer, framesPerBuffer, device->Format);
ProcessContext(NULL);
return 0;

View File

@ -169,10 +169,11 @@ static void context_state_callback(pa_context *context, void *pdata) //{{{
static void stream_write_callback(pa_stream *stream, size_t len, void *pdata) //{{{
{
ALCdevice *Device = pdata;
pulse_data *data = Device->ExtraData;
void *buf = ppa_xmalloc0(len);
SuspendContext(NULL);
aluMixData(Device->Context, buf, len, Device->Format);
aluMixData(Device->Context, buf, len/data->frame_size, Device->Format);
ProcessContext(NULL);
ppa_stream_write(stream, buf, len, ppa_xfree, 0, PA_SEEK_RELATIVE);

View File

@ -54,15 +54,19 @@ static ALuint SolarisProc(ALvoid *ptr)
ALCdevice *pDevice = (ALCdevice*)ptr;
solaris_data *data = (solaris_data*)pDevice->ExtraData;
int remaining = 0;
ALint frameSize;
int wrote;
frameSize = aluChannelsFromFormat(pDevice->Format) *
aluBytesFromFormat(pDevice->Format);
while(!data->killNow && !pDevice->Connected)
{
ALint len = data->data_size;
ALubyte *WritePtr = data->mix_data;
SuspendContext(NULL);
aluMixData(pDevice->Context, WritePtr, len, pDevice->Format);
aluMixData(pDevice->Context, WritePtr, len/frameSize, pDevice->Format);
ProcessContext(NULL);
while(len > 0 && !data->killNow)

View File

@ -75,7 +75,7 @@ static ALuint WaveProc(ALvoid *ptr)
while(avail >= pDevice->UpdateSize)
{
SuspendContext(NULL);
aluMixData(pDevice->Context, data->buffer, data->size,
aluMixData(pDevice->Context, data->buffer, pDevice->UpdateSize,
pDevice->Format);
ProcessContext(NULL);