Esempio n. 1
0
File: snd_ogg.c Progetto: ZwS/qudos
/*
==========
OGG_Shutdown

Shutdown the Ogg Vorbis subsystem.
==========
*/
void OGG_Shutdown(void)
{

	if (!ogg_started)
		return;

	Com_Printf("Shutting down Ogg Vorbis.\n");

	OGG_Stop();

	/* Free the list of files. */
	FS_FreeList(ogg_filelist, ogg_numfiles + 1);

	/* Remove console commands. */
	Cmd_RemoveCommand("ogg_list");
	Cmd_RemoveCommand("ogg_pause");
	Cmd_RemoveCommand("ogg_play");
	Cmd_RemoveCommand("ogg_reinit");
	Cmd_RemoveCommand("ogg_resume");
	Cmd_RemoveCommand("ogg_seek");
	Cmd_RemoveCommand("ogg_status");
	Cmd_RemoveCommand("ogg_stop");

	ogg_started = false;
}
Esempio n. 2
0
void CL_PlayBackgroundTrack (void)
{
	char	name[MAX_QPATH];
	int32_t		track;

	if (!cl.refresh_prepped)
		return;

	// using a named audio track intead of numbered
	if (strlen(cl.configstrings[CS_CDTRACK]) > 2)
	{
	
			OGG_ParseCmd(cl.configstrings[CS_CDTRACK]);
//			S_StartBackgroundTrack(name, name);
			return;

	}

	track = atoi(cl.configstrings[CS_CDTRACK]);

	if (track == 0)
	{	// Stop any playing track
		OGG_Stop();
		return;
	}

	// If an OGG file exists play it, otherwise fall back to CD audio
	Com_sprintf (name, sizeof(name), "track%02i", CL_MissionPackCDTrack(track));
	OGG_ParseCmd(name);
}
Esempio n. 3
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Manage suspend:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int OGG_suspend(){
    OGG_suspendPosition = ov_raw_tell(&OGG_VorbisFile);
    OGG_suspendIsPlaying = OGG_isPlaying;
    OGG_Stop();
    OGG_FreeTune();
    return 0;
}
Esempio n. 4
0
void
CL_Shutdown(void)
{
	static qboolean isdown = false;

	if (isdown)
	{
		printf("recursive shutdown\n");
		return;
	}

	isdown = true;

#ifdef USE_CURL
	CL_HTTP_Cleanup(true);
#endif

	CL_WriteConfiguration();

	Key_WriteConsoleHistory();

	OGG_Stop();

	S_Shutdown();
	IN_Shutdown();
	VID_Shutdown();
}
Esempio n. 5
0
void
CL_Shutdown(void)
{
	static qboolean isdown = false;

	if (isdown)
	{
		printf("recursive shutdown\n");
		return;
	}

	isdown = true;

	CL_WriteConfiguration();

	Key_WriteConsoleHistory();

#ifdef CDA
	CDAudio_Shutdown();
#endif
#ifdef OGG
	OGG_Stop();
#endif
	S_Shutdown();
	IN_Shutdown();
	VID_Shutdown();
}
Esempio n. 6
0
File: snd_ogg.c Progetto: ZwS/qudos
/*
==========
OGG_Open

Play Ogg Vorbis file (with absolute or relative index).
==========
*/
qboolean OGG_Open(ogg_seek_t type, int offset)
{
	int		 size;		/* File size. */
	int		 pos;		/* Absolute position. */
	int		 res;		/* Error indicator. */

	pos = -1;

	switch (type) {
	case ABS:
		/* Absolute index. */
		if (offset < 0 || offset >= ogg_numfiles) {
			Com_Printf("OGG_Open: %d out of range.\n", offset+1);
			return (false);
		} else
			pos = offset;
		break;
	case REL:
		/* Simulate a loopback. */
		if (ogg_curfile == -1 && offset < 0)
			offset++;
		while (ogg_curfile + offset < 0)
			offset += ogg_numfiles;
		while (ogg_curfile + offset >= ogg_numfiles)
			offset -= ogg_numfiles;
		pos = ogg_curfile + offset;
		break;
	}

	/* Check running music. */
	if (ogg_status == PLAY) {
		if (ogg_curfile == pos)
			return (true);
		else
			OGG_Stop();
	}

	/* Find file. */
	if ((size = FS_LoadFile(ogg_filelist[pos], (void **)&ogg_buffer)) == -1) {
		Com_Printf("OGG_Open: could not open %d (%s): %s.\n", pos, ogg_filelist[pos], strerror(errno));
		return (false);
	}

	/* Open ogg vorbis file. */
	if ((res = ov_open(NULL, &ovFile, (char *)ogg_buffer, size)) < 0) {
		Com_Printf("OGG_Open: '%s' is not a valid Ogg Vorbis file (error %i).\n", ogg_filelist[pos], res);
		FS_FreeFile(ogg_buffer);
		return (false);
	}

	/* Play file. */
	ovSection = 0;
	ogg_curfile = pos;
	ogg_status = PLAY;

	Com_Printf("Playing file %d '%s'\n", pos, ogg_filelist[pos]);

	return (true);
}
Esempio n. 7
0
File: snd_ogg.c Progetto: ZwS/qudos
/*
==========
OGG_Read

Play a portion of the currently opened file.
==========
*/
int OGG_Read(void)
{
	int res;	/* Number of bytes read. */

	/* Read and resample. */
	res = ov_read(&ovFile, ovBuf, sizeof(ovBuf), 0, 2, 1, &ovSection);
	S_RawSamplesVol(res>>2, 44100, 2, 2, (byte*)ovBuf, ogg_volume->value);

	/* Check for end of file. */
	if (res == 0) {
		OGG_Stop();
		OGG_Sequence();
	}

	return (res);
}
Esempio n. 8
0
void
SCR_BeginLoadingPlaque(void)
{
	S_StopAllSounds();
	cl.sound_prepped = false; /* don't play ambients */
#ifdef CDA
	CDAudio_Stop();
#endif
#ifdef OGG
	OGG_Stop();
#endif

	if (cls.disable_screen)
	{
		return;
	}

	if (developer->value)
	{
		return;
	}

	if (cls.state == ca_disconnected)
	{
		/* if at console, don't bring up the plaque */
		return;
	}

	if (cls.key_dest == key_console)
	{
		return;
	}

	if (cl.cinematictime > 0)
	{
		scr_draw_loading = 2; /* clear to balack first */
	}
	else
	{
		scr_draw_loading = 1;
	}

	SCR_UpdateScreen();
	SCR_StopCinematic();
	cls.disable_screen = Sys_Milliseconds();
	cls.disable_servercount = cl.servercount;
}
Esempio n. 9
0
/*
 * Play a portion of the currently opened file.
 */
