Media: fix code smells

This commit is contained in:
李通洲
2025-03-27 16:44:14 +08:00
parent 4b6f2a9efa
commit 1d7b212d8d
3 changed files with 14 additions and 12 deletions
+3 -1
View File
@@ -11,7 +11,7 @@ extern void MRMediaRemoteGetNowPlayingInfo(dispatch_queue_t dispatcher, void(^ca
extern void MRMediaRemoteGetNowPlayingClient(dispatch_queue_t dispatcher, void (^callback)(_Nullable id clientObj)) __attribute__((weak_import));
extern CFStringRef MRNowPlayingClientGetBundleIdentifier(id clientObj) __attribute__((weak_import));
extern CFStringRef MRNowPlayingClientGetParentAppBundleIdentifier(id clientObj) __attribute__((weak_import));
void MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_queue_t queue, void (^callback)(BOOL playing));
void MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_queue_t queue, void (^callback)(BOOL playing)) __attribute__((weak_import));
static const char* getMedia(FFMediaResult* result)
{
@@ -20,6 +20,7 @@ static const char* getMedia(FFMediaResult* result)
FF_TEST_FN_EXISTANCE(MRMediaRemoteGetNowPlayingClient);
FF_TEST_FN_EXISTANCE(MRNowPlayingClientGetBundleIdentifier);
FF_TEST_FN_EXISTANCE(MRNowPlayingClientGetParentAppBundleIdentifier);
FF_TEST_FN_EXISTANCE(MRMediaRemoteGetNowPlayingApplicationIsPlaying);
#undef FF_TEST_FN_EXISTANCE
dispatch_group_t group = dispatch_group_create();
@@ -63,6 +64,7 @@ static const char* getMedia(FFMediaResult* result)
});
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
// Don't dispatch_release because we are using ARC
if(result->playerId.length > 0)
{
+2 -2
View File
@@ -129,9 +129,9 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul
}
else
{
char str[] = { fileName[1], fileName[2], 0 };
if (str[0] == 0 || str[1] == 0)
if (fileName[1] == 0 || fileName[2] == 0)
break;
char str[] = { fileName[1], fileName[2], 0 };
ffStrbufAppendC(&result->song, (char) strtoul(str, NULL, 16));
fileName += 2;
}
+9 -9
View File
@@ -32,15 +32,15 @@ const char* ffWinrtDetectMedia(FFWinrtMediaResult* result)
{
switch (playbackInfo.PlaybackStatus())
{
#define FF_MEDIA_SET_STATUS(status_code) \
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::status_code: result->status = #status_code; break
FF_MEDIA_SET_STATUS(Closed);
FF_MEDIA_SET_STATUS(Opened);
FF_MEDIA_SET_STATUS(Changing);
FF_MEDIA_SET_STATUS(Stopped);
FF_MEDIA_SET_STATUS(Playing);
FF_MEDIA_SET_STATUS(Paused);
#undef FF_MEDIA_SET_STATUS
#define FF_MEDIA_SET_STATUS(status_code) \
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::status_code: result->status = #status_code; break;
FF_MEDIA_SET_STATUS(Closed)
FF_MEDIA_SET_STATUS(Opened)
FF_MEDIA_SET_STATUS(Changing)
FF_MEDIA_SET_STATUS(Stopped)
FF_MEDIA_SET_STATUS(Playing)
FF_MEDIA_SET_STATUS(Paused)
#undef FF_MEDIA_SET_STATUS
}
}