Ejemplo n.º 1
0
/*
================
S_Init
================
*/
qboolean S_Base_Init( soundInterface_t *si ) {
	qboolean	r;

	if( !si ) {
		return qfalse;
	}

	s_mixahead = Cvar_Get ("s_mixahead", "0.2", CVAR_ARCHIVE);
	s_mixPreStep = Cvar_Get ("s_mixPreStep", "0.05", CVAR_ARCHIVE);
	s_show = Cvar_Get ("s_show", "0", CVAR_CHEAT);
	s_testsound = Cvar_Get ("s_testsound", "0", CVAR_CHEAT);

	r = SNDDMA_Init();

	if ( r ) {
		s_soundStarted = 1;
		s_soundMuted = 1;
//		s_numSfx = 0;

		Com_Memset(sfxHash, 0, sizeof(sfx_t *)*LOOP_HASH);

		s_soundtime = 0;
		s_paintedtime = 0;

		S_Base_StopAllSounds( );
	} else {
		return qfalse;
	}

	si->Shutdown = S_Base_Shutdown;
	si->StartSound = S_Base_StartSound;
	si->StartLocalSound = S_Base_StartLocalSound;
	si->StartBackgroundTrack = S_Base_StartBackgroundTrack;
	si->StopBackgroundTrack = S_Base_StopBackgroundTrack;
	si->RawSamples = S_Base_RawSamples;
	si->StopAllSounds = S_Base_StopAllSounds;
	si->ClearLoopingSounds = S_Base_ClearLoopingSounds;
	si->AddLoopingSound = S_Base_AddLoopingSound;
	si->AddRealLoopingSound = S_Base_AddRealLoopingSound;
	si->StopLoopingSound = S_Base_StopLoopingSound;
	si->Respatialize = S_Base_Respatialize;
	si->UpdateEntityPosition = S_Base_UpdateEntityPosition;
	si->Update = S_Base_Update;
	si->DisableSounds = S_Base_DisableSounds;
	si->BeginRegistration = S_Base_BeginRegistration;
	si->RegisterSound = S_Base_RegisterSound;
	si->ClearSoundBuffer = S_Base_ClearSoundBuffer;
	si->SoundInfo = S_Base_SoundInfo;
	si->SoundList = S_Base_SoundList;

#ifdef USE_VOIP
	si->StartCapture = S_Base_StartCapture;
	si->AvailableCaptureSamples = S_Base_AvailableCaptureSamples;
	si->Capture = S_Base_Capture;
	si->StopCapture = S_Base_StopCapture;
	si->MasterGain = S_Base_MasterGain;
#endif

	return qtrue;
}
Ejemplo n.º 2
0
void S_GetSoundtime(void)
{
	int        samplepos;
	static int buffers;
	static int oldsamplepos;
	int        fullsamples = dma.samples / dma.channels;

	if (CL_VideoRecording())
	{
		float fps           = MIN(cl_avidemo->integer, 1000.0f);
		float frameDuration = MAX(dma.speed / fps, 1.0f);// +clc.aviSoundFrameRemainder;

		int msec = (int)frameDuration;
		s_soundtime               += msec;
		//clc.aviSoundFrameRemainder = frameDuration - msec;

		return;
	}

	// it is possible to miscount buffers if it has wrapped twice between
	// calls to S_Update.  Oh well.
	samplepos = SNDDMA_GetDMAPos();
	if (samplepos < oldsamplepos)
	{
		buffers++;                  // buffer wrapped

		if (s_paintedtime > 0x40000000)     // time to chop things off to avoid 32 bit limits
		{
			buffers       = 0;
			s_paintedtime = fullsamples;
			S_Base_StopAllSounds();
		}
	}
	oldsamplepos = samplepos;

	s_soundtime = buffers * fullsamples + samplepos / dma.channels;

#if 0
// check to make sure that we haven't overshot
	if (s_paintedtime < s_soundtime)
	{
		Com_DPrintf("S_Update_ : overflow\n");
		s_paintedtime = s_soundtime;
	}
#endif

	if (dma.submission_chunk < 256)
	{
		s_paintedtime = s_soundtime + s_mixPreStep->value * dma.speed;
	}
	else
	{
		s_paintedtime = s_soundtime + dma.submission_chunk;
	}
}
Ejemplo n.º 3
0
Archivo: dma.c Proyecto: icanhas/yantar
qbool
S_Base_Init(Sndinterface *si)
{
    qbool r;

    if(!si)
        return qfalse;
    s_mixahead = cvarget("s_mixahead", "0.2", CVAR_ARCHIVE);
    s_mixPreStep = cvarget("s_mixPreStep", "0.05", CVAR_ARCHIVE);
    s_show = cvarget("s_show", "0", CVAR_CHEAT);
    s_testsound = cvarget("s_testsound", "0", CVAR_CHEAT);
    r = SNDDMA_Init();

    if(r) {
        s_soundStarted	= 1;
        s_soundMuted	= 1;
        /*		s_numSfx = 0; */
        Q_Memset(sfxHash, 0, sizeof(Sfx *)*LOOP_HASH);
        s_soundtime = 0;
        s_paintedtime = 0;
        S_Base_StopAllSounds( );
    } else
        return qfalse;

    si->shutdown = S_Base_Shutdown;
    si->startsnd = S_Base_StartSound;
    si->startlocalsnd = S_Base_StartLocalSound;
    si->startbackgroundtrack = S_Base_StartBackgroundTrack;
    si->stopbackgroundtrack = S_Base_StopBackgroundTrack;
    si->rawsamps = S_Base_RawSamples;
    si->stopall = S_Base_StopAllSounds;
    si->clearloops = S_Base_ClearLoopingSounds;
    si->addloop = S_Base_AddLoopingSound;
    si->addrealloop = S_Base_AddRealLoopingSound;
    si->stoploops = S_Base_StopLoopingSound;
    si->respatialize = S_Base_Respatialize;
    si->updateentpos = S_Base_UpdateEntityPosition;
    si->update = S_Base_Update;
    si->disablesnds = S_Base_DisableSounds;
    si->beginreg = S_Base_BeginRegistration;
    si->registersnd = S_Base_RegisterSound;
    si->clearsndbuf = S_Base_ClearSoundBuffer;
    si->sndinfo	= S_Base_SoundInfo;
    si->sndlist	= S_Base_SoundList;
#ifdef USE_VOIP
    si->startcapture = S_Base_StartCapture;
    si->availcapturesamps = S_Base_AvailableCaptureSamples;
    si->capture = S_Base_Capture;
    si->stopcapture = S_Base_StopCapture;
    si->mastergain	= S_Base_MasterGain;
#endif
    return qtrue;
}
Ejemplo n.º 4
0
void S_GetSoundtime(void)
{
	int		samplepos;
	static	int		buffers;
	static	int		oldsamplepos;
	int		fullsamples;
	
	fullsamples = dma.samples / dma.channels;

	if( CL_VideoRecording( ) )
	{
		s_soundtime += (int)ceil( dma.speed / cl_aviFrameRate->value );
		return;
	}

	// it is possible to miscount buffers if it has wrapped twice between
	// calls to S_Update.  Oh well.
	samplepos = SNDDMA_GetDMAPos();
	if (samplepos < oldsamplepos)
	{
		buffers++;					// buffer wrapped
		
		if (s_paintedtime > 0x40000000)
		{	// time to chop things off to avoid 32 bit limits
			buffers = 0;
			s_paintedtime = fullsamples;
			S_Base_StopAllSounds ();
		}
	}
	oldsamplepos = samplepos;

	s_soundtime = buffers*fullsamples + samplepos/dma.channels;

#if 0
// check to make sure that we haven't overshot
	if (s_paintedtime < s_soundtime)
	{
		Com_DPrintf ("S_Update_ : overflow\n");
		s_paintedtime = s_soundtime;
	}
#endif

	if ( dma.submission_chunk < 256 ) {
		s_paintedtime = s_soundtime + s_mixPreStep->value * dma.speed;
	} else {
		s_paintedtime = s_soundtime + dma.submission_chunk;
	}
}
Ejemplo n.º 5
0
void S_Base_Reload(void)
{
	sfx_t *sfx;
	int   i;

	if (!s_soundStarted)
	{
		return;
	}

	Com_Printf("reloading sounds...\n");

	S_Base_StopAllSounds();

	for (sfx = knownSfx, i = 0; i < numSfx; i++, sfx++)
	{
		sfx->inMemory = qfalse;
		S_memoryLoad(sfx);
	}
}
Ejemplo n.º 6
0
/*
===================
S_DisableSounds

Disables sounds until the next S_BeginRegistration.
This is called when the hunk is cleared and the sounds
are no longer valid.
===================
*/
void S_Base_DisableSounds( void ) {
	S_Base_StopAllSounds();
	s_soundMuted = qtrue;
}
Ejemplo n.º 7
0
/*
================
S_Init
================
*/
qboolean S_Base_Init( soundInterface_t *si ) {
	qboolean	r;

	if( !si ) {
		return qfalse;
	}

#ifndef NO_DMAHD
	s_khz = Cvar_Get ("s_khz", "44", CVAR_ARCHIVE);
#else
	s_khz = Cvar_Get ("s_khz", "22", CVAR_ARCHIVE);
#endif
	s_mixahead = Cvar_Get ("s_mixahead", "0.2", CVAR_ARCHIVE);
	s_mixPreStep = Cvar_Get ("s_mixPreStep", "0.05", CVAR_ARCHIVE);
	s_show = Cvar_Get ("s_show", "0", CVAR_CHEAT);
	s_testsound = Cvar_Get ("s_testsound", "0", CVAR_CHEAT);
	s_dev = Cvar_Get ("s_dev", "", CVAR_ARCHIVE);

	Cmd_AddCommand( "s_devlist", S_dmaHD_devlist );
	
	r = SNDDMA_Init();

	if ( r ) {
		s_soundStarted = 1;
		s_soundMuted = 1;
//		s_numSfx = 0;

		Com_Memset(sfxHash, 0, sizeof(sfx_t *)*LOOP_HASH);

		s_soundtime = 0;
		s_paintedtime = 0;

		S_Base_StopAllSounds( );
	} else {
		return qfalse;
	}

	si->Shutdown = S_Base_Shutdown;
	si->StartSound = S_Base_StartSound;
	si->StartLocalSound = S_Base_StartLocalSound;
	si->StartBackgroundTrack = S_Base_StartBackgroundTrack;
	si->StopBackgroundTrack = S_Base_StopBackgroundTrack;
	si->RawSamples = S_Base_RawSamples;
	si->StopAllSounds = S_Base_StopAllSounds;
	si->ClearLoopingSounds = S_Base_ClearLoopingSounds;
	si->AddLoopingSound = S_Base_AddLoopingSound;
	si->AddRealLoopingSound = S_Base_AddRealLoopingSound;
	si->StopLoopingSound = S_Base_StopLoopingSound;
	si->Respatialize = S_Base_Respatialize;
	si->UpdateEntityPosition = S_Base_UpdateEntityPosition;
	si->Update = S_Base_Update;
	si->DisableSounds = S_Base_DisableSounds;
	si->BeginRegistration = S_Base_BeginRegistration;
	si->RegisterSound = S_Base_RegisterSound;
	si->ClearSoundBuffer = S_Base_ClearSoundBuffer;
	si->SoundInfo = S_Base_SoundInfo;
	si->SoundList = S_Base_SoundList;

#ifndef NO_DMAHD
	if (dmaHD_Enabled()) return dmaHD_Init(si);
#endif

	return qtrue;
}
Ejemplo n.º 8
0
qboolean S_Base_Init(soundInterface_t *si)
{
	qboolean r;

	if (!si)
	{
		Com_Printf("Invalid sound interface NULL.\n");
		return qfalse;
	}

	s_mixahead     = Cvar_Get("s_mixahead", "0.2", CVAR_ARCHIVE);
	s_mixPreStep   = Cvar_Get("s_mixPreStep", "0.05", CVAR_ARCHIVE);
	s_show         = Cvar_Get("s_show", "0", CVAR_CHEAT);
	s_testsound    = Cvar_Get("s_testsound", "0", CVAR_CHEAT);
	s_debugStreams = Cvar_Get("s_debugStreams", "0", CVAR_TEMP);

	r = SNDDMA_Init();

	if (r)
	{
		s_soundStarted = 1;
		s_soundMuted   = 1;

		Com_Memset(streamingSounds, 0, sizeof(streamingSound_t) * MAX_STREAMING_SOUNDS);
		Com_Memset(sfxHash, 0, sizeof(sfx_t *) * LOOP_HASH);

		s_soundtime   = 0;
		s_paintedtime = 0;

		S_Base_StopAllSounds();
	}
	else
	{
		return qfalse;
	}

	si->Shutdown              = S_Base_Shutdown;
	si->Reload                = S_Base_Reload;
	si->StartSound            = S_Base_StartSound;
	si->StartSoundEx          = S_Base_StartSoundEx;
	si->StartLocalSound       = S_Base_StartLocalSound;
	si->StartBackgroundTrack  = S_Base_StartBackgroundTrack;
	si->StopBackgroundTrack   = S_Base_StopBackgroundTrack;
	si->StartStreamingSound   = S_Base_StartStreamingSound;
	si->StopEntStreamingSound = S_Base_StopEntStreamingSound;
	si->FadeStreamingSound    = S_Base_FadeStreamingSound;
	si->RawSamples            = S_Base_RawSamples;
	si->ClearSounds           = S_Base_ClearSounds;
	si->StopAllSounds         = S_Base_StopAllSounds;
	si->FadeAllSounds         = S_Base_FadeAllSounds;
	si->ClearLoopingSounds    = S_Base_ClearLoopingSounds;
	si->AddLoopingSound       = S_Base_AddLoopingSound;
	si->AddRealLoopingSound   = S_Base_AddRealLoopingSound;
	si->Respatialize          = S_Base_Respatialize;
	si->UpdateEntityPosition  = S_Base_UpdateEntityPosition;
	si->Update                = S_Base_Update;
	si->DisableSounds         = S_Base_DisableSounds;
	si->BeginRegistration     = S_Base_BeginRegistration;
	si->RegisterSound         = S_Base_RegisterSound;
	si->ClearSoundBuffer      = S_Base_ClearSoundBuffer;
	si->SoundInfo             = S_Base_SoundInfo;
	si->SoundList             = S_Base_SoundList;
	si->GetVoiceAmplitude     = S_Base_GetVoiceAmplitude;
	si->GetSoundLength        = S_Base_GetSoundLength;
	si->GetCurrentSoundTime   = S_Base_GetCurrentSoundTime;

#ifdef USE_VOIP
	si->StartCapture            = S_Base_StartCapture;
	si->AvailableCaptureSamples = S_Base_AvailableCaptureSamples;
	si->Capture                 = S_Base_Capture;
	si->StopCapture             = S_Base_StopCapture;
	si->MasterGain              = S_Base_MasterGain;
#endif

	return qtrue;
}
Ejemplo n.º 9
0
static void S_GetSoundtime(void)
{
	int		samplepos;
	static	int		buffers;
	static	int		oldsamplepos;
	int		fullsamples;
	int blurFrames;
	double msec;

	fullsamples = dma.samples / dma.channels;

	//if (CL_VideoRecording(&afdMain)  &&  !(cl_freezeDemoPauseVideoRecording->integer  &&  cl_freezeDemo->integer))
	if (CL_VideoRecording(&afdMain))
	{
		//FIXME why no msec check like video?
		blurFrames = Cvar_VariableIntegerValue("mme_blurFrames");
		if (blurFrames == 0  ||  blurFrames == 1) {
			//msec = (int)ceil( (1000.0f / cl_aviFrameRate->value) * com_timescale->value );
			//s_soundtime += (int)ceil( dma.speed / cl_aviFrameRate->value );
			//msec = (int)ceil( dma.speed / cl_aviFrameRate->value );
			//msec = ceil( (float)dma.speed / (float)cl_aviFrameRate->value );
			msec = ( (double)dma.speed / (double)cl_aviFrameRate->value );
		} else {
			//msec = (int)ceil((1000.0f / (cl_aviFrameRate->value * (float)blurFrames)) * com_timescale->value);
			//s_soundtime += (int)ceil( dma.speed / (cl_aviFrameRate->value * (float)blurFrames));
			//msec = (int)ceil( dma.speed / (cl_aviFrameRate->value * (float)blurFrames));
			//msec = ceil( (float)dma.speed / ((float)cl_aviFrameRate->value * (float)blurFrames));
			msec = ( (double)dma.speed / ((double)cl_aviFrameRate->value * (double)blurFrames));
		}
		//overf += ceil(msec) - msec;
		overf += msec - floor(msec);
		//s_soundtime += (int)ceil(msec);
		s_soundtime += (int)floor(msec);
		if (overf > 1.0) {
			//s_soundtime -= (int)floor(overf);
			s_soundtime += (int)floor(overf);
			overf -= floor(overf);
		}
		//Com_Printf("sound msec: %lf %d  overf: %f\n", msec, (int)ceil(msec), overf);
		return;
	} else {
		if (!CL_VideoRecording(&afdMain)) {
			overf = 0.0;
		}
	}

	// it is possible to miscount buffers if it has wrapped twice between
	// calls to S_Update.  Oh well.
	samplepos = SNDDMA_GetDMAPos();
	if (samplepos < oldsamplepos)
	{
		buffers++;					// buffer wrapped
		//Com_Printf("swap %d\n", buffers);

		if (s_paintedtime > 0x40000000)
		{	// time to chop things off to avoid 32 bit limits
			buffers = 0;
			s_paintedtime = fullsamples;
			S_Base_StopAllSounds ();
			//Com_Printf("s_paintedtime (%x) > 0x40000000\n", s_paintedtime);
		}
	}
	oldsamplepos = samplepos;

	s_soundtime = buffers*fullsamples + samplepos/dma.channels;

#if 0
// check to make sure that we haven't overshot
	if (s_paintedtime < s_soundtime)
	{
		Com_DPrintf ("S_Update_ : overflow\n");
		s_paintedtime = s_soundtime;
	}
#endif

	if ( dma.submission_chunk < 256 ) {
		//Com_Printf("dma.submission_chunk < 256\n");
		s_paintedtime = s_soundtime + s_mixPreStep->value * dma.speed;
	} else {
		s_paintedtime = s_soundtime + dma.submission_chunk;
	}
}