mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 16:26:39 +01:00
Sound: fix typo and mem leaks
This commit is contained in:
@@ -64,7 +64,7 @@ const char* ffDetectSound(FFlist* devices)
|
||||
return "sioctl_ondesc() failed";
|
||||
|
||||
if (bundle.iLevel != bundle.iMute || bundle.iLevel == 0)
|
||||
return "Unexpecd sioctl_ondesc() result";
|
||||
return "Unexpected sioctl_ondesc() result";
|
||||
|
||||
FFSoundDevice* device = ffListAdd(devices);
|
||||
ffStrbufInitS(&device->name, bundle.name);
|
||||
|
||||
@@ -9,6 +9,14 @@ extern "C" {
|
||||
#include <endpointvolume.h>
|
||||
#include <functiondiscoverykeys_devpkey.h>
|
||||
|
||||
static void ffCoTaskMemFreeWrapper(void* pptr)
|
||||
{
|
||||
assert(pptr != NULL);
|
||||
void* ptr = *(void**)pptr;
|
||||
if (ptr) CoTaskMemFree(ptr);
|
||||
}
|
||||
#define FF_COTASK_AUTO_FREE __attribute__((__cleanup__(ffCoTaskMemFreeWrapper)))
|
||||
|
||||
const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
|
||||
{
|
||||
const char* error = ffInitCom();
|
||||
@@ -20,7 +28,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
|
||||
if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void **)&pEnum)))
|
||||
return "CoCreateInstance(CLSID_MMDeviceEnumerator) failed";
|
||||
|
||||
LPWSTR mainDeviceId = NULL;
|
||||
LPWSTR FF_COTASK_AUTO_FREE mainDeviceId = NULL;
|
||||
|
||||
{
|
||||
IMMDevice* FF_AUTO_RELEASE_COM_OBJECT pDefaultDevice = NULL;
|
||||
@@ -47,7 +55,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
|
||||
if (FAILED(pDevices->Item(deviceIdx, &immDevice)))
|
||||
continue;
|
||||
|
||||
LPWSTR immDeviceId = NULL;
|
||||
LPWSTR FF_COTASK_AUTO_FREE immDeviceId = NULL;
|
||||
if (FAILED(immDevice->GetId(&immDeviceId)))
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user