diff options
author | Chris Robinson <[email protected]> | 2018-12-27 14:27:35 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-27 14:27:35 -0800 |
commit | f2c2b7c5383ddd999b56f28730258f270b0d2576 (patch) | |
tree | f8940ac867fe81647597c0c42888fa23222fdb93 /Alc/backends | |
parent | 4782d6107d250e3528c5e567dca48da727584ee7 (diff) |
Get rid of the unnecessary STATIC_(UP)CAST macros
Diffstat (limited to 'Alc/backends')
-rw-r--r-- | Alc/backends/alsa.cpp | 29 | ||||
-rw-r--r-- | Alc/backends/base.h | 2 | ||||
-rw-r--r-- | Alc/backends/coreaudio.cpp | 17 | ||||
-rw-r--r-- | Alc/backends/dsound.cpp | 20 | ||||
-rw-r--r-- | Alc/backends/jack.cpp | 5 | ||||
-rw-r--r-- | Alc/backends/loopback.cpp | 7 | ||||
-rw-r--r-- | Alc/backends/null.cpp | 11 | ||||
-rw-r--r-- | Alc/backends/opensl.cpp | 15 | ||||
-rw-r--r-- | Alc/backends/oss.cpp | 16 | ||||
-rw-r--r-- | Alc/backends/portaudio.cpp | 19 | ||||
-rw-r--r-- | Alc/backends/pulseaudio.cpp | 48 | ||||
-rw-r--r-- | Alc/backends/qsa.cpp | 20 | ||||
-rw-r--r-- | Alc/backends/sdl2.cpp | 12 | ||||
-rw-r--r-- | Alc/backends/sndio.cpp | 16 | ||||
-rw-r--r-- | Alc/backends/solaris.cpp | 9 | ||||
-rw-r--r-- | Alc/backends/wasapi.cpp | 167 | ||||
-rw-r--r-- | Alc/backends/wave.cpp | 9 | ||||
-rw-r--r-- | Alc/backends/winmm.cpp | 14 |
18 files changed, 194 insertions, 242 deletions
diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp index 2d0b3070..f0838d25 100644 --- a/Alc/backends/alsa.cpp +++ b/Alc/backends/alsa.cpp @@ -469,7 +469,7 @@ void ALCplaybackAlsa_Destruct(ALCplaybackAlsa *self) int ALCplaybackAlsa_mixerProc(ALCplaybackAlsa *self) { - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; SetRTPriority(); althrd_setname(MIXER_THREAD_NAME); @@ -556,7 +556,7 @@ int ALCplaybackAlsa_mixerProc(ALCplaybackAlsa *self) int ALCplaybackAlsa_mixerNoMMapProc(ALCplaybackAlsa *self) { - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; SetRTPriority(); althrd_setname(MIXER_THREAD_NAME); @@ -680,7 +680,7 @@ ALCenum ALCplaybackAlsa_open(ALCplaybackAlsa *self, const ALCchar *name) /* Free alsa's global config tree. Otherwise valgrind reports a ton of leaks. */ snd_config_update_free_global(); - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device = self->mDevice; device->DeviceName = name; return ALC_NO_ERROR; @@ -688,7 +688,7 @@ ALCenum ALCplaybackAlsa_open(ALCplaybackAlsa *self, const ALCchar *name) ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self) { - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; snd_pcm_format_t format{SND_PCM_FORMAT_UNKNOWN}; switch(device->FmtType) @@ -840,7 +840,7 @@ error: ALCboolean ALCplaybackAlsa_start(ALCplaybackAlsa *self) { - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; int (*thread_func)(ALCplaybackAlsa*){}; snd_pcm_hw_params_t *hp{}; snd_pcm_access_t access; @@ -903,7 +903,7 @@ void ALCplaybackAlsa_stop(ALCplaybackAlsa *self) ClockLatency ALCplaybackAlsa_getClockLatency(ALCplaybackAlsa *self) { - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; ClockLatency ret; ALCplaybackAlsa_lock(self); @@ -970,7 +970,7 @@ void ALCcaptureAlsa_Destruct(ALCcaptureAlsa *self) ALCenum ALCcaptureAlsa_open(ALCcaptureAlsa *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; const char *driver{}; if(name) { @@ -1103,8 +1103,7 @@ ALCboolean ALCcaptureAlsa_start(ALCcaptureAlsa *self) } if(err < 0) { - aluHandleDisconnect(STATIC_CAST(ALCbackend, self)->mDevice, "Capture state failure: %s", - snd_strerror(err)); + aluHandleDisconnect(self->mDevice, "Capture state failure: %s", snd_strerror(err)); return ALC_FALSE; } @@ -1134,7 +1133,7 @@ void ALCcaptureAlsa_stop(ALCcaptureAlsa *self) ALCenum ALCcaptureAlsa_captureSamples(ALCcaptureAlsa *self, ALCvoid *buffer, ALCuint samples) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; if(RingBuffer *ring{self->mRing.get()}) { @@ -1198,7 +1197,7 @@ ALCenum ALCcaptureAlsa_captureSamples(ALCcaptureAlsa *self, ALCvoid *buffer, ALC ALCuint ALCcaptureAlsa_availableSamples(ALCcaptureAlsa *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; snd_pcm_sframes_t avail{0}; if(device->Connected.load(std::memory_order_acquire) && self->mDoCapture) @@ -1269,7 +1268,7 @@ ALCuint ALCcaptureAlsa_availableSamples(ALCcaptureAlsa *self) ClockLatency ALCcaptureAlsa_getClockLatency(ALCcaptureAlsa *self) { - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; ClockLatency ret; ALCcaptureAlsa_lock(self); @@ -1338,15 +1337,13 @@ ALCbackend *AlsaBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type { ALCplaybackAlsa *backend; NEW_OBJ(backend, ALCplaybackAlsa)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { ALCcaptureAlsa *backend; NEW_OBJ(backend, ALCcaptureAlsa)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/base.h b/Alc/backends/base.h index aaa2b037..4380540f 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -85,7 +85,7 @@ DECLARE_THUNK(T, ALCbackend, ClockLatency, getClockLatency) \ DECLARE_THUNK(T, ALCbackend, void, lock) \ DECLARE_THUNK(T, ALCbackend, void, unlock) \ static void T##_ALCbackend_Delete(void *ptr) \ -{ T##_Delete(STATIC_UPCAST(T, ALCbackend, (ALCbackend*)ptr)); } \ +{ T##_Delete(static_cast<T*>(static_cast<ALCbackend*>(ptr))); } \ \ static const ALCbackendVtable T##_ALCbackend_vtable = { \ T##_ALCbackend_Destruct, \ diff --git a/Alc/backends/coreaudio.cpp b/Alc/backends/coreaudio.cpp index d0d0060c..62a88da1 100644 --- a/Alc/backends/coreaudio.cpp +++ b/Alc/backends/coreaudio.cpp @@ -83,11 +83,10 @@ static OSStatus ALCcoreAudioPlayback_MixerProc(void *inRefCon, AudioUnitRenderActionFlags* UNUSED(ioActionFlags), const AudioTimeStamp* UNUSED(inTimeStamp), UInt32 UNUSED(inBusNumber), UInt32 UNUSED(inNumberFrames), AudioBufferList *ioData) { - ALCcoreAudioPlayback *self = static_cast<ALCcoreAudioPlayback*>(inRefCon); - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + auto self = static_cast<ALCcoreAudioPlayback*>(inRefCon); ALCcoreAudioPlayback_lock(self); - aluMixData(device, ioData->mBuffers[0].mData, + aluMixData(self->mDevice, ioData->mBuffers[0].mData, ioData->mBuffers[0].mDataByteSize / self->mFrameSize); ALCcoreAudioPlayback_unlock(self); @@ -97,7 +96,7 @@ static OSStatus ALCcoreAudioPlayback_MixerProc(void *inRefCon, static ALCenum ALCcoreAudioPlayback_open(ALCcoreAudioPlayback *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; AudioComponentDescription desc; AudioComponent comp; OSStatus err; @@ -147,7 +146,7 @@ static ALCenum ALCcoreAudioPlayback_open(ALCcoreAudioPlayback *self, const ALCch static ALCboolean ALCcoreAudioPlayback_reset(ALCcoreAudioPlayback *self) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; AudioStreamBasicDescription streamFormat; AURenderCallbackStruct input; OSStatus err; @@ -413,7 +412,7 @@ static OSStatus ALCcoreAudioCapture_RecordProc(void *inRefCon, static ALCenum ALCcoreAudioCapture_open(ALCcoreAudioCapture *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; AudioStreamBasicDescription requestedFormat; // The application requested format AudioStreamBasicDescription hardwareFormat; // The hardware format AudioStreamBasicDescription outputFormat; // The AudioUnit output format @@ -730,15 +729,13 @@ ALCbackend *CoreAudioBackendFactory::createBackend(ALCdevice *device, ALCbackend { ALCcoreAudioPlayback *backend; NEW_OBJ(backend, ALCcoreAudioPlayback)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { ALCcoreAudioCapture *backend; NEW_OBJ(backend, ALCcoreAudioCapture)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp index 7bfe79df..421c3107 100644 --- a/Alc/backends/dsound.cpp +++ b/Alc/backends/dsound.cpp @@ -246,7 +246,7 @@ void ALCdsoundPlayback_Destruct(ALCdsoundPlayback *self) FORCE_ALIGN int ALCdsoundPlayback_mixerProc(ALCdsoundPlayback *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; SetRTPriority(); althrd_setname(MIXER_THREAD_NAME); @@ -352,7 +352,7 @@ FORCE_ALIGN int ALCdsoundPlayback_mixerProc(ALCdsoundPlayback *self) ALCenum ALCdsoundPlayback_open(ALCdsoundPlayback *self, const ALCchar *deviceName) { - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; HRESULT hr; if(PlaybackDevices.empty()) @@ -404,7 +404,7 @@ ALCenum ALCdsoundPlayback_open(ALCdsoundPlayback *self, const ALCchar *deviceNam ALCboolean ALCdsoundPlayback_reset(ALCdsoundPlayback *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; if(self->mNotifies) self->mNotifies->Release(); @@ -699,7 +699,7 @@ void ALCdsoundCapture_Destruct(ALCdsoundCapture *self) ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *deviceName) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; HRESULT hr; if(CaptureDevices.empty()) @@ -868,8 +868,7 @@ ALCboolean ALCdsoundCapture_start(ALCdsoundCapture *self) if(FAILED(hr)) { ERR("start failed: 0x%08lx\n", hr); - aluHandleDisconnect(STATIC_CAST(ALCbackend, self)->mDevice, - "Failure starting capture: 0x%lx", hr); + aluHandleDisconnect(self->mDevice, "Failure starting capture: 0x%lx", hr); return ALC_FALSE; } @@ -882,8 +881,7 @@ void ALCdsoundCapture_stop(ALCdsoundCapture *self) if(FAILED(hr)) { ERR("stop failed: 0x%08lx\n", hr); - aluHandleDisconnect(STATIC_CAST(ALCbackend, self)->mDevice, - "Failure stopping capture: 0x%lx", hr); + aluHandleDisconnect(self->mDevice, "Failure stopping capture: 0x%lx", hr); } } @@ -1003,16 +1001,14 @@ ALCbackend *DSoundBackendFactory::createBackend(ALCdevice *device, ALCbackend_Ty { ALCdsoundPlayback *backend; NEW_OBJ(backend, ALCdsoundPlayback)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { ALCdsoundCapture *backend; NEW_OBJ(backend, ALCdsoundCapture)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp index 059f9c96..37855fe3 100644 --- a/Alc/backends/jack.cpp +++ b/Alc/backends/jack.cpp @@ -208,7 +208,7 @@ void ALCjackPlayback_Destruct(ALCjackPlayback *self) int ALCjackPlayback_bufferSizeNotify(jack_nframes_t numframes, void *arg) { auto self = static_cast<ALCjackPlayback*>(arg); - ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; + ALCdevice *device{self->mDevice}; ALCjackPlayback_lock(self); device->UpdateSize = numframes; @@ -582,8 +582,7 @@ ALCbackend *JackBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type { ALCjackPlayback *backend; NEW_OBJ(backend, ALCjackPlayback)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/loopback.cpp b/Alc/backends/loopback.cpp index 9291ae77..eadacdfb 100644 --- a/Alc/backends/loopback.cpp +++ b/Alc/backends/loopback.cpp @@ -61,7 +61,7 @@ void ALCloopback_Destruct(ALCloopback *self) ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; device->DeviceName = name; return ALC_NO_ERROR; @@ -69,7 +69,7 @@ ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name) ALCboolean ALCloopback_reset(ALCloopback *self) { - SetDefaultWFXChannelOrder(STATIC_CAST(ALCbackend, self)->mDevice); + SetDefaultWFXChannelOrder(self->mDevice); return ALC_TRUE; } @@ -100,8 +100,7 @@ ALCbackend *LoopbackBackendFactory::createBackend(ALCdevice *device, ALCbackend_ { ALCloopback *backend; NEW_OBJ(backend, ALCloopback)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/null.cpp b/Alc/backends/null.cpp index 2b2a4b84..7a4cf475 100644 --- a/Alc/backends/null.cpp +++ b/Alc/backends/null.cpp @@ -83,7 +83,7 @@ void ALCnullBackend_Destruct(ALCnullBackend *self) int ALCnullBackend_mixerProc(ALCnullBackend *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; const milliseconds restTime{device->UpdateSize*1000/device->Frequency / 2}; SetRTPriority(); @@ -130,14 +130,12 @@ int ALCnullBackend_mixerProc(ALCnullBackend *self) ALCenum ALCnullBackend_open(ALCnullBackend *self, const ALCchar *name) { - ALCdevice *device; - if(!name) name = nullDevice; else if(strcmp(name, nullDevice) != 0) return ALC_INVALID_VALUE; - device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; device->DeviceName = name; return ALC_NO_ERROR; @@ -145,7 +143,7 @@ ALCenum ALCnullBackend_open(ALCnullBackend *self, const ALCchar *name) ALCboolean ALCnullBackend_reset(ALCnullBackend *self) { - SetDefaultWFXChannelOrder(STATIC_CAST(ALCbackend, self)->mDevice); + SetDefaultWFXChannelOrder(self->mDevice); return ALC_TRUE; } @@ -199,8 +197,7 @@ ALCbackend *NullBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type { ALCnullBackend *backend; NEW_OBJ(backend, ALCnullBackend)(device); - if(!backend) return NULL; - return STATIC_CAST(ALCbackend, backend); + return backend; } return NULL; diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp index 3aa2d267..0853e32f 100644 --- a/Alc/backends/opensl.cpp +++ b/Alc/backends/opensl.cpp @@ -313,7 +313,7 @@ static int ALCopenslPlayback_mixerProc(ALCopenslPlayback *self) static ALCenum ALCopenslPlayback_open(ALCopenslPlayback *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; SLresult result; if(!name) @@ -365,7 +365,7 @@ static ALCenum ALCopenslPlayback_open(ALCopenslPlayback *self, const ALCchar *na static ALCboolean ALCopenslPlayback_reset(ALCopenslPlayback *self) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; SLDataLocator_AndroidSimpleBufferQueue loc_bufq; SLDataLocator_OutputMix loc_outmix; SLDataSource audioSrc; @@ -713,7 +713,7 @@ static void ALCopenslCapture_process(SLAndroidSimpleBufferQueueItf UNUSED(bq), v static ALCenum ALCopenslCapture_open(ALCopenslCapture *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; SLDataLocator_AndroidSimpleBufferQueue loc_bq; SLAndroidSimpleBufferQueueItf bufferQueue; SLDataLocator_IODevice loc_dev; @@ -892,8 +892,7 @@ static ALCboolean ALCopenslCapture_start(ALCopenslCapture *self) if(SL_RESULT_SUCCESS != result) { ALCopenslCapture_lock(self); - aluHandleDisconnect(STATIC_CAST(ALCbackend, self)->mDevice, - "Failed to start capture: 0x%08x", result); + aluHandleDisconnect(self->mDevice, "Failed to start capture: 0x%08x", result); ALCopenslCapture_unlock(self); return ALC_FALSE; } @@ -1003,15 +1002,13 @@ ALCbackend *OSLBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type { ALCopenslPlayback *backend; NEW_OBJ(backend, ALCopenslPlayback)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { ALCopenslCapture *backend; NEW_OBJ(backend, ALCopenslCapture)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/oss.cpp b/Alc/backends/oss.cpp index 73b62b30..e5630ad3 100644 --- a/Alc/backends/oss.cpp +++ b/Alc/backends/oss.cpp @@ -287,7 +287,7 @@ void ALCplaybackOSS_Destruct(ALCplaybackOSS *self) int ALCplaybackOSS_mixerProc(ALCplaybackOSS *self) { - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; SetRTPriority(); althrd_setname(MIXER_THREAD_NAME); @@ -347,7 +347,7 @@ int ALCplaybackOSS_mixerProc(ALCplaybackOSS *self) ALCenum ALCplaybackOSS_open(ALCplaybackOSS *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; const char *devname{DefaultPlayback}; if(!name) @@ -379,7 +379,7 @@ ALCenum ALCplaybackOSS_open(ALCplaybackOSS *self, const ALCchar *name) ALCboolean ALCplaybackOSS_reset(ALCplaybackOSS *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; int numFragmentsLogSize; int log2FragmentSize; unsigned int periods; @@ -461,7 +461,7 @@ ALCboolean ALCplaybackOSS_reset(ALCplaybackOSS *self) ALCboolean ALCplaybackOSS_start(ALCplaybackOSS *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; try { self->mMixData.resize(device->UpdateSize * device->frameSizeFromFmt()); @@ -587,7 +587,7 @@ int ALCcaptureOSS_recordProc(ALCcaptureOSS *self) ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; const char *devname{DefaultCapture}; if(!name) @@ -797,15 +797,13 @@ ALCbackend *OSSBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type { ALCplaybackOSS *backend; NEW_OBJ(backend, ALCplaybackOSS)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { ALCcaptureOSS *backend; NEW_OBJ(backend, ALCcaptureOSS)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/portaudio.cpp b/Alc/backends/portaudio.cpp index f49c0d2c..7c0569c2 100644 --- a/Alc/backends/portaudio.cpp +++ b/Alc/backends/portaudio.cpp @@ -179,10 +179,10 @@ int ALCportPlayback_WriteCallback(const void *UNUSED(inputBuffer), void *outputB unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *UNUSED(timeInfo), const PaStreamCallbackFlags UNUSED(statusFlags), void *userData) { - ALCportPlayback *self = static_cast<ALCportPlayback*>(userData); + auto self = static_cast<ALCportPlayback*>(userData); ALCportPlayback_lock(self); - aluMixData(STATIC_CAST(ALCbackend, self)->mDevice, outputBuffer, framesPerBuffer); + aluMixData(self->mDevice, outputBuffer, framesPerBuffer); ALCportPlayback_unlock(self); return 0; } @@ -190,7 +190,7 @@ int ALCportPlayback_WriteCallback(const void *UNUSED(inputBuffer), void *outputB ALCenum ALCportPlayback_open(ALCportPlayback *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; PaError err; if(!name) @@ -256,10 +256,9 @@ retry_open: ALCboolean ALCportPlayback_reset(ALCportPlayback *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; - const PaStreamInfo *streamInfo; + ALCdevice *device{self->mDevice}; - streamInfo = Pa_GetStreamInfo(self->Stream); + const PaStreamInfo *streamInfo{Pa_GetStreamInfo(self->Stream)}; device->Frequency = streamInfo->sampleRate; device->UpdateSize = self->UpdateSize; @@ -374,7 +373,7 @@ int ALCportCapture_ReadCallback(const void *inputBuffer, void *UNUSED(outputBuff ALCenum ALCportCapture_open(ALCportCapture *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; ALuint samples, frame_size; PaError err; @@ -509,15 +508,13 @@ ALCbackend *PortBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type { ALCportPlayback *backend; NEW_OBJ(backend, ALCportPlayback)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { ALCportCapture *backend; NEW_OBJ(backend, ALCportCapture)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp index dc7f97b3..23685178 100644 --- a/Alc/backends/pulseaudio.cpp +++ b/Alc/backends/pulseaudio.cpp @@ -697,7 +697,7 @@ void PulsePlayback_contextStateCallback(pa_context *context, void *pdata) if(pa_context_get_state(context) == PA_CONTEXT_FAILED) { ERR("Received context failure!\n"); - aluHandleDisconnect(STATIC_CAST(ALCbackend,self)->mDevice, "Playback state failure"); + aluHandleDisconnect(self->mDevice, "Playback state failure"); } pa_threaded_mainloop_signal(self->loop, 0); } @@ -708,7 +708,7 @@ void PulsePlayback_streamStateCallback(pa_stream *stream, void *pdata) if(pa_stream_get_state(stream) == PA_STREAM_FAILED) { ERR("Received stream failure!\n"); - aluHandleDisconnect(STATIC_CAST(ALCbackend,self)->mDevice, "Playback stream failure"); + aluHandleDisconnect(self->mDevice, "Playback stream failure"); } pa_threaded_mainloop_signal(self->loop, 0); } @@ -769,7 +769,7 @@ void PulsePlayback_sinkInfoCallback(pa_context *UNUSED(context), const pa_sink_i } } }, { DevFmtMono, { 1, {PA_CHANNEL_POSITION_MONO} } } }}; - auto self = reinterpret_cast<PulsePlayback*>(pdata); + auto self = static_cast<PulsePlayback*>(pdata); if(eol) { @@ -777,7 +777,7 @@ void PulsePlayback_sinkInfoCallback(pa_context *UNUSED(context), const pa_sink_i return; } - ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; + ALCdevice *device{self->mDevice}; auto chanmap = std::find_if(chanmaps.cbegin(), chanmaps.cend(), [info](const ChannelMap &chanmap) -> bool { return pa_channel_map_superset(&info->channel_map, &chanmap.map); } @@ -803,7 +803,7 @@ void PulsePlayback_sinkInfoCallback(pa_context *UNUSED(context), const pa_sink_i void PulsePlayback_sinkNameCallback(pa_context *UNUSED(context), const pa_sink_info *info, int eol, void *pdata) { - auto self = reinterpret_cast<PulsePlayback*>(pdata); + auto self = static_cast<PulsePlayback*>(pdata); if(eol) { @@ -811,14 +811,14 @@ void PulsePlayback_sinkNameCallback(pa_context *UNUSED(context), const pa_sink_i return; } - ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; + ALCdevice *device{self->mDevice}; device->DeviceName = info->description; } void PulsePlayback_streamMovedCallback(pa_stream *stream, void *pdata) { - auto self = reinterpret_cast<PulsePlayback*>(pdata); + auto self = static_cast<PulsePlayback*>(pdata); self->device_name = pa_stream_get_device_name(stream); @@ -932,7 +932,7 @@ ALCenum PulsePlayback_open(PulsePlayback *self, const ALCchar *name) } else { - ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; + ALCdevice *device{self->mDevice}; device->DeviceName = dev_name; } @@ -958,7 +958,7 @@ ALCboolean PulsePlayback_reset(PulsePlayback *self) self->device_name.c_str(), PulsePlayback_sinkInfoCallback, self)}; wait_for_operation(op, self->loop); - ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; + ALCdevice *device{self->mDevice}; pa_stream_flags_t flags{PA_STREAM_START_CORKED | PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE}; if(!GetConfigValueBool(nullptr, "pulse", "allow-moves", 0)) @@ -1132,7 +1132,7 @@ ClockLatency PulsePlayback_getClockLatency(PulsePlayback *self) int neg, err; { palock_guard _{self->loop}; - ret.ClockTime = GetDeviceClockTime(STATIC_CAST(ALCbackend,self)->mDevice); + ret.ClockTime = GetDeviceClockTime(self->mDevice); err = pa_stream_get_latency(self->stream, &latency, &neg); } @@ -1320,22 +1320,22 @@ void PulseCapture_probeDevices(void) void PulseCapture_contextStateCallback(pa_context *context, void *pdata) { - auto self = reinterpret_cast<PulseCapture*>(pdata); + auto self = static_cast<PulseCapture*>(pdata); if(pa_context_get_state(context) == PA_CONTEXT_FAILED) { ERR("Received context failure!\n"); - aluHandleDisconnect(STATIC_CAST(ALCbackend,self)->mDevice, "Capture state failure"); + aluHandleDisconnect(self->mDevice, "Capture state failure"); } pa_threaded_mainloop_signal(self->loop, 0); } void PulseCapture_streamStateCallback(pa_stream *stream, void *pdata) { - auto self = reinterpret_cast<PulseCapture*>(pdata); + auto self = static_cast<PulseCapture*>(pdata); if(pa_stream_get_state(stream) == PA_STREAM_FAILED) { ERR("Received stream failure!\n"); - aluHandleDisconnect(STATIC_CAST(ALCbackend,self)->mDevice, "Capture stream failure"); + aluHandleDisconnect(self->mDevice, "Capture stream failure"); } pa_threaded_mainloop_signal(self->loop, 0); } @@ -1343,7 +1343,7 @@ void PulseCapture_streamStateCallback(pa_stream *stream, void *pdata) void PulseCapture_sourceNameCallback(pa_context *UNUSED(context), const pa_source_info *info, int eol, void *pdata) { - auto self = reinterpret_cast<PulseCapture*>(pdata); + auto self = static_cast<PulseCapture*>(pdata); if(eol) { @@ -1351,14 +1351,14 @@ void PulseCapture_sourceNameCallback(pa_context *UNUSED(context), const pa_sourc return; } - ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; + ALCdevice *device{self->mDevice}; device->DeviceName = info->description; } void PulseCapture_streamMovedCallback(pa_stream *stream, void *pdata) { - auto self = reinterpret_cast<PulseCapture*>(pdata); + auto self = static_cast<PulseCapture*>(pdata); self->device_name = pa_stream_get_device_name(stream); @@ -1409,7 +1409,7 @@ pa_stream *PulseCapture_connectStream(const char *device_name, ALCenum PulseCapture_open(PulseCapture *self, const ALCchar *name) { - ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; + ALCdevice *device{self->mDevice}; const char *pulse_name{nullptr}; if(name) @@ -1555,7 +1555,7 @@ void PulseCapture_stop(PulseCapture *self) ALCenum PulseCapture_captureSamples(PulseCapture *self, ALCvoid *buffer, ALCuint samples) { - ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; + ALCdevice *device{self->mDevice}; ALCuint todo{samples * static_cast<ALCuint>(pa_frame_size(&self->spec))}; /* Capture is done in fragment-sized chunks, so we loop until we get all @@ -1609,7 +1609,7 @@ ALCenum PulseCapture_captureSamples(PulseCapture *self, ALCvoid *buffer, ALCuint ALCuint PulseCapture_availableSamples(PulseCapture *self) { - ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; + ALCdevice *device{self->mDevice}; size_t readable{self->cap_remain}; if(device->Connected.load(std::memory_order_acquire)) @@ -1638,7 +1638,7 @@ ClockLatency PulseCapture_getClockLatency(PulseCapture *self) int neg, err; { palock_guard _{self->loop}; - ret.ClockTime = GetDeviceClockTime(STATIC_CAST(ALCbackend,self)->mDevice); + ret.ClockTime = GetDeviceClockTime(self->mDevice); err = pa_stream_get_latency(self->stream, &latency, &neg); } @@ -1757,15 +1757,13 @@ ALCbackend *PulseBackendFactory::createBackend(ALCdevice *device, ALCbackend_Typ { PulsePlayback *backend; NEW_OBJ(backend, PulsePlayback)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { PulseCapture *backend; NEW_OBJ(backend, PulseCapture)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp index ff74ff21..7469d874 100644 --- a/Alc/backends/qsa.cpp +++ b/Alc/backends/qsa.cpp @@ -194,8 +194,8 @@ DEFINE_ALCBACKEND_VTABLE(PlaybackWrapper); FORCE_ALIGN static int qsa_proc_playback(void *ptr) { PlaybackWrapper *self = static_cast<PlaybackWrapper*>(ptr); - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; - qsa_data *data = self->ExtraData; + ALCdevice *device = self->mDevice; + qsa_data *data = self->ExtraData.get(); snd_pcm_channel_status_t status; sched_param param; char* write_ptr; @@ -282,7 +282,7 @@ FORCE_ALIGN static int qsa_proc_playback(void *ptr) static ALCenum qsa_open_playback(PlaybackWrapper *self, const ALCchar* deviceName) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device = self->mDevice; int card, dev; int status; @@ -342,7 +342,7 @@ static void qsa_close_playback(PlaybackWrapper *self) static ALCboolean qsa_reset_playback(PlaybackWrapper *self) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device = self->mDevice; qsa_data *data = self->ExtraData.get(); int32_t format=-1; @@ -676,7 +676,7 @@ DEFINE_ALCBACKEND_VTABLE(CaptureWrapper); static ALCenum qsa_open_capture(CaptureWrapper *self, const ALCchar *deviceName) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device = self->mDevice; int card, dev; int format=-1; int status; @@ -813,7 +813,7 @@ static void qsa_stop_capture(CaptureWrapper *self) static ALCuint qsa_available_samples(CaptureWrapper *self) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device = self->mDevice; qsa_data *data = self->ExtraData.get(); snd_pcm_channel_status_t status; ALint frame_size = device->frameSizeFromFmt(); @@ -845,7 +845,7 @@ static ALCuint qsa_available_samples(CaptureWrapper *self) static ALCenum qsa_capture_samples(CaptureWrapper *self, ALCvoid *buffer, ALCuint samples) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device = self->mDevice; qsa_data *data = self->ExtraData.get(); char* read_ptr; snd_pcm_channel_status_t status; @@ -1004,15 +1004,13 @@ ALCbackend *QSABackendFactory::createBackend(ALCdevice *device, ALCbackend_Type { PlaybackWrapper *backend; NEW_OBJ(backend, PlaybackWrapper)(device); - if(!backend) return NULL; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { CaptureWrapper *backend; NEW_OBJ(backend, CaptureWrapper)(device); - if(!backend) return NULL; - return STATIC_CAST(ALCbackend, backend); + return backend; } return NULL; diff --git a/Alc/backends/sdl2.cpp b/Alc/backends/sdl2.cpp index 75052b0f..cb5f875a 100644 --- a/Alc/backends/sdl2.cpp +++ b/Alc/backends/sdl2.cpp @@ -92,16 +92,15 @@ static void ALCsdl2Backend_Destruct(ALCsdl2Backend *self) static void ALCsdl2Backend_audioCallback(void *ptr, Uint8 *stream, int len) { - ALCsdl2Backend *self = static_cast<ALCsdl2Backend*>(ptr); - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + auto self = static_cast<ALCsdl2Backend*>(ptr); assert((len % self->frameSize) == 0); - aluMixData(device, stream, len / self->frameSize); + aluMixData(self->mDevice, stream, len / self->frameSize); } static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; SDL_AudioSpec want, have; SDL_zero(want); @@ -179,7 +178,7 @@ static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name) static ALCboolean ALCsdl2Backend_reset(ALCsdl2Backend *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; device->Frequency = self->Frequency; device->FmtChans = self->FmtChans; device->FmtType = self->FmtType; @@ -256,8 +255,7 @@ ALCbackend *SDL2BackendFactory::createBackend(ALCdevice *device, ALCbackend_Type { ALCsdl2Backend *backend; NEW_OBJ(backend, ALCsdl2Backend)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp index 576e9ba9..ef9ce549 100644 --- a/Alc/backends/sndio.cpp +++ b/Alc/backends/sndio.cpp @@ -90,7 +90,7 @@ static void SndioPlayback_Destruct(SndioPlayback *self) static int SndioPlayback_mixerProc(SndioPlayback *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; ALsizei frameSize; size_t wrote; @@ -131,7 +131,7 @@ static int SndioPlayback_mixerProc(SndioPlayback *self) static ALCenum SndioPlayback_open(SndioPlayback *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; if(!name) name = sndio_device; @@ -151,7 +151,7 @@ static ALCenum SndioPlayback_open(SndioPlayback *self, const ALCchar *name) static ALCboolean SndioPlayback_reset(SndioPlayback *self) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; sio_par par; sio_initpar(&par); @@ -236,7 +236,7 @@ static ALCboolean SndioPlayback_reset(SndioPlayback *self) static ALCboolean SndioPlayback_start(SndioPlayback *self) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; self->data_size = device->UpdateSize * device->frameSizeFromFmt(); al_free(self->mix_data); @@ -378,7 +378,7 @@ static int SndioCapture_recordProc(SndioCapture *self) static ALCenum SndioCapture_open(SndioCapture *self, const ALCchar *name) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; sio_par par; if(!name) @@ -555,15 +555,13 @@ ALCbackend *SndIOBackendFactory::createBackend(ALCdevice *device, ALCbackend_Typ { SndioPlayback *backend; NEW_OBJ(backend, SndioPlayback)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { SndioCapture *backend; NEW_OBJ(backend, SndioCapture)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/solaris.cpp b/Alc/backends/solaris.cpp index 60db963b..bbbe1612 100644 --- a/Alc/backends/solaris.cpp +++ b/Alc/backends/solaris.cpp @@ -103,7 +103,7 @@ static void ALCsolarisBackend_Destruct(ALCsolarisBackend *self) static int ALCsolarisBackend_mixerProc(ALCsolarisBackend *self) { - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; SetRTPriority(); althrd_setname(MIXER_THREAD_NAME); @@ -177,7 +177,7 @@ static ALCenum ALCsolarisBackend_open(ALCsolarisBackend *self, const ALCchar *na return ALC_INVALID_VALUE; } - device = STATIC_CAST(ALCbackend,self)->mDevice; + device = self->mDevice; device->DeviceName = name; return ALC_NO_ERROR; @@ -185,7 +185,7 @@ static ALCenum ALCsolarisBackend_open(ALCsolarisBackend *self, const ALCchar *na static ALCboolean ALCsolarisBackend_reset(ALCsolarisBackend *self) { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; audio_info_t info; ALsizei frameSize; ALsizei numChannels; @@ -326,8 +326,7 @@ ALCbackend *SolarisBackendFactory::createBackend(ALCdevice *device, ALCbackend_T { ALCsolarisBackend *backend; NEW_OBJ(backend, ALCsolarisBackend)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp index c7a216eb..1c760b4e 100644 --- a/Alc/backends/wasapi.cpp +++ b/Alc/backends/wasapi.cpp @@ -565,7 +565,7 @@ void ALCwasapiPlayback_Destruct(ALCwasapiPlayback *self) FORCE_ALIGN int ALCwasapiPlayback_mixerProc(ALCwasapiPlayback *self) { - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; IAudioClient *client{self->mClient}; IAudioRenderClient *render{self->mRender}; @@ -714,7 +714,7 @@ ALCenum ALCwasapiPlayback_open(ALCwasapiPlayback *self, const ALCchar *deviceNam WARN("Failed to find device name matching \"%s\"\n", deviceName); else { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; self->mDevId = iter->devid; device->DeviceName = iter->name; hr = S_OK; @@ -754,8 +754,6 @@ ALCenum ALCwasapiPlayback_open(ALCwasapiPlayback *self, const ALCchar *deviceNam HRESULT ALCwasapiPlayback::openProxy() { - ALCdevice *device = STATIC_CAST(ALCbackend, this)->mDevice; - void *ptr; HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, &ptr); if(SUCCEEDED(hr)) @@ -772,8 +770,8 @@ HRESULT ALCwasapiPlayback::openProxy() if(SUCCEEDED(hr)) { mClient = reinterpret_cast<IAudioClient*>(ptr); - if(device->DeviceName.empty()) - device->DeviceName = get_device_name_and_guid(mMMDev).first; + if(mDevice->DeviceName.empty()) + mDevice->DeviceName = get_device_name_and_guid(mMMDev).first; } if(FAILED(hr)) @@ -812,8 +810,6 @@ ALCboolean ALCwasapiPlayback_reset(ALCwasapiPlayback *self) HRESULT ALCwasapiPlayback::resetProxy() { - ALCdevice *device{STATIC_CAST(ALCbackend, this)->mDevice}; - if(mClient) mClient->Release(); mClient = nullptr; @@ -844,39 +840,39 @@ HRESULT ALCwasapiPlayback::resetProxy() CoTaskMemFree(wfx); wfx = nullptr; - REFERENCE_TIME buf_time{ScaleCeil(device->UpdateSize*device->NumUpdates, REFTIME_PER_SEC, - device->Frequency)}; + REFERENCE_TIME buf_time{ScaleCeil(mDevice->UpdateSize*mDevice->NumUpdates, REFTIME_PER_SEC, + mDevice->Frequency)}; - if(!(device->Flags&DEVICE_FREQUENCY_REQUEST)) - device->Frequency = OutputType.Format.nSamplesPerSec; - if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) + if(!(mDevice->Flags&DEVICE_FREQUENCY_REQUEST)) + mDevice->Frequency = OutputType.Format.nSamplesPerSec; + if(!(mDevice->Flags&DEVICE_CHANNELS_REQUEST)) { if(OutputType.Format.nChannels == 1 && OutputType.dwChannelMask == MONO) - device->FmtChans = DevFmtMono; + mDevice->FmtChans = DevFmtMono; else if(OutputType.Format.nChannels == 2 && OutputType.dwChannelMask == STEREO) - device->FmtChans = DevFmtStereo; + mDevice->FmtChans = DevFmtStereo; else if(OutputType.Format.nChannels == 4 && OutputType.dwChannelMask == QUAD) - device->FmtChans = DevFmtQuad; + mDevice->FmtChans = DevFmtQuad; else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1) - device->FmtChans = DevFmtX51; + mDevice->FmtChans = DevFmtX51; else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1REAR) - device->FmtChans = DevFmtX51Rear; + mDevice->FmtChans = DevFmtX51Rear; else if(OutputType.Format.nChannels == 7 && OutputType.dwChannelMask == X6DOT1) - device->FmtChans = DevFmtX61; + mDevice->FmtChans = DevFmtX61; else if(OutputType.Format.nChannels == 8 && (OutputType.dwChannelMask == X7DOT1 || OutputType.dwChannelMask == X7DOT1_WIDE)) - device->FmtChans = DevFmtX71; + mDevice->FmtChans = DevFmtX71; else ERR("Unhandled channel config: %d -- 0x%08lx\n", OutputType.Format.nChannels, OutputType.dwChannelMask); } - switch(device->FmtChans) + switch(mDevice->FmtChans) { case DevFmtMono: OutputType.Format.nChannels = 1; OutputType.dwChannelMask = MONO; break; case DevFmtAmbi3D: - device->FmtChans = DevFmtStereo; + mDevice->FmtChans = DevFmtStereo; /*fall-through*/ case DevFmtStereo: OutputType.Format.nChannels = 2; @@ -903,10 +899,10 @@ HRESULT ALCwasapiPlayback::resetProxy() OutputType.dwChannelMask = X7DOT1; break; } - switch(device->FmtType) + switch(mDevice->FmtType) { case DevFmtByte: - device->FmtType = DevFmtUByte; + mDevice->FmtType = DevFmtUByte; /* fall-through */ case DevFmtUByte: OutputType.Format.wBitsPerSample = 8; @@ -914,7 +910,7 @@ HRESULT ALCwasapiPlayback::resetProxy() OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; break; case DevFmtUShort: - device->FmtType = DevFmtShort; + mDevice->FmtType = DevFmtShort; /* fall-through */ case DevFmtShort: OutputType.Format.wBitsPerSample = 16; @@ -922,7 +918,7 @@ HRESULT ALCwasapiPlayback::resetProxy() OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; break; case DevFmtUInt: - device->FmtType = DevFmtInt; + mDevice->FmtType = DevFmtInt; /* fall-through */ case DevFmtInt: OutputType.Format.wBitsPerSample = 32; @@ -935,7 +931,7 @@ HRESULT ALCwasapiPlayback::resetProxy() OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; break; } - OutputType.Format.nSamplesPerSec = device->Frequency; + OutputType.Format.nSamplesPerSec = mDevice->Frequency; OutputType.Format.nBlockAlign = OutputType.Format.nChannels * OutputType.Format.wBitsPerSample / 8; @@ -964,25 +960,25 @@ HRESULT ALCwasapiPlayback::resetProxy() CoTaskMemFree(wfx); wfx = nullptr; - device->Frequency = OutputType.Format.nSamplesPerSec; + mDevice->Frequency = OutputType.Format.nSamplesPerSec; if(OutputType.Format.nChannels == 1 && OutputType.dwChannelMask == MONO) - device->FmtChans = DevFmtMono; + mDevice->FmtChans = DevFmtMono; else if(OutputType.Format.nChannels == 2 && OutputType.dwChannelMask == STEREO) - device->FmtChans = DevFmtStereo; + mDevice->FmtChans = DevFmtStereo; else if(OutputType.Format.nChannels == 4 && OutputType.dwChannelMask == QUAD) - device->FmtChans = DevFmtQuad; + mDevice->FmtChans = DevFmtQuad; else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1) - device->FmtChans = DevFmtX51; + mDevice->FmtChans = DevFmtX51; else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1REAR) - device->FmtChans = DevFmtX51Rear; + mDevice->FmtChans = DevFmtX51Rear; else if(OutputType.Format.nChannels == 7 && OutputType.dwChannelMask == X6DOT1) - device->FmtChans = DevFmtX61; + mDevice->FmtChans = DevFmtX61; else if(OutputType.Format.nChannels == 8 && (OutputType.dwChannelMask == X7DOT1 || OutputType.dwChannelMask == X7DOT1_WIDE)) - device->FmtChans = DevFmtX71; + mDevice->FmtChans = DevFmtX71; else { ERR("Unhandled extensible channels: %d -- 0x%08lx\n", OutputType.Format.nChannels, OutputType.dwChannelMask); - device->FmtChans = DevFmtStereo; + mDevice->FmtChans = DevFmtStereo; OutputType.Format.nChannels = 2; OutputType.dwChannelMask = STEREO; } @@ -990,26 +986,26 @@ HRESULT ALCwasapiPlayback::resetProxy() if(IsEqualGUID(OutputType.SubFormat, KSDATAFORMAT_SUBTYPE_PCM)) { if(OutputType.Format.wBitsPerSample == 8) - device->FmtType = DevFmtUByte; + mDevice->FmtType = DevFmtUByte; else if(OutputType.Format.wBitsPerSample == 16) - device->FmtType = DevFmtShort; + mDevice->FmtType = DevFmtShort; else if(OutputType.Format.wBitsPerSample == 32) - device->FmtType = DevFmtInt; + mDevice->FmtType = DevFmtInt; else { - device->FmtType = DevFmtShort; + mDevice->FmtType = DevFmtShort; OutputType.Format.wBitsPerSample = 16; } } else if(IsEqualGUID(OutputType.SubFormat, KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) { - device->FmtType = DevFmtFloat; + mDevice->FmtType = DevFmtFloat; OutputType.Format.wBitsPerSample = 32; } else { ERR("Unhandled format sub-type\n"); - device->FmtType = DevFmtShort; + mDevice->FmtType = DevFmtShort; OutputType.Format.wBitsPerSample = 16; OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; } @@ -1018,11 +1014,10 @@ HRESULT ALCwasapiPlayback::resetProxy() EndpointFormFactor formfactor = UnknownFormFactor; get_device_formfactor(mMMDev, &formfactor); - device->IsHeadphones = (device->FmtChans == DevFmtStereo && - (formfactor == Headphones || formfactor == Headset) - ); + mDevice->IsHeadphones = (mDevice->FmtChans == DevFmtStereo && + (formfactor == Headphones || formfactor == Headset)); - SetDefaultWFXChannelOrder(device); + SetDefaultWFXChannelOrder(mDevice); hr = mClient->Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, buf_time, 0, &OutputType.Format, nullptr); @@ -1037,10 +1032,10 @@ HRESULT ALCwasapiPlayback::resetProxy() hr = mClient->GetDevicePeriod(&min_per, nullptr); if(SUCCEEDED(hr)) { - min_len = (UINT32)ScaleCeil(min_per, device->Frequency, REFTIME_PER_SEC); + min_len = (UINT32)ScaleCeil(min_per, mDevice->Frequency, REFTIME_PER_SEC); /* Find the nearest multiple of the period size to the update size */ - if(min_len < device->UpdateSize) - min_len *= maxu((device->UpdateSize + min_len/2) / min_len, 1u); + if(min_len < mDevice->UpdateSize) + min_len *= maxu((mDevice->UpdateSize + min_len/2) / min_len, 1u); hr = mClient->GetBufferSize(&buffer_len); } if(FAILED(hr)) @@ -1049,13 +1044,13 @@ HRESULT ALCwasapiPlayback::resetProxy() return hr; } - device->UpdateSize = min_len; - device->NumUpdates = buffer_len / device->UpdateSize; - if(device->NumUpdates <= 1) + mDevice->UpdateSize = min_len; + mDevice->NumUpdates = buffer_len / mDevice->UpdateSize; + if(mDevice->NumUpdates <= 1) { ERR("Audio client returned buffer_len < period*2; expect break up\n"); - device->NumUpdates = 2; - device->UpdateSize = buffer_len / device->NumUpdates; + mDevice->NumUpdates = 2; + mDevice->UpdateSize = buffer_len / mDevice->NumUpdates; } hr = mClient->SetEventHandle(mNotifyEvent); @@ -1143,7 +1138,7 @@ ClockLatency ALCwasapiPlayback_getClockLatency(ALCwasapiPlayback *self) ClockLatency ret; ALCwasapiPlayback_lock(self); - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; ret.ClockTime = GetDeviceClockTime(device); ret.Latency = std::chrono::seconds{self->mPadding.load(std::memory_order_relaxed)}; ret.Latency /= device->Frequency; @@ -1367,7 +1362,7 @@ ALCenum ALCwasapiCapture_open(ALCwasapiCapture *self, const ALCchar *deviceName) WARN("Failed to find device name matching \"%s\"\n", deviceName); else { - ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; + ALCdevice *device{self->mDevice}; self->mDevId = iter->devid; device->DeviceName = iter->name; hr = S_OK; @@ -1425,8 +1420,6 @@ ALCenum ALCwasapiCapture_open(ALCwasapiCapture *self, const ALCchar *deviceName) HRESULT ALCwasapiCapture::openProxy() { - ALCdevice *device{STATIC_CAST(ALCbackend, this)->mDevice}; - void *ptr; HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, &ptr); @@ -1444,8 +1437,8 @@ HRESULT ALCwasapiCapture::openProxy() if(SUCCEEDED(hr)) { mClient = reinterpret_cast<IAudioClient*>(ptr); - if(device->DeviceName.empty()) - device->DeviceName = get_device_name_and_guid(mMMDev).first; + if(mDevice->DeviceName.empty()) + mDevice->DeviceName = get_device_name_and_guid(mMMDev).first; } if(FAILED(hr)) @@ -1471,8 +1464,6 @@ void ALCwasapiCapture::closeProxy() HRESULT ALCwasapiCapture::resetProxy() { - ALCdevice *device{STATIC_CAST(ALCbackend, this)->mDevice}; - if(mClient) mClient->Release(); mClient = nullptr; @@ -1486,16 +1477,16 @@ HRESULT ALCwasapiCapture::resetProxy() } mClient = reinterpret_cast<IAudioClient*>(ptr); - REFERENCE_TIME buf_time{ScaleCeil(device->UpdateSize*device->NumUpdates, REFTIME_PER_SEC, - device->Frequency)}; + REFERENCE_TIME buf_time{ScaleCeil(mDevice->UpdateSize*mDevice->NumUpdates, REFTIME_PER_SEC, + mDevice->Frequency)}; // Make sure buffer is at least 100ms in size buf_time = maxu64(buf_time, REFTIME_PER_SEC/10); - device->UpdateSize = (ALuint)ScaleCeil(buf_time, device->Frequency, REFTIME_PER_SEC) / - device->NumUpdates; + mDevice->UpdateSize = (ALuint)ScaleCeil(buf_time, mDevice->Frequency, REFTIME_PER_SEC) / + mDevice->NumUpdates; WAVEFORMATEXTENSIBLE OutputType; OutputType.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - switch(device->FmtChans) + switch(mDevice->FmtChans) { case DevFmtMono: OutputType.Format.nChannels = 1; @@ -1529,7 +1520,7 @@ HRESULT ALCwasapiCapture::resetProxy() case DevFmtAmbi3D: return E_FAIL; } - switch(device->FmtType) + switch(mDevice->FmtType) { /* NOTE: Signedness doesn't matter, the converter will handle it. */ case DevFmtByte: @@ -1553,7 +1544,7 @@ HRESULT ALCwasapiCapture::resetProxy() break; } OutputType.Samples.wValidBitsPerSample = OutputType.Format.wBitsPerSample; - OutputType.Format.nSamplesPerSec = device->Frequency; + OutputType.Format.nSamplesPerSec = mDevice->Frequency; OutputType.Format.nBlockAlign = OutputType.Format.nChannels * OutputType.Format.wBitsPerSample / 8; @@ -1579,8 +1570,8 @@ HRESULT ALCwasapiCapture::resetProxy() (wfx->nChannels == 2 && OutputType.Format.nChannels == 1))) { ERR("Failed to get matching format, wanted: %s %s %uhz, got: %d channel%s %d-bit %luhz\n", - DevFmtChannelsString(device->FmtChans), DevFmtTypeString(device->FmtType), - device->Frequency, wfx->nChannels, (wfx->nChannels==1)?"":"s", wfx->wBitsPerSample, + DevFmtChannelsString(mDevice->FmtChans), DevFmtTypeString(mDevice->FmtType), + mDevice->Frequency, wfx->nChannels, (wfx->nChannels==1)?"":"s", wfx->wBitsPerSample, wfx->nSamplesPerSec); CoTaskMemFree(wfx); return E_FAIL; @@ -1626,9 +1617,9 @@ HRESULT ALCwasapiCapture::resetProxy() return E_FAIL; } - if(device->FmtChans == DevFmtMono && OutputType.Format.nChannels == 2) + if(mDevice->FmtChans == DevFmtMono && OutputType.Format.nChannels == 2) { - mChannelConv = CreateChannelConverter(srcType, DevFmtStereo, device->FmtChans); + mChannelConv = CreateChannelConverter(srcType, DevFmtStereo, mDevice->FmtChans); if(!mChannelConv) { ERR("Failed to create %s stereo-to-mono converter\n", DevFmtTypeString(srcType)); @@ -1640,9 +1631,9 @@ HRESULT ALCwasapiCapture::resetProxy() */ srcType = DevFmtFloat; } - else if(device->FmtChans == DevFmtStereo && OutputType.Format.nChannels == 1) + else if(mDevice->FmtChans == DevFmtStereo && OutputType.Format.nChannels == 1) { - mChannelConv = CreateChannelConverter(srcType, DevFmtMono, device->FmtChans); + mChannelConv = CreateChannelConverter(srcType, DevFmtMono, mDevice->FmtChans); if(!mChannelConv) { ERR("Failed to create %s mono-to-stereo converter\n", DevFmtTypeString(srcType)); @@ -1652,22 +1643,20 @@ HRESULT ALCwasapiCapture::resetProxy() srcType = DevFmtFloat; } - if(device->Frequency != OutputType.Format.nSamplesPerSec || device->FmtType != srcType) + if(mDevice->Frequency != OutputType.Format.nSamplesPerSec || mDevice->FmtType != srcType) { - mSampleConv = CreateSampleConverter( - srcType, device->FmtType, device->channelsFromFmt(), OutputType.Format.nSamplesPerSec, - device->Frequency, BSinc24Resampler - ); + mSampleConv = CreateSampleConverter(srcType, mDevice->FmtType, mDevice->channelsFromFmt(), + OutputType.Format.nSamplesPerSec, mDevice->Frequency, BSinc24Resampler); if(!mSampleConv) { ERR("Failed to create converter for %s format, dst: %s %uhz, src: %s %luhz\n", - DevFmtChannelsString(device->FmtChans), DevFmtTypeString(device->FmtType), - device->Frequency, DevFmtTypeString(srcType), OutputType.Format.nSamplesPerSec); + DevFmtChannelsString(mDevice->FmtChans), DevFmtTypeString(mDevice->FmtType), + mDevice->Frequency, DevFmtTypeString(srcType), OutputType.Format.nSamplesPerSec); return E_FAIL; } TRACE("Created converter for %s format, dst: %s %uhz, src: %s %luhz\n", - DevFmtChannelsString(device->FmtChans), DevFmtTypeString(device->FmtType), - device->Frequency, DevFmtTypeString(srcType), OutputType.Format.nSamplesPerSec); + DevFmtChannelsString(mDevice->FmtChans), DevFmtTypeString(mDevice->FmtType), + mDevice->Frequency, DevFmtTypeString(srcType), OutputType.Format.nSamplesPerSec); } hr = mClient->Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, @@ -1686,8 +1675,8 @@ HRESULT ALCwasapiCapture::resetProxy() return hr; } - buffer_len = maxu(device->UpdateSize*device->NumUpdates, buffer_len); - mRing = CreateRingBuffer(buffer_len, device->frameSizeFromFmt(), false); + buffer_len = maxu(mDevice->UpdateSize*mDevice->NumUpdates, buffer_len); + mRing = CreateRingBuffer(buffer_len, mDevice->frameSizeFromFmt(), false); if(!mRing) { ERR("Failed to allocate capture ring buffer\n"); @@ -1875,15 +1864,13 @@ ALCbackend *WasapiBackendFactory::createBackend(ALCdevice *device, ALCbackend_Ty { ALCwasapiPlayback *backend; NEW_OBJ(backend, ALCwasapiPlayback)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { ALCwasapiCapture *backend; NEW_OBJ(backend, ALCwasapiCapture)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp index 3a65fc64..11e8a440 100644 --- a/Alc/backends/wave.cpp +++ b/Alc/backends/wave.cpp @@ -125,7 +125,7 @@ void ALCwaveBackend_Destruct(ALCwaveBackend *self) int ALCwaveBackend_mixerProc(ALCwaveBackend *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; const milliseconds restTime{device->UpdateSize*1000/device->Frequency / 2}; althrd_setname(MIXER_THREAD_NAME); @@ -234,7 +234,7 @@ ALCenum ALCwaveBackend_open(ALCwaveBackend *self, const ALCchar *name) return ALC_INVALID_VALUE; } - ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; + ALCdevice *device{self->mDevice}; device->DeviceName = name; return ALC_NO_ERROR; @@ -242,7 +242,7 @@ ALCenum ALCwaveBackend_open(ALCwaveBackend *self, const ALCchar *name) ALCboolean ALCwaveBackend_reset(ALCwaveBackend *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; ALuint channels=0, bits=0, chanmask=0; int isbformat = 0; size_t val; @@ -404,8 +404,7 @@ ALCbackend *WaveBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type { ALCwaveBackend *backend; NEW_OBJ(backend, ALCwaveBackend)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp index ab638cd4..31c39c52 100644 --- a/Alc/backends/winmm.cpp +++ b/Alc/backends/winmm.cpp @@ -196,7 +196,7 @@ void CALLBACK ALCwinmmPlayback_waveOutProc(HWAVEOUT UNUSED(device), UINT msg, FORCE_ALIGN int ALCwinmmPlayback_mixerProc(ALCwinmmPlayback *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; SetRTPriority(); althrd_setname(MIXER_THREAD_NAME); @@ -233,7 +233,7 @@ FORCE_ALIGN int ALCwinmmPlayback_mixerProc(ALCwinmmPlayback *self) ALCenum ALCwinmmPlayback_open(ALCwinmmPlayback *self, const ALCchar *deviceName) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; if(PlaybackDevices.empty()) ProbePlaybackDevices(); @@ -288,7 +288,7 @@ retry_open: ALCboolean ALCwinmmPlayback_reset(ALCwinmmPlayback *self) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; device->UpdateSize = (ALuint)((ALuint64)device->UpdateSize * self->Format.nSamplesPerSec / @@ -509,7 +509,7 @@ int ALCwinmmCapture_captureProc(ALCwinmmCapture *self) ALCenum ALCwinmmCapture_open(ALCwinmmCapture *self, const ALCchar *deviceName) { - ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALCdevice *device{self->mDevice}; if(CaptureDevices.empty()) ProbeCaptureDevices(); @@ -700,15 +700,13 @@ ALCbackend *WinMMBackendFactory::createBackend(ALCdevice *device, ALCbackend_Typ { ALCwinmmPlayback *backend; NEW_OBJ(backend, ALCwinmmPlayback)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } if(type == ALCbackend_Capture) { ALCwinmmCapture *backend; NEW_OBJ(backend, ALCwinmmCapture)(device); - if(!backend) return nullptr; - return STATIC_CAST(ALCbackend, backend); + return backend; } return nullptr; |