int
OGG_Read ( void )
{
	int res;    /* Number of bytes read. */

	/* Read and resample. */
	res = ov_read( &ovFile, ovBuf, sizeof ( ovBuf ), ogg_bigendian, OGG_SAMPLEWIDTH, 1, &ovSection );
	S_RawSamples( res / (OGG_SAMPLEWIDTH * ogg_info->channels),
		      ogg_info->rate, OGG_SAMPLEWIDTH, ogg_info->channels, (byte *) ovBuf, ogg_volume->value );

	/* Check for end of file. */
	if ( res == 0 )
	{
		OGG_Stop();
		OGG_Sequence();
	}

	return ( res );
}
Esempio n. 10
0
/*
 * Play Ogg Vorbis file (with absolute or relative index).
 */
qboolean
OGG_Open(ogg_seek_t type, int offset)
{
	int size;     /* File size. */
	int pos = -1; /* Absolute position. */
	int res;      /* Error indicator. */

	switch (type)
	{
		case ABS:

			/* Absolute index. */
			if ((offset < 0) || (offset >= ogg_numfiles))
			{
				Com_Printf("OGG_Open: %d out of range.\n", offset + 1);
				return false;
			}
			else
			{
				pos = offset;
			}

			break;
		case REL:

			/* Simulate a loopback. */
			if ((ogg_curfile == -1) && (offset < 0))
			{
				offset++;
			}

			while (ogg_curfile + offset < 0)
			{
				offset += ogg_numfiles;
			}

			while (ogg_curfile + offset >= ogg_numfiles)
			{
				offset -= ogg_numfiles;
			}

			pos = ogg_curfile + offset;
			break;
	}

	/* Check running music. */
	if (ogg_status == PLAY)
	{
		if (ogg_curfile == pos)
		{
			return true;
		}

		else
		{
			OGG_Stop();
		}
	}

	/* Find file. */
	if ((size = FS_LoadFile(ogg_filelist[pos], (void **)&ogg_buffer)) == -1)
	{
		Com_Printf("OGG_Open: could not open %d (%s): %s.\n",
				pos, ogg_filelist[pos], strerror(errno));
		return false;
	}

	/* Open ogg vorbis file. */
	if ((res = ov_open(NULL, &ovFile, (char *)ogg_buffer, size)) < 0)
	{
		Com_Printf("OGG_Open: '%s' is not a valid Ogg Vorbis file (error %i).\n",
				ogg_filelist[pos], res); FS_FreeFile(ogg_buffer);
		ogg_buffer = NULL;
		return false;
	}

	ogg_info = ov_info(&ovFile, 0);

	if (!ogg_info)
	{
		Com_Printf("OGG_Open: Unable to get stream information for %s.\n",
				ogg_filelist[pos]);
		ov_clear(&ovFile);
		FS_FreeFile(ogg_buffer);
		ogg_buffer = NULL;
		return false;
	}

	/* Play file. */
	ovSection = 0;
	ogg_curfile = pos;
	ogg_status = PLAY;

	return true;
}
Esempio n. 11
0
void OGG_End(){
    OGG_Stop();
	pspAudioSetChannelCallback(OGG_audio_channel, 0,0);
	OGG_FreeTune();
	endAudioLib();
}
Esempio n. 12
0
void
SCR_PlayCinematic(char *arg)
{
	int width, height;
	byte *palette;
	char name[MAX_OSPATH], *dot;

	/* make sure background music is not playing */
#ifdef CDA
	CDAudio_Stop();
#endif
#ifdef OGG
	OGG_Stop();
#endif

	cl.cinematicframe = 0;
	dot = strstr(arg, ".");

	/* static pcx image */
	if (dot && !strcmp(dot, ".pcx"))
	{
		Com_sprintf(name, sizeof(name), "pics/%s", arg);
		SCR_LoadPCX(name, &cin.pic, &palette, &cin.width, &cin.height);
		cl.cinematicframe = -1;
		cl.cinematictime = 1;
		SCR_EndLoadingPlaque();
		cls.state = ca_active;

		if (!cin.pic)
		{
			Com_Printf("%s not found.\n", name);
			cl.cinematictime = 0;
		}
		else
		{
			memcpy(cl.cinematicpalette, palette, sizeof(cl.cinematicpalette));
			Z_Free(palette);
		}

		return;
	}

	Com_sprintf(name, sizeof(name), "video/%s", arg);
	FS_FOpenFile(name, &cl.cinematic_file, false);

	if (!cl.cinematic_file)
	{
		SCR_FinishCinematic();
		cl.cinematictime = 0; /* done */
		return;
	}

	SCR_EndLoadingPlaque();

	cls.state = ca_active;

	FS_Read(&width, 4, cl.cinematic_file);
	FS_Read(&height, 4, cl.cinematic_file);
	cin.width = LittleLong(width);
	cin.height = LittleLong(height);

	FS_Read(&cin.s_rate, 4, cl.cinematic_file);
	cin.s_rate = LittleLong(cin.s_rate);
	FS_Read(&cin.s_width, 4, cl.cinematic_file);
	cin.s_width = LittleLong(cin.s_width);
	FS_Read(&cin.s_channels, 4, cl.cinematic_file);
	cin.s_channels = LittleLong(cin.s_channels);

	Huff1TableInit();

	cl.cinematicframe = 0;
	cin.pic = SCR_ReadNextFrame();
	cl.cinematictime = Sys_Milliseconds();
}