示例#1
0
文件: ogg.c 项目: tomgreen66/yquake2
/*
 * Stream music.
 */
void
OGG_Stream(void)
{
	if (!ogg_started)
	{
		return;
	}

	if (ogg_status == PLAY)
	{
#ifdef USE_OPENAL
		if (sound_started == SS_OAL)
		{
			/* Calculate the number of buffers used
			   for storing decoded OGG/Vorbis data.
			   We take the number of active buffers
			   at startup (at this point most of the
			   samples should be precached and loaded
			   into buffers) and add 64. Empircal
			   testing showed, that at most times
			   at least 52 buffers remain available
			   for OGG/Vorbis, enough for about 3
			   seconds playback. The music won't
			   stutter as long as the framerate
			   stayes over 1 FPS. */
			if (ogg_numbufs == 0)
			{
				ogg_numbufs = active_buffers + 64;
			}

			/* active_buffers are all active OpenAL buffers,
			   buffering normal sfx _and_ ogg/vorbis samples. */
			while (active_buffers <= ogg_numbufs)
			{
				OGG_Read();
			}
		}
		else /* using SDL */
#endif
		{
			if (sound_started == SS_SDL)
			{
				/* Read that number samples into the buffer, that
				   were played since the last call to this function.
				   This keeps the buffer at all times at an "optimal"
				   fill level. */
				while (paintedtime + MAX_RAW_SAMPLES - 2048 > s_rawend)
				{
					OGG_Read();
				}
			}
		} /* using SDL */
	} /* ogg_status == PLAY */
}
示例#2
0
文件: snd_ogg.c 项目: ZwS/qudos
/*
==========
OGG_Stream

Stream music.
==========
*/
void OGG_Stream(void)
{

	if (!ogg_started)
		return;

	while (ogg_status == PLAY && paintedtime + MAX_RAW_SAMPLES - 2048 > s_rawend)
		OGG_Read();
}