Use static_cast instead of reinterpret_cast where possible
This commit is contained in:
parent
01ed98c99b
commit
67b874328d
@ -158,7 +158,7 @@ BOOL CALLBACK DSoundEnumDevices(GUID *guid, const WCHAR *desc, const WCHAR* UNUS
|
||||
if(!guid)
|
||||
return TRUE;
|
||||
|
||||
auto& devices = *reinterpret_cast<al::vector<DevMap>*>(data);
|
||||
auto& devices = *static_cast<al::vector<DevMap>*>(data);
|
||||
const std::string basename{DEVNAME_HEAD + wstr_to_utf8(desc)};
|
||||
|
||||
int count{1};
|
||||
|
@ -371,7 +371,7 @@ pa_proplist *prop_filter;
|
||||
/* PulseAudio Event Callbacks */
|
||||
void context_state_callback(pa_context *context, void *pdata)
|
||||
{
|
||||
auto loop = reinterpret_cast<pa_threaded_mainloop*>(pdata);
|
||||
auto loop = static_cast<pa_threaded_mainloop*>(pdata);
|
||||
pa_context_state_t state{pa_context_get_state(context)};
|
||||
if(state == PA_CONTEXT_READY || !PA_CONTEXT_IS_GOOD(state))
|
||||
pa_threaded_mainloop_signal(loop, 0);
|
||||
@ -379,7 +379,7 @@ void context_state_callback(pa_context *context, void *pdata)
|
||||
|
||||
void stream_state_callback(pa_stream *stream, void *pdata)
|
||||
{
|
||||
auto loop = reinterpret_cast<pa_threaded_mainloop*>(pdata);
|
||||
auto loop = static_cast<pa_threaded_mainloop*>(pdata);
|
||||
pa_stream_state_t state{pa_stream_get_state(stream)};
|
||||
if(state == PA_STREAM_READY || !PA_STREAM_IS_GOOD(state))
|
||||
pa_threaded_mainloop_signal(loop, 0);
|
||||
@ -387,7 +387,7 @@ void stream_state_callback(pa_stream *stream, void *pdata)
|
||||
|
||||
void stream_success_callback(pa_stream *UNUSED(stream), int UNUSED(success), void *pdata)
|
||||
{
|
||||
auto loop = reinterpret_cast<pa_threaded_mainloop*>(pdata);
|
||||
auto loop = static_cast<pa_threaded_mainloop*>(pdata);
|
||||
pa_threaded_mainloop_signal(loop, 0);
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ struct WasapiProxy {
|
||||
|
||||
DWORD WasapiProxy::messageHandler(void *ptr)
|
||||
{
|
||||
auto req = reinterpret_cast<ThreadRequest*>(ptr);
|
||||
auto req = static_cast<ThreadRequest*>(ptr);
|
||||
|
||||
TRACE("Starting message thread\n");
|
||||
|
||||
@ -365,8 +365,8 @@ DWORD WasapiProxy::messageHandler(void *ptr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_INPROC_SERVER,
|
||||
IID_IMMDeviceEnumerator, &ptr);
|
||||
HRESULT hr{CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_INPROC_SERVER,
|
||||
IID_IMMDeviceEnumerator, &ptr)};
|
||||
if(FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create IMMDeviceEnumerator instance: 0x%08lx\n", hr);
|
||||
@ -374,7 +374,7 @@ DWORD WasapiProxy::messageHandler(void *ptr)
|
||||
ReturnMsgResponse(req, hr);
|
||||
return 0;
|
||||
}
|
||||
auto Enumerator = reinterpret_cast<IMMDeviceEnumerator*>(ptr);
|
||||
auto Enumerator = static_cast<IMMDeviceEnumerator*>(ptr);
|
||||
Enumerator->Release();
|
||||
Enumerator = nullptr;
|
||||
|
||||
@ -466,7 +466,7 @@ DWORD WasapiProxy::messageHandler(void *ptr)
|
||||
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, &ptr);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
Enumerator = reinterpret_cast<IMMDeviceEnumerator*>(ptr);
|
||||
Enumerator = static_cast<IMMDeviceEnumerator*>(ptr);
|
||||
|
||||
if(msg.lParam == ALL_DEVICE_PROBE)
|
||||
hr = probe_devices(Enumerator, eRender, PlaybackDevices);
|
||||
@ -757,10 +757,10 @@ ALCenum WasapiPlayback_open(WasapiPlayback *self, const ALCchar *deviceName)
|
||||
HRESULT WasapiPlayback::openProxy()
|
||||
{
|
||||
void *ptr;
|
||||
HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, &ptr);
|
||||
HRESULT hr{CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, &ptr)};
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
auto Enumerator = reinterpret_cast<IMMDeviceEnumerator*>(ptr);
|
||||
auto Enumerator = static_cast<IMMDeviceEnumerator*>(ptr);
|
||||
if(mDevId.empty())
|
||||
hr = Enumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &mMMDev);
|
||||
else
|
||||
@ -771,7 +771,7 @@ HRESULT WasapiPlayback::openProxy()
|
||||
hr = mMMDev->Activate(IID_IAudioClient, CLSCTX_INPROC_SERVER, nullptr, &ptr);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
mClient = reinterpret_cast<IAudioClient*>(ptr);
|
||||
mClient = static_cast<IAudioClient*>(ptr);
|
||||
if(mDevice->DeviceName.empty())
|
||||
mDevice->DeviceName = get_device_name_and_guid(mMMDev).first;
|
||||
}
|
||||
@ -823,7 +823,7 @@ HRESULT WasapiPlayback::resetProxy()
|
||||
ERR("Failed to reactivate audio client: 0x%08lx\n", hr);
|
||||
return hr;
|
||||
}
|
||||
mClient = reinterpret_cast<IAudioClient*>(ptr);
|
||||
mClient = static_cast<IAudioClient*>(ptr);
|
||||
|
||||
WAVEFORMATEX *wfx;
|
||||
hr = mClient->GetMixFormat(&wfx);
|
||||
@ -1093,7 +1093,7 @@ HRESULT WasapiPlayback::startProxy()
|
||||
hr = mClient->GetService(IID_IAudioRenderClient, &ptr);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
mRender = reinterpret_cast<IAudioRenderClient*>(ptr);
|
||||
mRender = static_cast<IAudioRenderClient*>(ptr);
|
||||
try {
|
||||
mKillNow.store(AL_FALSE, std::memory_order_release);
|
||||
mThread = std::thread{std::mem_fn(&WasapiPlayback::mixerProc), this};
|
||||
@ -1421,11 +1421,11 @@ ALCenum WasapiCapture_open(WasapiCapture *self, const ALCchar *deviceName)
|
||||
HRESULT WasapiCapture::openProxy()
|
||||
{
|
||||
void *ptr;
|
||||
HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_INPROC_SERVER,
|
||||
IID_IMMDeviceEnumerator, &ptr);
|
||||
HRESULT hr{CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_INPROC_SERVER,
|
||||
IID_IMMDeviceEnumerator, &ptr)};
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
auto Enumerator = reinterpret_cast<IMMDeviceEnumerator*>(ptr);
|
||||
auto Enumerator = static_cast<IMMDeviceEnumerator*>(ptr);
|
||||
if(mDevId.empty())
|
||||
hr = Enumerator->GetDefaultAudioEndpoint(eCapture, eMultimedia, &mMMDev);
|
||||
else
|
||||
@ -1436,7 +1436,7 @@ HRESULT WasapiCapture::openProxy()
|
||||
hr = mMMDev->Activate(IID_IAudioClient, CLSCTX_INPROC_SERVER, nullptr, &ptr);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
mClient = reinterpret_cast<IAudioClient*>(ptr);
|
||||
mClient = static_cast<IAudioClient*>(ptr);
|
||||
if(mDevice->DeviceName.empty())
|
||||
mDevice->DeviceName = get_device_name_and_guid(mMMDev).first;
|
||||
}
|
||||
@ -1475,7 +1475,7 @@ HRESULT WasapiCapture::resetProxy()
|
||||
ERR("Failed to reactivate audio client: 0x%08lx\n", hr);
|
||||
return hr;
|
||||
}
|
||||
mClient = reinterpret_cast<IAudioClient*>(ptr);
|
||||
mClient = static_cast<IAudioClient*>(ptr);
|
||||
|
||||
REFERENCE_TIME buf_time{ScaleCeil(mDevice->UpdateSize*mDevice->NumUpdates, REFTIME_PER_SEC,
|
||||
mDevice->Frequency)};
|
||||
@ -1721,7 +1721,7 @@ HRESULT WasapiCapture::startProxy()
|
||||
hr = mClient->GetService(IID_IAudioCaptureClient, &ptr);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
mCapture = reinterpret_cast<IAudioCaptureClient*>(ptr);
|
||||
mCapture = static_cast<IAudioCaptureClient*>(ptr);
|
||||
try {
|
||||
mKillNow.store(AL_FALSE, std::memory_order_release);
|
||||
mThread = std::thread{std::mem_fn(&WasapiCapture::recordProc), this};
|
||||
|
@ -73,7 +73,7 @@ inline T* assume_aligned(T *ptr) noexcept
|
||||
{
|
||||
static_assert((alignment & (alignment-1)) == 0, "alignment must be a power of 2");
|
||||
#ifdef __GNUC__
|
||||
return reinterpret_cast<T*>(__builtin_assume_aligned(ptr, alignment));
|
||||
return static_cast<T*>(__builtin_assume_aligned(ptr, alignment));
|
||||
#elif defined(_MSC_VER)
|
||||
auto ptrval = reinterpret_cast<uintptr_t>(ptr);
|
||||
if((ptrval&(alignment-1)) != 0) __assume(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user