view src/sid/xs_sidplay.h @ 611:3f7a52adfe0e trunk

[svn] merge recent changes from yaz's branch. - stable shoutcast playback. - tag handling improvement. - view track detail on streaming won't crash. (disabled.) - filepopup for streaming is partially supported. filepopup displays track name and stream name, but not updated automatically.
author yaz
date Tue, 06 Feb 2007 12:11:42 -0800
parents c488d191b528
children 6c3c7b841382
line wrap: on
line source

/*
 * Here comes the really ugly code...
 * Get all SID-tune information (for all sub-tunes)
 * including name, length, etc.
 */
t_xs_tuneinfo *TFUNCTION(gchar * pcFilename)
{
	t_xs_sldb_node *tuneLength = NULL;
	t_xs_tuneinfo *pResult;
	TTUNEINFO tuneInfo;
	TTUNE *testTune;
	gboolean haveInfo = TRUE;
	gint i;
	gchar *buffer = NULL;
	glong buffer_size = 0;

	if ( TBUFFGETFUNC( pcFilename , &buffer , &buffer_size ) != 0 )
		return NULL;

	/* Check if the tune exists and is readable */
	if ((testTune = new TTUNE((TBUFFTYPEMEM)buffer,(TBUFFTYPESIZE)buffer_size)) == NULL)
		return NULL;

	if (!testTune->getStatus()) {
		g_free( buffer );
		delete testTune;
		return NULL;
	}

	/* Get general tune information */
#ifdef _XS_SIDPLAY1_H
	haveInfo = testTune->getInfo(tuneInfo);
#endif
#ifdef _XS_SIDPLAY2_H
	testTune->getInfo(tuneInfo);
	haveInfo = TRUE;
#endif

	/* Get length information (NOTE: Do not free this!) */
	tuneLength = xs_songlen_get(pcFilename);

	/* Allocate tuneinfo structure */
	pResult = xs_tuneinfo_new(pcFilename,
				  tuneInfo.songs, tuneInfo.startSong,
				  tuneInfo.infoString[0], tuneInfo.infoString[1], tuneInfo.infoString[2],
				  tuneInfo.loadAddr, tuneInfo.initAddr, tuneInfo.playAddr, tuneInfo.dataFileLen);

	if (!pResult) {
		g_free( buffer );
		delete testTune;
		return NULL;
	}

	/* Get information for subtunes */
	for (i = 0; i < pResult->nsubTunes; i++) {
		/* Make the title */
		if (haveInfo) {
			pResult->subTunes[i].tuneTitle =
			    xs_make_titlestring(pcFilename, i + 1, pResult->nsubTunes, tuneInfo.sidModel,
						tuneInfo.formatString, tuneInfo.infoString[0],
						tuneInfo.infoString[1], tuneInfo.infoString[2]);
		} else
			pResult->subTunes[i].tuneTitle = g_strdup(pcFilename);

		/* Get song length */
		if (tuneLength && (i < tuneLength->nLengths))
			pResult->subTunes[i].tuneLength = tuneLength->sLengths[i];
		else
			pResult->subTunes[i].tuneLength = -1;
	}

	g_free( buffer );
	delete testTune;

	return pResult;
}

/* Undefine these */
#undef TFUNCTION
#undef TTUNEINFO
#undef TTUNE
#undef TBUFFGETFUNC
#undef TBUFFTYPEMEM
#undef TBUFFTYPESIZE