aboutsummaryrefslogtreecommitdiff
path: root/Src/mp3-mpg123/main.cpp
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/mp3-mpg123/main.cpp
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/mp3-mpg123/main.cpp')
-rw-r--r--Src/mp3-mpg123/main.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/Src/mp3-mpg123/main.cpp b/Src/mp3-mpg123/main.cpp
new file mode 100644
index 00000000..cdf95308
--- /dev/null
+++ b/Src/mp3-mpg123/main.cpp
@@ -0,0 +1,89 @@
+#include "api__mp3-mpg123.h"
+
+#include "../nu/Singleton.h"
+#include "../nu/factoryt.h"
+#include "avi_mp3_decoder.h"
+#include "flv_mp3_decoder.h"
+#include "mkv_mp3_decoder.h"
+#include "mp3_in_mp4.h"
+#include "adts_mpg123.h"
+#include "MP4Factory.h"
+#include "NSVFactory.h"
+#include <bfc/platform/export.h>
+#include "../Agave/Component/ifc_wa5component.h"
+#include "../nu/ServiceBuilder.h"
+#include <mpg123.h>
+
+api_service *WASABI_API_SVC = 0;
+api_config *AGAVE_API_CONFIG = 0;
+api_memmgr *WASABI_API_MEMMGR = 0;
+
+class MP3DecoderComponent : public ifc_wa5component
+{
+public:
+ void RegisterServices(api_service *service);
+ int RegisterServicesSafeModeOk();
+ void DeregisterServices(api_service *service);
+
+protected:
+ RECVS_DISPATCH;
+};
+
+static SingletonServiceFactory<svc_avidecoder, AVIDecoder> avi_factory;
+static AVIDecoder avi_decoder;
+static SingletonServiceFactory<svc_mkvdecoder, MKVDecoder> mkv_factory;
+static MKVDecoder mkv_decoder;
+static SingletonServiceFactory<svc_flvdecoder, FLVDecoderCreator> flv_factory;
+static FLVDecoderCreator flv_decoder;
+static MPEG4Factory mp4_factory;
+static ServiceFactoryT<adts, ADTS_MPG123> adts_factory;
+
+static NSVFactory nsv_decoder;
+static SingletonServiceFactory<svc_nsvFactory, NSVFactory> nsv_factory;
+
+void MP3DecoderComponent::RegisterServices(api_service *service)
+{
+ WASABI_API_SVC = service;
+ if (mpg123_init() == MPG123_OK) {
+ WASABI_API_SVC->service_register(&mp4_factory);
+ avi_factory.Register(WASABI_API_SVC, &avi_decoder);
+ mkv_factory.Register(WASABI_API_SVC, &mkv_decoder);
+ flv_factory.Register(WASABI_API_SVC, &flv_decoder);
+ nsv_factory.Register(WASABI_API_SVC, &nsv_decoder);
+ adts_factory.Register(WASABI_API_SVC);
+ }
+ ServiceBuild(WASABI_API_SVC, AGAVE_API_CONFIG, AgaveConfigGUID);
+ ServiceBuild(WASABI_API_SVC, WASABI_API_MEMMGR, memMgrApiServiceGuid);
+}
+
+void MP3DecoderComponent::DeregisterServices(api_service *service)
+{
+ avi_factory.Deregister(WASABI_API_SVC);
+ mkv_factory.Deregister(WASABI_API_SVC);
+ WASABI_API_SVC->service_deregister(&mp4_factory);
+ flv_factory.Deregister(WASABI_API_SVC);
+ nsv_factory.Deregister(WASABI_API_SVC);
+ adts_factory.Deregister(WASABI_API_SVC);
+ ServiceRelease(WASABI_API_SVC, AGAVE_API_CONFIG, AgaveConfigGUID);
+ ServiceRelease(WASABI_API_SVC, WASABI_API_MEMMGR, memMgrApiServiceGuid);
+ mpg123_exit();
+}
+
+int MP3DecoderComponent::RegisterServicesSafeModeOk()
+{
+ return 1;
+}
+
+MP3DecoderComponent mp3_decoder_component;
+extern "C" DLLEXPORT ifc_wa5component *GetWinamp5SystemComponent()
+{
+ return &mp3_decoder_component;
+}
+
+#define CBCLASS MP3DecoderComponent
+START_DISPATCH;
+VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
+CB(15, RegisterServicesSafeModeOk)
+VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
+END_DISPATCH;
+#undef CBCLASS \ No newline at end of file