Avoid calling through the vtable in the backends

This commit is contained in:
Chris Robinson 2018-11-13 18:05:10 -08:00
parent 0dfb805fa2
commit 7088f4e34a
5 changed files with 27 additions and 27 deletions

View File

@ -257,9 +257,9 @@ FORCE_ALIGN static int ALCdsoundPlayback_mixerProc(ALCdsoundPlayback *self)
if(FAILED(err))
{
ERR("Failed to get buffer caps: 0x%lx\n", err);
ALCdevice_Lock(device);
ALCdsoundPlayback_lock(self);
aluHandleDisconnect(device, "Failure retrieving playback buffer info: 0x%lx", err);
ALCdevice_Unlock(device);
ALCdsoundPlayback_unlock(self);
return 1;
}
@ -285,9 +285,9 @@ FORCE_ALIGN static int ALCdsoundPlayback_mixerProc(ALCdsoundPlayback *self)
if(FAILED(err))
{
ERR("Failed to play buffer: 0x%lx\n", err);
ALCdevice_Lock(device);
ALCdsoundPlayback_lock(self);
aluHandleDisconnect(device, "Failure starting playback: 0x%lx", err);
ALCdevice_Unlock(device);
ALCdsoundPlayback_unlock(self);
return 1;
}
Playing = true;
@ -323,10 +323,10 @@ FORCE_ALIGN static int ALCdsoundPlayback_mixerProc(ALCdsoundPlayback *self)
if(SUCCEEDED(err))
{
// If we have an active context, mix data directly into output buffer otherwise fill with silence
ALCdevice_Lock(device);
ALCdsoundPlayback_lock(self);
aluMixData(device, WritePtr1, WriteCnt1/FrameSize);
aluMixData(device, WritePtr2, WriteCnt2/FrameSize);
ALCdevice_Unlock(device);
ALCdsoundPlayback_unlock(self);
// Unlock output buffer only when successfully locked
Buffer->Unlock(WritePtr1, WriteCnt1, WritePtr2, WriteCnt2);
@ -334,9 +334,9 @@ FORCE_ALIGN static int ALCdsoundPlayback_mixerProc(ALCdsoundPlayback *self)
else
{
ERR("Buffer lock error: %#lx\n", err);
ALCdevice_Lock(device);
ALCdsoundPlayback_lock(self);
aluHandleDisconnect(device, "Failed to lock output buffer: 0x%lx", err);
ALCdevice_Unlock(device);
ALCdsoundPlayback_unlock(self);
return 1;
}

View File

@ -188,7 +188,7 @@ DEFINE_ALCBACKEND_VTABLE(PlaybackWrapper);
FORCE_ALIGN static int qsa_proc_playback(void *ptr)
{
PlaybackWrapper *self = ptr;
PlaybackWrapper *self = static_cast<PlaybackWrapper*>(ptr);
ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
qsa_data *data = self->ExtraData;
snd_pcm_channel_status_t status;
@ -211,7 +211,7 @@ FORCE_ALIGN static int qsa_proc_playback(void *ptr)
device->FmtChans, device->FmtType, device->AmbiOrder
);
V0(device->Backend,lock)();
PlaybackWrapper_lock(self);
while(!ATOMIC_LOAD(&data->killNow, almemory_order_acquire))
{
FD_ZERO(&wfds);
@ -220,9 +220,9 @@ FORCE_ALIGN static int qsa_proc_playback(void *ptr)
timeout.tv_usec=0;
/* Select also works like time slice to OS */
V0(device->Backend,unlock)();
PlaybackWrapper_unlock(self);
sret = select(data->audio_fd+1, NULL, &wfds, NULL, &timeout);
V0(device->Backend,lock)();
PlaybackWrapper_lock(self);
if(sret == -1)
{
ERR("select error: %s\n", strerror(errno));
@ -269,7 +269,7 @@ FORCE_ALIGN static int qsa_proc_playback(void *ptr)
}
}
}
V0(device->Backend,unlock)();
PlaybackWrapper_unlock(self);
return 0;
}

View File

@ -117,9 +117,9 @@ static int SndioPlayback_mixerProc(void *ptr)
if(wrote == 0)
{
ERR("sio_write failed\n");
ALCdevice_Lock(device);
SndioPlayback_lock(self);
aluHandleDisconnect(device, "Failed to write playback samples");
ALCdevice_Unlock(device);
SndioPlayback_unlock(self);
break;
}

View File

@ -576,9 +576,9 @@ FORCE_ALIGN static int ALCwasapiPlayback_mixerProc(ALCwasapiPlayback *self)
if(FAILED(hr))
{
ERR("CoInitializeEx(nullptr, COINIT_MULTITHREADED) failed: 0x%08lx\n", hr);
V0(device->Backend,lock)();
ALCwasapiPlayback_lock(self);
aluHandleDisconnect(device, "COM init failed: 0x%08lx", hr);
V0(device->Backend,unlock)();
ALCwasapiPlayback_unlock(self);
return 1;
}
@ -594,9 +594,9 @@ FORCE_ALIGN static int ALCwasapiPlayback_mixerProc(ALCwasapiPlayback *self)
if(FAILED(hr))
{
ERR("Failed to get padding: 0x%08lx\n", hr);
V0(device->Backend,lock)();
ALCwasapiPlayback_lock(self);
aluHandleDisconnect(device, "Failed to retrieve buffer padding: 0x%08lx", hr);
V0(device->Backend,unlock)();
ALCwasapiPlayback_unlock(self);
break;
}
self->mPadding.store(written, std::memory_order_relaxed);
@ -625,9 +625,9 @@ FORCE_ALIGN static int ALCwasapiPlayback_mixerProc(ALCwasapiPlayback *self)
if(FAILED(hr))
{
ERR("Failed to buffer data: 0x%08lx\n", hr);
V0(device->Backend,lock)();
ALCwasapiPlayback_lock(self);
aluHandleDisconnect(device, "Failed to send playback samples: 0x%08lx", hr);
V0(device->Backend,unlock)();
ALCwasapiPlayback_unlock(self);
break;
}
}
@ -1247,9 +1247,9 @@ FORCE_ALIGN int ALCwasapiCapture_recordProc(ALCwasapiCapture *self)
if(FAILED(hr))
{
ERR("CoInitializeEx(nullptr, COINIT_MULTITHREADED) failed: 0x%08lx\n", hr);
V0(device->Backend,lock)();
ALCwasapiCapture_lock(self);
aluHandleDisconnect(device, "COM init failed: 0x%08lx", hr);
V0(device->Backend,unlock)();
ALCwasapiCapture_unlock(self);
return 1;
}
@ -1327,9 +1327,9 @@ FORCE_ALIGN int ALCwasapiCapture_recordProc(ALCwasapiCapture *self)
if(FAILED(hr))
{
V0(device->Backend,lock)();
ALCwasapiCapture_lock(self);
aluHandleDisconnect(device, "Failed to capture samples: 0x%08lx", hr);
V0(device->Backend,unlock)();
ALCwasapiCapture_unlock(self);
break;
}

View File

@ -193,9 +193,9 @@ static int ALCwaveBackend_mixerProc(ALCwaveBackend *self)
if(ferror(self->mFile))
{
ERR("Error writing to file\n");
ALCdevice_Lock(device);
ALCwaveBackend_lock(self);
aluHandleDisconnect(device, "Failed to write playback samples");
ALCdevice_Unlock(device);
ALCwaveBackend_unlock(self);
break;
}
}