diff src/xs_sidplay1.cc @ 75:653c9b0d1320

SIDPlay2 support "works" now. Borked problems with threads.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 15 Sep 2003 11:10:03 +0000
parents 8cb66a3f75f7
children ab522ab65c85
line wrap: on
line diff
--- a/src/xs_sidplay1.cc	Sun Sep 14 18:51:05 2003 +0000
+++ b/src/xs_sidplay1.cc	Mon Sep 15 11:10:03 2003 +0000
@@ -49,9 +49,12 @@
  */
 extern "C" {
 
+
+/*
+ * Check if we can play the given file
+ */
 gboolean xs_sidplay1_isourfile(gchar *pcFileName)
 {
- /* Try to detect via libSIDPlay's detection routine, if required */
  sidTune *testTune = new sidTune(pcFileName);
 
  if (!testTune) return FALSE;
@@ -66,35 +69,13 @@
 }
 
 
-void xs_sidplay1_close(t_xs_status *myStatus)
-{
- t_xs_sidplay1 *myPlayer;
-
- /* Check pointer */
- if (!myStatus) return;
-
- /* Free internals */
- xs_sidplay1_deletesid(myStatus);
-
- myPlayer = (t_xs_sidplay1 *) myStatus->player;
-
- if (myPlayer->currEng) delete myPlayer->currEng;
-
- free(myPlayer);
- myStatus->player = NULL;
-
- /* Miscellaneous */
- free(myStatus->currFileName);
- myStatus->currFileName = NULL;
-}
-
-
+/*
+ * Initialize SIDPlay1
+ */
 gboolean xs_sidplay1_init(t_xs_status *myStatus)
 {
  t_xs_sidplay1 *myPlayer;
-
- /* Check pointer */
- if (!myStatus) return FALSE;
+ assert(myStatus);
 
  /* Allocate internal structures */
  myPlayer = (t_xs_sidplay1 *) g_malloc0(sizeof(t_xs_sidplay1));
@@ -122,13 +103,43 @@
 }
 
 
+/*
+ * Close SIDPlay1
+ */
+void xs_sidplay1_close(t_xs_status *myStatus)
+{
+ t_xs_sidplay1 *myPlayer;
+ assert(myStatus);
+
+ /* Free internals */
+ xs_sidplay1_deletesid(myStatus);
+
+ myPlayer = (t_xs_sidplay1 *) myStatus->player;
+
+ if (myPlayer->currEng) delete myPlayer->currEng;
+
+ free(myPlayer);
+ myStatus->player = NULL;
+}
+
+
 gboolean xs_sidplay1_initsong(t_xs_status *myStatus)
 {
  t_xs_sidplay1 *myPlayer = (t_xs_sidplay1 *) myStatus->player;
 
  if (!myPlayer) return FALSE;
 
- if ((!myPlayer->currTune) || (!myPlayer->currTune->getStatus())) return FALSE;
+ if (!myPlayer->currTune)
+	{
+	XSERR("Tune was NULL\n");
+	return FALSE;
+	}
+
+ if (!myPlayer->currTune->getStatus())
+	{
+	XSERR("Tune status check failed\n");
+	return FALSE;
+	}
 
  return sidEmuInitializeSong(
 	*myPlayer->currEng,
@@ -158,6 +169,7 @@
  t_xs_sidplay1 *myPlayer = (t_xs_sidplay1 *) myStatus->player;
  sidTune *newTune;
  sidTuneInfo tuneInfo;
+ assert(myStatus);
 
  /* Try to get the tune */
  if (!pcFileName) return FALSE;
@@ -239,17 +251,17 @@
  myPlayer->currConfig.filterFt		= xs_cfg.filterFt;
 
  /* Now set the emulator configuration */
- myPlayer->currEng->setConfig(myPlayer->currConfig);
+ if (!myPlayer->currEng->setConfig(myPlayer->currConfig))
+	{
+	XSERR("Emulator engine configuration failed!\n");
+	return FALSE;
+	}
 
  /* Initialize status information */
  newTune->getInfo(tuneInfo);
-
- myStatus->isPlaying	= TRUE;
- myStatus->isError	= FALSE;
+ myPlayer->currTune	= newTune;
  myStatus->currSong	= tuneInfo.startSong;
  myStatus->nSongs	= tuneInfo.songs;
- myPlayer->currTune	= newTune;
- myStatus->currFileName = g_strdup(pcFileName);
 
  return TRUE;
 }
@@ -261,14 +273,7 @@
 void xs_sidplay1_deletesid(t_xs_status *myStatus)
 {
  t_xs_sidplay1 *myPlayer;
-
- if (!myStatus) return;
-
- if (myStatus->currFileName)
-	{
-	g_free(myStatus->currFileName);
-	myStatus->currFileName = NULL;
-	}
+ assert(myStatus);
 
  myPlayer = (t_xs_sidplay1 *) myStatus->player;
  if (!myPlayer) return;
@@ -286,10 +291,11 @@
  return 0;
 }
 
+
 /*
  * Return song information
  */
-#include "xs_sidplay_info.h"
+#include "xs_sidplay.h"	// Include common function
 
 void xs_sidplay1_getsidinfo(gchar *songFileName, gchar **songTitle, gint *songLength)
 {