Global: replaces NULL to nullptr

This commit is contained in:
李通洲
2026-07-10 18:08:04 +08:00
parent 873454191f
commit ba18705d2e
387 changed files with 2411 additions and 2411 deletions
+16 -16
View File
@@ -11,7 +11,7 @@
const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FFSoundDevice */) {
AudioDeviceID mainDeviceId;
UInt32 dataSize = sizeof(mainDeviceId);
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &mainDeviceId) != kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &mainDeviceId) != kAudioHardwareNoError) {
return "AudioObjectGetPropertyData(kAudioHardwarePropertyDefaultOutputDevice) failed";
}
@@ -21,7 +21,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
dataSize = sizeof(mainDeviceId);
} else {
dataSize = sizeof(deviceIds);
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &deviceIds) != kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &deviceIds) != kAudioHardwareNoError) {
return "AudioObjectGetPropertyData(kAudioHardwarePropertyDevices) failed";
}
}
@@ -30,16 +30,16 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
AudioDeviceID deviceId = deviceIds[index];
// Ignore input devices
if (AudioObjectGetPropertyDataSize(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyStreams, kAudioObjectPropertyScopeInput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize) == kAudioHardwareNoError && dataSize > 0) {
if (AudioObjectGetPropertyDataSize(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyStreams, kAudioObjectPropertyScopeInput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize) == kAudioHardwareNoError && dataSize > 0) {
continue;
}
uint32_t dataSource;
dataSize = sizeof(dataSource);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDataSource, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &dataSource) == kAudioHardwareNoError && dataSource == 'hdpn') {
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDataSource, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &dataSource) == kAudioHardwareNoError && dataSource == 'hdpn') {
uint32_t connected;
dataSize = sizeof(connected);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyJackIsConnected, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &connected) == kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyJackIsConnected, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &connected) == kAudioHardwareNoError) {
if (!connected) {
continue;
}
@@ -48,7 +48,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
uint32_t active = true;
dataSize = sizeof(active);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &active) == kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &active) == kAudioHardwareNoError) {
if ((options->soundType & FF_SOUND_TYPE_ACTIVE) && !active) {
continue;
}
@@ -62,17 +62,17 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
ffStrbufInit(&device->name);
ffStrbufInitStatic(&device->platformApi, "Core Audio");
FF_CFTYPE_AUTO_RELEASE CFStringRef uid = NULL;
FF_CFTYPE_AUTO_RELEASE CFStringRef uid = nullptr;
dataSize = sizeof(uid);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDeviceUID, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &uid) == kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDeviceUID, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &uid) == kAudioHardwareNoError) {
ffCfStrGetString(uid, &device->identifier);
} else {
ffStrbufAppendF(&device->identifier, "ID-%u", (unsigned) deviceId);
}
FF_CFTYPE_AUTO_RELEASE CFStringRef name = NULL;
FF_CFTYPE_AUTO_RELEASE CFStringRef name = nullptr;
dataSize = sizeof(name);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioObjectPropertyName, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &name) == kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioObjectPropertyName, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &name) == kAudioHardwareNoError) {
ffCfStrGetString(name, &device->name);
} else {
ffStrbufSet(&device->name, &device->identifier);
@@ -80,7 +80,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
uint32_t muted;
dataSize = sizeof(muted);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyMute, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &muted) != kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyMute, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &muted) != kAudioHardwareNoError) {
muted = false; // Device may not support volume control
}
@@ -89,17 +89,17 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
} else {
float volume;
dataSize = sizeof(volume);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, &volume) == kAudioHardwareNoError) {
device->volume = (uint8_t) (volume * 100 + 0.5);
} else {
// Try detecting volume from channels
uint32_t channels[2];
dataSize = sizeof(channels);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyPreferredChannelsForStereo, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, channels) == kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyPreferredChannelsForStereo, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, nullptr, &dataSize, channels) == kAudioHardwareNoError) {
dataSize = sizeof(volume);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[0] }, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[0] }, 0, nullptr, &dataSize, &volume) == kAudioHardwareNoError) {
float temp;
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[1] }, 0, NULL, &dataSize, &temp) == kAudioHardwareNoError) {
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[1] }, 0, nullptr, &dataSize, &temp) == kAudioHardwareNoError) {
device->volume = (uint8_t) ((volume + temp) / 2 * 100 + 0.5);
}
}
@@ -108,5 +108,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
}
}
return NULL;
return nullptr;
}
+1 -1
View File
@@ -86,5 +86,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) {
device->type = FF_SOUND_TYPE_ACTIVE | (isMain ? FF_SOUND_TYPE_MAIN : FF_SOUND_TYPE_NONE);
}
return NULL;
return nullptr;
}
+10 -10
View File
@@ -14,7 +14,7 @@ const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices /
dormant_node_info dormantInfo;
if (roster->GetAudioOutput(&mediaNode) != B_OK) {
return NULL;
return nullptr;
}
FFSoundDevice* device = FF_LIST_ADD(FFSoundDevice, *devices);
@@ -36,20 +36,20 @@ const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices /
media_node mixer;
if (roster->GetAudioMixer(&mixer) != B_OK) {
return NULL;
return nullptr;
}
BParameterWeb* web;
status_t status = roster->GetParameterWebFor(mixer, &web);
roster->ReleaseNode(mixer); // the web is all we need :-)
if (status != B_OK) {
return NULL;
return nullptr;
}
BContinuousParameter* gain = NULL;
BParameter* mute = NULL;
BContinuousParameter* gain = nullptr;
BParameter* mute = nullptr;
BParameter* parameter;
for (int32 index = 0; (parameter = web->ParameterAt(index)) != NULL; index++) {
for (int32 index = 0; (parameter = web->ParameterAt(index)) != nullptr; index++) {
// assume the mute preceding master gain control
if (ffStrEquals(parameter->Kind(), B_MUTE)) {
mute = parameter;
@@ -63,8 +63,8 @@ const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices /
}
}
if (gain == NULL) {
return NULL;
if (gain == nullptr) {
return nullptr;
}
bigtime_t when;
@@ -74,7 +74,7 @@ const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices /
int32 isMute = false;
size = sizeof(isMute);
if (mute->GetValue(&isMute, &size, &when) == B_OK && isMute) {
return NULL;
return nullptr;
}
}
@@ -84,5 +84,5 @@ const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices /
device->volume = (uint8_t) (100 * (volume - gain->MinValue()) / (gain->MaxValue() - gain->MinValue()));
}
return NULL;
return nullptr;
}
+5 -5
View File
@@ -96,9 +96,9 @@ static const char* detectSound(FFSoundOptions* options, FFlist* devices) {
.result = devices,
.options = options,
};
const char* error = NULL;
const char* error = nullptr;
if (ffpa_context_connect(context, NULL, PA_CONTEXT_NOFLAGS, NULL) < 0) {
if (ffpa_context_connect(context, nullptr, PA_CONTEXT_NOFLAGS, nullptr) < 0) {
error = "Failed to connect to pulseaudio context";
goto exit;
}
@@ -110,7 +110,7 @@ static const char* detectSound(FFSoundOptions* options, FFlist* devices) {
goto exit;
}
ffpa_mainloop_iterate(mainloop, 1, NULL);
ffpa_mainloop_iterate(mainloop, 1, nullptr);
}
{
@@ -120,7 +120,7 @@ static const char* detectSound(FFSoundOptions* options, FFlist* devices) {
goto exit;
}
while (ffpa_operation_get_state(operation) == PA_OPERATION_RUNNING) {
ffpa_mainloop_iterate(mainloop, 1, NULL);
ffpa_mainloop_iterate(mainloop, 1, nullptr);
}
ffpa_operation_unref(operation);
@@ -138,7 +138,7 @@ static const char* detectSound(FFSoundOptions* options, FFlist* devices) {
ffpa_operation_cancel(operation);
}
ffpa_mainloop_iterate(mainloop, 1, NULL);
ffpa_mainloop_iterate(mainloop, 1, nullptr);
}
ffpa_operation_unref(operation);
+1 -1
View File
@@ -54,5 +54,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) {
device->type = FF_SOUND_TYPE_ACTIVE | (isMain ? FF_SOUND_TYPE_MAIN : FF_SOUND_TYPE_NONE);
}
return NULL;
return nullptr;
}
+1 -1
View File
@@ -86,5 +86,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) {
}
device->volume = (uint8_t) ((totalLevel * 100 + bundle.iLevel / 2) / bundle.iLevel);
return NULL;
return nullptr;
}
+1 -1
View File
@@ -105,5 +105,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) {
(isMain ? FF_SOUND_TYPE_MAIN : FF_SOUND_TYPE_NONE);
}
return NULL;
return nullptr;
}
+14 -14
View File
@@ -11,7 +11,7 @@ extern "C" {
#include <functiondiscoverykeys_devpkey.h>
static void ffCoTaskMemFreeWrapper(void* pptr) {
assert(pptr != NULL);
assert(pptr != nullptr);
void* ptr = *(void**) pptr;
if (ptr) {
CoTaskMemFree(ptr);
@@ -20,12 +20,12 @@ static void ffCoTaskMemFreeWrapper(void* pptr) {
#define FF_COTASK_AUTO_FREE FF_A_CLEANUP(ffCoTaskMemFreeWrapper)
static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */, IMMDevice* immDevice, LPWSTR mainDeviceId) {
LPWSTR FF_COTASK_AUTO_FREE immDeviceId = NULL;
LPWSTR FF_COTASK_AUTO_FREE immDeviceId = nullptr;
if (FAILED(immDevice->GetId(&immDeviceId))) {
return "immDevice->GetId() failed";
}
IPropertyStore* FF_AUTO_RELEASE_COM_OBJECT immPropStore = NULL;
IPropertyStore* FF_AUTO_RELEASE_COM_OBJECT immPropStore = nullptr;
if (FAILED(immDevice->OpenPropertyStore(STGM_READ, &immPropStore))) {
return "immDevice->OpenPropertyStore() failed";
}
@@ -54,8 +54,8 @@ static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */
}
}
IAudioEndpointVolume* FF_AUTO_RELEASE_COM_OBJECT immEndpointVolume = NULL;
if (SUCCEEDED(immDevice->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**) &immEndpointVolume))) {
IAudioEndpointVolume* FF_AUTO_RELEASE_COM_OBJECT immEndpointVolume = nullptr;
if (SUCCEEDED(immDevice->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, nullptr, (void**) &immEndpointVolume))) {
BOOL muted;
if (FAILED(immEndpointVolume->GetMute(&muted)) || !muted) {
FLOAT volume;
@@ -65,7 +65,7 @@ static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */
}
}
return NULL;
return nullptr;
}
const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FFSoundDevice */) {
@@ -74,23 +74,23 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
return error;
}
IMMDeviceEnumerator* FF_AUTO_RELEASE_COM_OBJECT pEnum = NULL;
IMMDeviceEnumerator* FF_AUTO_RELEASE_COM_OBJECT pEnum = nullptr;
if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pEnum)))) {
if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pEnum)))) {
return "CoCreateInstance(CLSID_MMDeviceEnumerator) failed";
}
LPWSTR FF_COTASK_AUTO_FREE mainDeviceId = NULL;
LPWSTR FF_COTASK_AUTO_FREE mainDeviceId = nullptr;
{
IMMDevice* FF_AUTO_RELEASE_COM_OBJECT pDefaultDevice = NULL;
IMMDevice* FF_AUTO_RELEASE_COM_OBJECT pDefaultDevice = nullptr;
if (FAILED(pEnum->GetDefaultAudioEndpoint(eRender, eMultimedia, &pDefaultDevice))) {
return "GetDefaultAudioEndpoint() failed";
}
if (options->soundType & FF_SOUND_TYPE_MAIN) {
return detectSoundDevice(devices, pDefaultDevice, NULL);
return detectSoundDevice(devices, pDefaultDevice, nullptr);
}
if (FAILED(pDefaultDevice->GetId(&mainDeviceId))) {
@@ -98,7 +98,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
}
}
IMMDeviceCollection* FF_AUTO_RELEASE_COM_OBJECT pDevices = NULL;
IMMDeviceCollection* FF_AUTO_RELEASE_COM_OBJECT pDevices = nullptr;
if (FAILED(pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE | (options->soundType & FF_SOUND_TYPE_ACTIVE ? 0 : DEVICE_STATE_DISABLED), &pDevices))) {
return "EnumAudioEndpoints() failed";
@@ -110,7 +110,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
}
for (uint32_t deviceIdx = 0; deviceIdx < deviceCount; ++deviceIdx) {
IMMDevice* FF_AUTO_RELEASE_COM_OBJECT immDevice = NULL;
IMMDevice* FF_AUTO_RELEASE_COM_OBJECT immDevice = nullptr;
if (FAILED(pDevices->Item(deviceIdx, &immDevice))) {
continue;
}
@@ -118,5 +118,5 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
detectSoundDevice(devices, immDevice, mainDeviceId);
}
return NULL;
return nullptr;
}