mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -13,7 +13,7 @@ static void removeMediaCoverFile(void) {
|
||||
}
|
||||
|
||||
const FFMediaResult* ffDetectMedia(bool saveCover) {
|
||||
if (result.error.chars == NULL) {
|
||||
if (result.error.chars == nullptr) {
|
||||
ffStrbufInit(&result.error);
|
||||
ffStrbufInit(&result.playerId);
|
||||
ffStrbufInit(&result.player);
|
||||
|
||||
@@ -16,7 +16,7 @@ extern void MRMediaRemoteGetNowPlayingApplicationDisplayName(int unknown, dispat
|
||||
|
||||
static uint32_t getTrueElapsedTime(CFDictionaryRef info) {
|
||||
double elapsedTime;
|
||||
if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoElapsedTime"), &elapsedTime) != NULL) {
|
||||
if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoElapsedTime"), &elapsedTime) != nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ static uint32_t getTrueElapsedTime(CFDictionaryRef info) {
|
||||
|
||||
double playbackRate;
|
||||
uint64_t timestampEpoch;
|
||||
if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoPlaybackRate"), &playbackRate) == NULL &&
|
||||
ffCfDictGetDateAsEpoch(info, CFSTR("kMRMediaRemoteNowPlayingInfoTimestamp"), ×tampEpoch) == NULL) {
|
||||
if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoPlaybackRate"), &playbackRate) == nullptr &&
|
||||
ffCfDictGetDateAsEpoch(info, CFSTR("kMRMediaRemoteNowPlayingInfoTimestamp"), ×tampEpoch) == nullptr) {
|
||||
uint64_t timeDiff = ffTimeGetNow() - timestampEpoch;
|
||||
elapsedTime += (double) timeDiff * playbackRate;
|
||||
}
|
||||
@@ -44,14 +44,14 @@ static const char* getMediaByMediaRemote(FFMediaResult* result, bool saveCover)
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
|
||||
|
||||
dispatch_group_enter(group);
|
||||
__block const char* error = NULL;
|
||||
__block const char* error = nullptr;
|
||||
MRMediaRemoteGetNowPlayingInfo(queue, ^(_Nullable CFDictionaryRef info) {
|
||||
if (info != nil) {
|
||||
ffCfDictGetString(info, CFSTR("kMRMediaRemoteNowPlayingInfoTitle"), &result->song);
|
||||
ffCfDictGetString(info, CFSTR("kMRMediaRemoteNowPlayingInfoArtist"), &result->artist);
|
||||
ffCfDictGetString(info, CFSTR("kMRMediaRemoteNowPlayingInfoAlbum"), &result->album);
|
||||
double value;
|
||||
if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoDuration"), &value) == NULL) {
|
||||
if (ffCfDictGetDouble(info, CFSTR("kMRMediaRemoteNowPlayingInfoDuration"), &value) == nullptr) {
|
||||
result->length = (uint32_t) (value * 1000);
|
||||
result->position = getTrueElapsedTime(info);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ static const char* getMediaByMediaRemote(FFMediaResult* result, bool saveCover)
|
||||
CFStringRef mime = (CFStringRef) CFDictionaryGetValue(info, CFSTR("kMRMediaRemoteNowPlayingInfoArtworkMIMEType"));
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
FF_CFTYPE_AUTO_RELEASE CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mime, NULL);
|
||||
FF_CFTYPE_AUTO_RELEASE CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mime, nullptr);
|
||||
FF_CFTYPE_AUTO_RELEASE CFStringRef ext = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassFilenameExtension);
|
||||
#pragma clang diagnostic pop
|
||||
NSString* tmpDir = NSTemporaryDirectory();
|
||||
@@ -104,7 +104,7 @@ static const char* getMediaByMediaRemote(FFMediaResult* result, bool saveCover)
|
||||
// Don't dispatch_release because we are using ARC
|
||||
|
||||
if (result->song.length > 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return error;
|
||||
@@ -121,7 +121,7 @@ __attribute__((visibility("default"), used)) int ffPrintMediaByMediaRemote(int s
|
||||
.player = ffStrbufCreate(),
|
||||
.cover = ffStrbufCreate(),
|
||||
};
|
||||
if (getMediaByMediaRemote(&media, !!saveCover) != NULL) {
|
||||
if (getMediaByMediaRemote(&media, !!saveCover) != nullptr) {
|
||||
return 1;
|
||||
}
|
||||
ffStrbufAppendC(&media.status, '\n');
|
||||
@@ -180,16 +180,16 @@ exit(fn(%c))",
|
||||
|
||||
// status\ntitle\nartist\nalbum\nbundleName\nappName\ncoverPath\nelapsedTimeMS\ndurationMS
|
||||
FFstrbuf* const strList[] = { &result->status, &result->song, &result->artist, &result->album, &result->playerId, &result->player, &result->cover };
|
||||
char* line = NULL;
|
||||
char* line = nullptr;
|
||||
size_t len = 0;
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(strList) && ffStrbufGetline(&line, &len, &buffer); ++i) {
|
||||
ffStrbufSetS(strList[i], line);
|
||||
}
|
||||
uint32_t* const numList[] = { &result->position, &result->length };
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(numList) && ffStrbufGetline(&line, &len, &buffer); ++i) {
|
||||
*numList[i] = (uint32_t) strtoul(line, NULL, 10);
|
||||
*numList[i] = (uint32_t) strtoul(line, nullptr, 10);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ffDetectMediaImpl(FFMediaResult* media, bool saveCover) {
|
||||
|
||||
@@ -81,7 +81,7 @@ static bool parseMprisMetadata(FFDBusData* data, DBusMessageIter* rootIterator,
|
||||
break;
|
||||
}
|
||||
char str[] = { path.chars[i + 1], path.chars[i + 2], 0 };
|
||||
char* end = NULL;
|
||||
char* end = nullptr;
|
||||
const char decodedChar = (char) strtoul(str, &end, 16);
|
||||
if (end == &str[2]) {
|
||||
i += 2;
|
||||
@@ -111,7 +111,7 @@ static bool parseMprisMetadata(FFDBusData* data, DBusMessageIter* rootIterator,
|
||||
static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResult* result) {
|
||||
// Get all properties at once to reduce the number of IPCs
|
||||
DBusMessage* reply = ffDBusGetAllProperties(data, busName, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player");
|
||||
if (reply == NULL) {
|
||||
if (reply == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul
|
||||
break;
|
||||
}
|
||||
char str[] = { fileName[1], fileName[2], 0 };
|
||||
ffStrbufAppendC(&result->song, (char) strtoul(str, NULL, 16));
|
||||
ffStrbufAppendC(&result->song, (char) strtoul(str, nullptr, 16));
|
||||
fileName += 2;
|
||||
}
|
||||
}
|
||||
@@ -221,8 +221,8 @@ static void getBestBus(FFDBusData* data, FFMediaResult* result) {
|
||||
return;
|
||||
}
|
||||
|
||||
DBusMessage* reply = ffDBusGetMethodReply(data, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames", NULL, NULL);
|
||||
if (reply == NULL) {
|
||||
DBusMessage* reply = ffDBusGetMethodReply(data, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames", nullptr, nullptr);
|
||||
if (reply == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ static void getBestBus(FFDBusData* data, FFMediaResult* result) {
|
||||
static const char* getMedia(FFMediaResult* result) {
|
||||
FF_DBUS_AUTO_DESTROY_DATA FFDBusData data = {};
|
||||
const char* error = ffDBusLoadData(DBUS_BUS_SESSION, &data);
|
||||
if (error != NULL) {
|
||||
if (error != nullptr) {
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ static const char* getMedia(FFMediaResult* result) {
|
||||
getBestBus(&data, result);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,7 +51,7 @@ static inline HRESULT ffQueryInterface(SourceAbi* source, abi_t<TargetProjection
|
||||
|
||||
template <typename TOperationAbi, typename TResultAbi>
|
||||
static HRESULT ffWaitForAsyncOperation(TOperationAbi* operation, TResultAbi** result) {
|
||||
IAsyncInfo* FF_AUTO_RELEASE_COM_OBJECT asyncInfo = NULL;
|
||||
IAsyncInfo* FF_AUTO_RELEASE_COM_OBJECT asyncInfo = nullptr;
|
||||
HRESULT hr = ffQueryInterface<IAsyncInfo>(operation, &asyncInfo);
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
@@ -82,7 +82,7 @@ static HRESULT ffWaitForAsyncOperation(TOperationAbi* operation, TResultAbi** re
|
||||
|
||||
template <typename TResultProjection, typename TOperation>
|
||||
static HRESULT ffRunAndWait(TOperation&& operation, abi_t<TResultProjection>** result) {
|
||||
abi_t<IAsyncOperation<TResultProjection>>* FF_AUTO_RELEASE_COM_OBJECT opResult = NULL;
|
||||
abi_t<IAsyncOperation<TResultProjection>>* FF_AUTO_RELEASE_COM_OBJECT opResult = nullptr;
|
||||
HRESULT hr = operation(reinterpret_cast<void**>(&opResult));
|
||||
if (FAILED(hr) || !opResult) {
|
||||
return hr;
|
||||
@@ -93,9 +93,9 @@ static HRESULT ffRunAndWait(TOperation&& operation, abi_t<TResultProjection>** r
|
||||
|
||||
template <typename TResultProjection, typename TOperation>
|
||||
static HRESULT ffRunAndWait2(TOperation&& operation, abi_t<TResultProjection>** result) {
|
||||
*result = NULL;
|
||||
*result = nullptr;
|
||||
|
||||
abi_t<IAsyncOperationWithProgress<TResultProjection, int32_t>>* FF_AUTO_RELEASE_COM_OBJECT opResult = NULL;
|
||||
abi_t<IAsyncOperationWithProgress<TResultProjection, int32_t>>* FF_AUTO_RELEASE_COM_OBJECT opResult = nullptr;
|
||||
HRESULT hr = operation(reinterpret_cast<void**>(&opResult));
|
||||
if (FAILED(hr) || !opResult) {
|
||||
return hr;
|
||||
@@ -107,7 +107,7 @@ static HRESULT ffRunAndWait2(TOperation&& operation, abi_t<TResultProjection>**
|
||||
static HRESULT ffSaveThumbnailToTempPath(
|
||||
abi_t<winrt::Windows::Storage::Streams::IRandomAccessStreamReference>* thumbnail,
|
||||
FFstrbuf* destination) {
|
||||
abi_t<winrt::Windows::Storage::Streams::IRandomAccessStreamWithContentType>* FF_AUTO_RELEASE_COM_OBJECT contentStream = NULL;
|
||||
abi_t<winrt::Windows::Storage::Streams::IRandomAccessStreamWithContentType>* FF_AUTO_RELEASE_COM_OBJECT contentStream = nullptr;
|
||||
HRESULT hr = ffRunAndWait<winrt::Windows::Storage::Streams::IRandomAccessStreamWithContentType>([=](void** result) {
|
||||
return thumbnail->OpenReadAsync(result);
|
||||
},
|
||||
@@ -116,7 +116,7 @@ static HRESULT ffSaveThumbnailToTempPath(
|
||||
return FAILED(hr) ? hr : E_FAIL;
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::Storage::Streams::IRandomAccessStream>* FF_AUTO_RELEASE_COM_OBJECT randomAccessStream = NULL;
|
||||
abi_t<winrt::Windows::Storage::Streams::IRandomAccessStream>* FF_AUTO_RELEASE_COM_OBJECT randomAccessStream = nullptr;
|
||||
hr = ffQueryInterface<winrt::Windows::Storage::Streams::IRandomAccessStream>(contentStream, &randomAccessStream);
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
@@ -132,25 +132,25 @@ static HRESULT ffSaveThumbnailToTempPath(
|
||||
return HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE);
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::Storage::Streams::IBufferFactory>* FF_AUTO_RELEASE_COM_OBJECT bufferFactory = NULL;
|
||||
abi_t<winrt::Windows::Storage::Streams::IBufferFactory>* FF_AUTO_RELEASE_COM_OBJECT bufferFactory = nullptr;
|
||||
hr = ffGetActivationFactory(L"Windows.Storage.Streams.Buffer", winrt::guid_of<winrt::Windows::Storage::Streams::IBufferFactory>(), &bufferFactory);
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::Storage::Streams::IBuffer>* FF_AUTO_RELEASE_COM_OBJECT buffer = NULL;
|
||||
abi_t<winrt::Windows::Storage::Streams::IBuffer>* FF_AUTO_RELEASE_COM_OBJECT buffer = nullptr;
|
||||
hr = bufferFactory->Create((UINT32) size, reinterpret_cast<void**>(&buffer));
|
||||
if (FAILED(hr) || !buffer) {
|
||||
return FAILED(hr) ? hr : E_FAIL;
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::Storage::Streams::IInputStream>* FF_AUTO_RELEASE_COM_OBJECT inputStream = NULL;
|
||||
abi_t<winrt::Windows::Storage::Streams::IInputStream>* FF_AUTO_RELEASE_COM_OBJECT inputStream = nullptr;
|
||||
hr = ffQueryInterface<winrt::Windows::Storage::Streams::IInputStream>(contentStream, &inputStream);
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::Storage::Streams::IBuffer>* FF_AUTO_RELEASE_COM_OBJECT readBuffer = NULL;
|
||||
abi_t<winrt::Windows::Storage::Streams::IBuffer>* FF_AUTO_RELEASE_COM_OBJECT readBuffer = nullptr;
|
||||
hr = ffRunAndWait2<winrt::Windows::Storage::Streams::IBuffer>([=](void** result) {
|
||||
return inputStream->ReadAsync(buffer, (uint32_t) size, (uint32_t) winrt::Windows::Storage::Streams::InputStreamOptions::None, result);
|
||||
},
|
||||
@@ -165,13 +165,13 @@ static HRESULT ffSaveThumbnailToTempPath(
|
||||
return FAILED(hr) ? hr : S_FALSE;
|
||||
}
|
||||
|
||||
Windows::Storage::Streams::IBufferByteAccess* FF_AUTO_RELEASE_COM_OBJECT byteAccess = NULL;
|
||||
Windows::Storage::Streams::IBufferByteAccess* FF_AUTO_RELEASE_COM_OBJECT byteAccess = nullptr;
|
||||
hr = readBuffer->QueryInterface(IID_PPV_ARGS(&byteAccess));
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
byte* bytes = NULL;
|
||||
byte* bytes = nullptr;
|
||||
hr = byteAccess->Buffer(&bytes);
|
||||
if (FAILED(hr) || !bytes) {
|
||||
return FAILED(hr) ? hr : E_FAIL;
|
||||
@@ -188,7 +188,7 @@ static HRESULT ffSaveThumbnailToTempPath(
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
HANDLE file = CreateFileW(tempFilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
HANDLE file = CreateFileW(tempFilePath, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (file == INVALID_HANDLE_VALUE) {
|
||||
DWORD writeError = GetLastError();
|
||||
DeleteFileW(tempFilePath);
|
||||
@@ -196,9 +196,9 @@ static HRESULT ffSaveThumbnailToTempPath(
|
||||
}
|
||||
|
||||
DWORD written = 0;
|
||||
BOOL writtenOk = WriteFile(file, bytes, length, &written, NULL);
|
||||
BOOL writtenOk = WriteFile(file, bytes, length, &written, nullptr);
|
||||
NtClose(file);
|
||||
file = NULL;
|
||||
file = nullptr;
|
||||
|
||||
if (!writtenOk || written != length) {
|
||||
DWORD writeError = GetLastError();
|
||||
@@ -217,14 +217,14 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
|
||||
}
|
||||
|
||||
do {
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionManagerStatics>* FF_AUTO_RELEASE_COM_OBJECT managerStatics = NULL;
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionManagerStatics>* FF_AUTO_RELEASE_COM_OBJECT managerStatics = nullptr;
|
||||
HRESULT hr = ffGetActivationFactory(L"Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager", winrt::guid_of<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionManagerStatics>(), &managerStatics);
|
||||
if (FAILED(hr) || !managerStatics) {
|
||||
error = "winrt: RoGetActivationFactory(GlobalSystemMediaTransportControlsSessionManager) failed";
|
||||
break;
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionManager>* FF_AUTO_RELEASE_COM_OBJECT manager = NULL;
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionManager>* FF_AUTO_RELEASE_COM_OBJECT manager = nullptr;
|
||||
hr = ffRunAndWait<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionManager>([=](void** result) {
|
||||
return managerStatics->RequestAsync(result);
|
||||
},
|
||||
@@ -234,11 +234,11 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
|
||||
break;
|
||||
}
|
||||
|
||||
FF_A_CLEANUP(deleteHstring) HSTRING playerId = NULL;
|
||||
FF_A_CLEANUP(deleteHstring) HSTRING playerId = nullptr;
|
||||
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSession>* FF_AUTO_RELEASE_COM_OBJECT session = NULL;
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSession>* FF_AUTO_RELEASE_COM_OBJECT session = nullptr;
|
||||
if (instance.config.general.playerName.length) {
|
||||
abi_t<winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Media::Control::GlobalSystemMediaTransportControlsSession>>* FF_AUTO_RELEASE_COM_OBJECT sessions = NULL;
|
||||
abi_t<winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Media::Control::GlobalSystemMediaTransportControlsSession>>* FF_AUTO_RELEASE_COM_OBJECT sessions = nullptr;
|
||||
hr = manager->GetSessions(reinterpret_cast<void**>(&sessions));
|
||||
if (FAILED(hr) || !sessions) {
|
||||
error = "winrt: GetSessions() failed";
|
||||
@@ -251,7 +251,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
|
||||
break;
|
||||
}
|
||||
for (uint32_t i = 0; i < sessionCount; i++) {
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSession>* FF_AUTO_RELEASE_COM_OBJECT currentSession = NULL;
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSession>* FF_AUTO_RELEASE_COM_OBJECT currentSession = nullptr;
|
||||
hr = sessions->GetAt(i, reinterpret_cast<void**>(¤tSession));
|
||||
if (FAILED(hr) || !currentSession) {
|
||||
continue;
|
||||
@@ -266,7 +266,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
|
||||
|
||||
if (ffStrbufContainIgnCase(&result->playerId, &instance.config.general.playerName)) {
|
||||
session = currentSession;
|
||||
currentSession = NULL; // Don't release the session object
|
||||
currentSession = nullptr; // Don't release the session object
|
||||
break;
|
||||
}
|
||||
deleteHstring(&playerId);
|
||||
@@ -294,7 +294,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
|
||||
ffStrbufSetHstring(&result->playerId, playerId);
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionMediaProperties>* FF_AUTO_RELEASE_COM_OBJECT mediaProps = NULL;
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionMediaProperties>* FF_AUTO_RELEASE_COM_OBJECT mediaProps = nullptr;
|
||||
hr = ffRunAndWait<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionMediaProperties>([=](void** result) {
|
||||
return session->TryGetMediaPropertiesAsync(result);
|
||||
},
|
||||
@@ -304,7 +304,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
|
||||
break;
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionPlaybackInfo>* FF_AUTO_RELEASE_COM_OBJECT playbackInfo = NULL;
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionPlaybackInfo>* FF_AUTO_RELEASE_COM_OBJECT playbackInfo = nullptr;
|
||||
hr = session->GetPlaybackInfo(reinterpret_cast<void**>(&playbackInfo));
|
||||
bool isPlaying = false;
|
||||
double playbackRate = 1.0;
|
||||
@@ -327,7 +327,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
|
||||
}
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::Foundation::IReference<double>>* FF_AUTO_RELEASE_COM_OBJECT playbackRateRef = NULL;
|
||||
abi_t<winrt::Windows::Foundation::IReference<double>>* FF_AUTO_RELEASE_COM_OBJECT playbackRateRef = nullptr;
|
||||
if (SUCCEEDED(playbackInfo->get_PlaybackRate(reinterpret_cast<void**>(&playbackRateRef))) && playbackRateRef) {
|
||||
if (SUCCEEDED(playbackRateRef->get_Value(&playbackRate)) && playbackRate < 0.0) {
|
||||
playbackRate = 0.0;
|
||||
@@ -335,22 +335,22 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
|
||||
}
|
||||
}
|
||||
|
||||
FF_A_CLEANUP(deleteHstring) HSTRING title = NULL;
|
||||
FF_A_CLEANUP(deleteHstring) HSTRING title = nullptr;
|
||||
if (SUCCEEDED(mediaProps->get_Title(reinterpret_cast<void**>(&title)))) {
|
||||
ffStrbufSetHstring(&result->song, title);
|
||||
}
|
||||
|
||||
FF_A_CLEANUP(deleteHstring) HSTRING artist = NULL;
|
||||
FF_A_CLEANUP(deleteHstring) HSTRING artist = nullptr;
|
||||
if (SUCCEEDED(mediaProps->get_Artist(reinterpret_cast<void**>(&artist)))) {
|
||||
ffStrbufSetHstring(&result->artist, artist);
|
||||
}
|
||||
|
||||
FF_A_CLEANUP(deleteHstring) HSTRING album = NULL;
|
||||
FF_A_CLEANUP(deleteHstring) HSTRING album = nullptr;
|
||||
if (SUCCEEDED(mediaProps->get_AlbumTitle(reinterpret_cast<void**>(&album)))) {
|
||||
ffStrbufSetHstring(&result->album, album);
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionTimelineProperties>* FF_AUTO_RELEASE_COM_OBJECT timelineProps = NULL;
|
||||
abi_t<winrt::Windows::Media::Control::IGlobalSystemMediaTransportControlsSessionTimelineProperties>* FF_AUTO_RELEASE_COM_OBJECT timelineProps = nullptr;
|
||||
hr = session->GetTimelineProperties(reinterpret_cast<void**>(&timelineProps));
|
||||
if (SUCCEEDED(hr) && timelineProps) {
|
||||
int64_t duration = 0;
|
||||
@@ -373,14 +373,14 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
|
||||
}
|
||||
}
|
||||
|
||||
abi_t<winrt::Windows::ApplicationModel::IAppInfoStatics>* FF_AUTO_RELEASE_COM_OBJECT appInfoStatics = NULL;
|
||||
abi_t<winrt::Windows::ApplicationModel::IAppInfoStatics>* FF_AUTO_RELEASE_COM_OBJECT appInfoStatics = nullptr;
|
||||
hr = ffGetActivationFactory(L"Windows.ApplicationModel.AppInfo", winrt::guid_of<winrt::Windows::ApplicationModel::IAppInfoStatics>(), &appInfoStatics);
|
||||
if (SUCCEEDED(hr) && appInfoStatics) {
|
||||
abi_t<winrt::Windows::ApplicationModel::IAppInfo>* FF_AUTO_RELEASE_COM_OBJECT appInfo = NULL;
|
||||
abi_t<winrt::Windows::ApplicationModel::IAppInfo>* FF_AUTO_RELEASE_COM_OBJECT appInfo = nullptr;
|
||||
if (SUCCEEDED(appInfoStatics->GetFromAppUserModelId(reinterpret_cast<void*>(playerId), reinterpret_cast<void**>(&appInfo))) && appInfo) {
|
||||
abi_t<winrt::Windows::ApplicationModel::IAppDisplayInfo>* FF_AUTO_RELEASE_COM_OBJECT displayInfo = NULL;
|
||||
abi_t<winrt::Windows::ApplicationModel::IAppDisplayInfo>* FF_AUTO_RELEASE_COM_OBJECT displayInfo = nullptr;
|
||||
if (SUCCEEDED(appInfo->get_DisplayInfo(reinterpret_cast<void**>(&displayInfo))) && displayInfo) {
|
||||
FF_A_CLEANUP(deleteHstring) HSTRING displayName = NULL;
|
||||
FF_A_CLEANUP(deleteHstring) HSTRING displayName = nullptr;
|
||||
if (SUCCEEDED(displayInfo->get_DisplayName(reinterpret_cast<void**>(&displayName)))) {
|
||||
ffStrbufSetHstring(&result->player, displayName);
|
||||
}
|
||||
@@ -396,7 +396,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
|
||||
}
|
||||
|
||||
if (saveCover) {
|
||||
abi_t<winrt::Windows::Storage::Streams::IRandomAccessStreamReference>* FF_AUTO_RELEASE_COM_OBJECT thumbnail = NULL;
|
||||
abi_t<winrt::Windows::Storage::Streams::IRandomAccessStreamReference>* FF_AUTO_RELEASE_COM_OBJECT thumbnail = nullptr;
|
||||
hr = mediaProps->get_Thumbnail(reinterpret_cast<void**>(&thumbnail));
|
||||
if (SUCCEEDED(hr) && thumbnail) {
|
||||
if (SUCCEEDED(ffSaveThumbnailToTempPath(thumbnail, &result->cover)) && result->cover.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user