diff src/xmms-sid.c @ 127:ddb513bd2610

Improved audio format support, now supported formats are "queried" from emulator engines. Preparing for NanoSID-support, since it's the worst in this sense.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 14 Jan 2004 21:45:05 +0000
parents 5bddcad25ef7
children 4162a5370b9e
line wrap: on
line diff
--- a/src/xmms-sid.c	Wed Jan 14 03:57:04 2004 +0000
+++ b/src/xmms-sid.c	Wed Jan 14 21:45:05 2004 +0000
@@ -129,7 +129,11 @@
 
  /* Initialize status */
  memset(&xs_status, 0, sizeof(xs_status));
-
+ xs_status.audioFrequency	= xs_cfg.audioFrequency;
+ xs_status.audioBitsPerSample	= xs_cfg.audioBitsPerSample;
+ xs_status.audioChannels	= xs_cfg.audioChannels;
+ xs_status.audioFormat		= -1;
+ 
  /* Try to initialize emulator engine */
  XSDEBUG("initializing emulator engine #%i...\n", xs_cfg.playerEngine);
 
@@ -252,7 +256,7 @@
  t_xs_tune *myTune;
  gboolean audioOpen = FALSE, doPlay = FALSE;
  guint audioGot;
- gint audioFreq, audioChannels, songLength, audioFmt;
+ gint songLength;
  gchar audioBuffer[XS_BUFSIZE];
 
  /* Initialize */
@@ -262,14 +266,6 @@
  myTune = xs_status.pTune;
  pthread_mutex_unlock(&xs_mutex);
 
- /* Copy and check audio options here (they might change in config while running) */
-#ifdef HAVE_UNSIGNEDPCM
- audioFmt = (xs_cfg.fmtBitsPerSample == XS_RES_16BIT) ? FMT_U16_NE : FMT_U8;
-#else
- audioFmt = (xs_cfg.fmtBitsPerSample == XS_RES_16BIT) ? FMT_S16_NE : FMT_S8;
-#endif
- audioFreq = xs_cfg.fmtFrequency;
- audioChannels = (xs_cfg.fmtChannels == XS_CHN_MONO) ? 1 : 2;
 
  /*
   * Main player loop: while not stopped, loop here - play subtunes
@@ -299,14 +295,15 @@
  	myTune->subTunes[myStatus.currSong - 1].tuneTitle,
  	(songLength > 0) ? (songLength * 1000) : -1,
  	(myTune->subTunes[myStatus.currSong - 1].tuneSpeed > 0) ? (myTune->subTunes[myStatus.currSong - 1].tuneSpeed * 1000) : -1,
-	audioFreq,
-	audioChannels);
+	myStatus.audioFrequency,
+	myStatus.audioChannels);
 
 
  /* Open the audio output */
- if (!xs_plugin_ip.output->open_audio(audioFmt, audioFreq, audioChannels))
+ if (!xs_plugin_ip.output->open_audio(myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels))
 	{
-	XSERR("Couldn't open XMMS audio output!\n");
+	XSERR("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n",
+	myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels);
 	pthread_mutex_lock(&xs_mutex);
 	xs_status.isError = TRUE;
 	pthread_mutex_unlock(&xs_mutex);
@@ -326,7 +323,8 @@
 	/* I <3 visualice/haujobb */
 	xs_plugin_ip.add_vis_pcm(
 		xs_plugin_ip.output->written_time(),
-		audioFmt, audioChannels, audioGot, audioBuffer);
+		myStatus.audioFormat, myStatus.audioChannels,
+		audioGot, audioBuffer);
 
 	/* Wait a little */
 	while (xs_status.isPlaying &&
@@ -671,7 +669,7 @@
 
 void xs_fileinfo(gchar *pcFilename)
 {
- GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu, *tmpText;
+ GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu;
  t_xs_stil_subnode *tmpNode;
  gchar tmpStr[32], *tmpS;
  gint n;