Store the channel count and sample size in the voice

This commit is contained in:
Chris Robinson
2017-03-06 22:58:04 -08:00
parent bc0096365e
commit 190120dfd7
3 changed files with 13 additions and 17 deletions
+2 -2
View File
@@ -389,8 +389,8 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei
DataPosFrac = ATOMIC_LOAD(&voice->position_fraction, almemory_order_relaxed);
BufferListItem = ATOMIC_LOAD(&voice->current_buffer, almemory_order_relaxed);
Looping = ATOMIC_LOAD(&Source->looping, almemory_order_relaxed);
NumChannels = Source->NumChannels;
SampleSize = Source->SampleSize;
NumChannels = voice->NumChannels;
SampleSize = voice->SampleSize;
increment = voice->Step;
IrSize = (Device->Hrtf.Handle ? Device->Hrtf.Handle->irSize : 0);
+7 -4
View File
@@ -94,6 +94,13 @@ typedef struct ALvoice {
ATOMIC(ALuint) position;
ATOMIC(ALuint) position_fraction;
/**
* Number of channels and bytes-per-sample for the attached source's
* buffer(s).
*/
ALsizei NumChannels;
ALsizei SampleSize;
/** Current target parameters used for mixing. */
ALint Step;
@@ -197,10 +204,6 @@ typedef struct ALsource {
ATOMIC(ALboolean) looping;
/** Current buffer sample info. */
ALsizei NumChannels;
ALsizei SampleSize;
ALenum NeedsUpdate;
ATOMIC(struct ALsourceProps*) Update;
+4 -11
View File
@@ -719,11 +719,6 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
/* Source is now Static */
Source->SourceType = AL_STATIC;
ReadLock(&buffer->lock);
Source->NumChannels = ChannelsFromFmt(buffer->FmtChannels);
Source->SampleSize = BytesFromFmt(buffer->FmtType);
ReadUnlock(&buffer->lock);
}
else
{
@@ -2582,12 +2577,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint src, ALsizei nb, const ALu
IncrementRef(&buffer->ref);
if(BufferFmt == NULL)
{
BufferFmt = buffer;
source->NumChannels = ChannelsFromFmt(buffer->FmtChannels);
source->SampleSize = BytesFromFmt(buffer->FmtType);
}
else if(BufferFmt->Frequency != buffer->Frequency ||
BufferFmt->OriginalChannels != buffer->OriginalChannels ||
BufferFmt->OriginalType != buffer->OriginalType)
@@ -2990,6 +2980,7 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
{
ALCdevice *device = Context->Device;
ALbufferlistitem *BufferList;
ALbuffer *buffer = NULL;
ALsizei i;
/* Check that there is a queue containing at least one valid, non zero
@@ -2997,7 +2988,6 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
BufferList = ATOMIC_LOAD_SEQ(&Source->queue);
while(BufferList)
{
ALbuffer *buffer;
if((buffer=BufferList->buffer) != NULL && buffer->SampleLen > 0)
break;
BufferList = BufferList->next;
@@ -3064,6 +3054,9 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
if(Source->OffsetType != AL_NONE)
ApplyOffset(Source, voice);
voice->NumChannels = ChannelsFromFmt(buffer->FmtChannels);
voice->SampleSize = BytesFromFmt(buffer->FmtType);
/* Clear previous samples. */
memset(voice->PrevSamples, 0, sizeof(voice->PrevSamples));