changeset 695:ca594ca1056f

COM API support works now.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 22 May 2008 11:32:37 +0300
parents fd81a16434ed
children 52d1cd646f08
files src/xs_sidplay2.cc
diffstat 1 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/xs_sidplay2.cc	Thu May 22 10:54:25 2008 +0300
+++ b/src/xs_sidplay2.cc	Thu May 22 11:32:37 2008 +0300
@@ -35,7 +35,8 @@
 #endif
 
 
-typedef struct {
+class xs_sidplay2_t {
+public:
 #ifdef HAVE_SIDPLAY2_COMI
     SidIPtr<ISidplay2> currEng;
     SidLazyIPtr<ISidUnknown> currBuilder;
@@ -47,7 +48,10 @@
     SidTune *currTune;
     guint8 *buf;
     size_t bufSize;
-} xs_sidplay2_t;
+    
+    xs_sidplay2_t(void);
+    virtual ~xs_sidplay2_t(void) { ; }
+};
 
 
 #ifdef HAVE_RESID_BUILDER
@@ -58,6 +62,20 @@
 #endif
 
 
+xs_sidplay2_t::xs_sidplay2_t(void)
+#ifdef HAVE_SIDPLAY2_COMI
+:currEng(sidplay2::create())
+#else
+:currEng(NULL)
+#endif
+{
+    buf = NULL;
+    bufSize = 0;
+    currTune = NULL;
+    currBuilder = NULL;    
+}
+
+
 /* We need to 'export' all this pseudo-C++ crap */
 extern "C" {
 
@@ -101,14 +119,12 @@
     assert(myStatus);
 
     /* Allocate internal structures */
-    myEngine = (xs_sidplay2_t *) g_malloc0(sizeof(xs_sidplay2_t));
+    myEngine = new xs_sidplay2_t();
     myStatus->sidEngine = myEngine;
     if (!myEngine) return FALSE;
 
     /* Initialize the engine */
-#ifdef HAVE_SIDPLAY2_COMI
-//    myEngine->currEng();
-#else
+#ifndef HAVE_SIDPLAY2_COMI
     myEngine->currEng = new sidplay2;
 #endif
     if (!myEngine->currEng) {
@@ -423,7 +439,7 @@
 
     xs_sidplay2_delete(myStatus);
 
-    g_free(myEngine);
+    delete myEngine;
     myStatus->sidEngine = NULL;
 }