diff src/xs_sidplay1.cc @ 71:2b32c75729ce

Started modularizing, separated sidplay1 things into a "wrapper" module. Removed non-generic stuff from xmms-sid.cc, removed C++ references and renamed to xmms-sid.c
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 10 Sep 2003 06:21:04 +0000
parents
children e3b205a6bc7e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/xs_sidplay1.cc	Wed Sep 10 06:21:04 2003 +0000
@@ -0,0 +1,173 @@
+/*
+   XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
+
+   libSIDPlay v1 support
+
+   Written by Matti "ccr" Hamalainen <ccr@tnsp.org>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#ifdef HAVE_SIDPLAY1
+#include "xmms-sid.h"
+
+extern "C" {
+#include <xmms/title.h>
+}
+
+#include <sidplay/player.h>
+#include <sidplay/myendian.h>
+#include <sidplay/fformat.h>
+
+
+struct xs_sidplay1 {
+	struct emuConfig	emuConf;
+	emuEngine		emuEngine;
+	gboolean	isError, isPlaying, allowNext;
+	gint		currSong, nSongs;
+	sidTune		*currTune;
+	gchar		*currFileName;
+};
+
+
+
+gboolean xs_sidplay1_initsong(struct xs_sidplay1 *myStatus)
+{
+ return sidEmuInitializeSong(myStatus->emuEngine, myStatus->currTune, myStatus->currSong);
+}
+
+
+void xs_sidplay1_fillbuffer(struct xs_sidplay1 *myStatus, gchar *audioBuffer, gint audioBufSize)
+{
+ sidEmuFillBuffer(myStatus->emuEngine, myStatus->currTune, audioBuffer, audioBufSize);
+}
+
+
+gint xs_sidplay1_inittune(gchar *pcFileName)
+{
+ sidTune *newTune;
+ sidTuneInfo tuneInfo;
+
+ /* Can we set the next tune? */ 
+ XSDEBUG("request to play '%s'\n", pcFileName);
+
+ /* Try to get the tune */
+ newTune = new sidTune(pcFileName);
+ if (newTune == NULL) return;
+
+ /* Get current configuration */
+ xs_emuEngine.getConfig(xs_emuConf);
+
+ /* Configure channels and stuff */
+ switch (xs_cfg.fmtChannels) {
+
+	case XS_CHN_AUTOPAN:
+		xs_emuConf.channels = SIDEMU_STEREO;
+		xs_emuConf.autoPanning = SIDEMU_CENTEREDAUTOPANNING;
+		xs_emuConf.volumeControl = SIDEMU_FULLPANNING;
+		break;
+
+	case XS_CHN_STEREO:
+		xs_emuConf.channels = SIDEMU_STEREO;
+		xs_emuConf.autoPanning = SIDEMU_NONE;
+		xs_emuConf.volumeControl = SIDEMU_NONE;
+		break;
+
+	case XS_CHN_MONO:
+	default:
+		xs_emuConf.channels = SIDEMU_MONO;
+		xs_emuConf.autoPanning = SIDEMU_NONE;
+		xs_emuConf.volumeControl = SIDEMU_NONE;
+		break;
+ }
+
+
+ /* Memory mode settings */
+ switch (xs_cfg.memoryMode) {
+	case XS_MPU_BANK_SWITCHING:
+		xs_emuConf.memoryMode = MPU_BANK_SWITCHING;
+		break;
+
+	case XS_MPU_TRANSPARENT_ROM:
+		xs_emuConf.memoryMode = MPU_TRANSPARENT_ROM;
+		break;
+
+	case XS_MPU_PLAYSID_ENVIRONMENT:
+		xs_emuConf.memoryMode = MPU_PLAYSID_ENVIRONMENT;
+		break;
+
+	default:
+		xs_emuConf.memoryMode = MPU_BANK_SWITCHING;
+		break;
+ }
+
+
+ /* Clockspeed settings */
+ switch (xs_cfg.clockSpeed) {
+	case XS_CLOCK_NTSC:
+		xs_emuConf.clockSpeed = SIDTUNE_CLOCK_NTSC;
+		break;
+
+	case XS_CLOCK_PAL:
+	default:
+		xs_emuConf.clockSpeed = SIDTUNE_CLOCK_PAL;
+		break;
+ }
+
+
+ /* Configure rest of the emulation */
+ xs_emuConf.bitsPerSample	= xs_cfg.fmtBitsPerSample;
+ xs_emuConf.frequency		= xs_cfg.fmtFrequency;
+#ifdef HAVE_UNSIGNEDPCM
+ xs_emuConf.sampleFormat	= SIDEMU_UNSIGNED_PCM;
+#else
+ xs_emuConf.sampleFormat	= SIDEMU_SIGNED_PCM;
+#endif
+ xs_emuConf.mos8580		= xs_cfg.mos8580;
+ xs_emuConf.emulateFilter	= xs_cfg.emulateFilters;
+ xs_emuConf.filterFs		= xs_cfg.filterFs;
+ xs_emuConf.filterFm		= xs_cfg.filterFm;
+ xs_emuConf.filterFt		= xs_cfg.filterFt;
+
+ /* Now set the emulator configuration */
+ xs_emuEngine.setConfig(xs_emuConf);
+
+
+ /* Initialize status information */
+ XSDEBUG("starting playing thread!\n");
+
+ newTune->getInfo(tuneInfo);
+
+ xs_status->isPlaying	= TRUE;
+ xs_status->isError	= FALSE;
+ xs_status->currSong	= tuneInfo.startSong;
+ xs_status->nSongs	= tuneInfo.songs;
+ xs_status->currTune	= newTune;
+ xs_status->currFileName = g_strdup(pcFileName);
+
+ /* Start the playing thread! */
+ if (pthread_create(&xs_decode_thread, NULL, xs_play_loop, NULL) < 0)
+	{
+	XSERR("Couldn't start playing thread! Possible reason reported by system: %s\n", strerror(errno));
+	delete newTune;
+	}
+
+ XSDEBUG("systems should be up?\n");
+
+ /* Exit */
+}
+
+
+#endif	/* HAVE_SIDPLAY1 */
+