aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_plg/pass2.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Library/ml_plg/pass2.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Plugins/Library/ml_plg/pass2.cpp')
-rw-r--r--Src/Plugins/Library/ml_plg/pass2.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/Src/Plugins/Library/ml_plg/pass2.cpp b/Src/Plugins/Library/ml_plg/pass2.cpp
new file mode 100644
index 00000000..6a4f10b2
--- /dev/null
+++ b/Src/Plugins/Library/ml_plg/pass2.cpp
@@ -0,0 +1,72 @@
+#include "IDScanner.h"
+#include "playlist.h"
+#include <atlbase.h>
+#include "main.h"
+#include "api__ml_plg.h"
+
+static ICddbFileInfoList *CreateScanList(volatile int *killswitch)
+{
+ // benski> this function REALLY SUCKS but there's not much we can do about it unfortunately.
+ // because Gracenote's Playlist SDK doesn't give us a good way to run queries like this
+ ICddbPL2FindDataPtr pFindData;
+ ICddbDisc2Ptr pDisc;
+
+ if (FAILED(pFindData.CreateInstance(CLSID_CddbPL2FindData)))
+ return 0;
+
+ if (FAILED(playlistMgr->FindOpen(pFindData)))
+ return 0;
+
+ ICddbFileInfoListPtr infoList;
+ infoList.CreateInstance(CLSID_CddbFileInfoList);
+
+ while (SUCCEEDED(playlistMgr->FindNext(pFindData, &pDisc)))
+ {
+ if (*killswitch)
+ return 0;
+ CComBSTR path,filespec;
+ wchar_t file[MAX_PATH] = {0};
+ CComBSTR phase;
+
+ pDisc->GetProperty(PROP_Default, PLM_Filename, &filespec);
+ pDisc->GetProperty(PROP_Default, PLM_Pathname, &path);
+ PathCombineW(file, path, filespec);
+ playlistMgr->FileGetFieldVal(file, gnpl_crit_field_xdev1, &phase);
+ if (!phase || !phase[0] || phase[0]!='2')
+ continue;
+
+ ICddbFileInfoPtr info;
+ info.CreateInstance(CLSID_CddbFileInfo);
+ info->put_Filename(file);
+ infoList->AddFileInfo(info);
+ }
+
+ playlistMgr->FindClose(pFindData);
+ infoList->AddRef();
+ return infoList;
+}
+
+
+/*
+Pass 2 Algorithm
+Find all files with gnpl_crit_field_xdev1 == "2" and run them through MusicID
+*/
+void IDScanner::Pass2()
+{
+ if (SetupMusicID())
+ {
+ ICddbFileInfoList *infoList = CreateScanList(&killswitch);
+ if (infoList)
+ {
+ musicID->LibraryID(infoList, MUSICID_RETURN_EXACT_ONLY | MUSICID_GET_FP_FROM_APP | MUSICID_GET_TAG_FROM_APP | MUSICID_PREFER_WF_MATCHES);
+ infoList->Release();
+ }
+ }
+}
+
+int IDScanner::Pass2OnThread(HANDLE handle, void *user_data, intptr_t id)
+{
+ IDScanner *scanner = (IDScanner *)id;
+ scanner->Pass2();
+ return 0;
+}