}
+int S_GetSoundRate(void)
+{
+ return snd_renderbuffer ? snd_renderbuffer->format.speed : 0;
+}
+
+
static qboolean S_ChooseCheaperFormat (snd_format_t* format, qboolean fixed_speed, qboolean fixed_width, qboolean fixed_channels)
{
static const snd_format_t thresholds [] =
CHECK_BOUNDARIES(width);
CHECK_BOUNDARIES(channels);
#undef CHECK_BOUNDARIES
-
+
// Find the level of each parameter
#define FIND_LEVEL(param) \
param##_level = 0; \
if (snd_channellayout.integer < SND_CHANNELLAYOUT_AUTO ||
snd_channellayout.integer > SND_CHANNELLAYOUT_ALSA)
Cvar_SetValueQuick (&snd_channellayout, SND_CHANNELLAYOUT_STANDARD);
-
+
if (snd_channellayout.integer == SND_CHANNELLAYOUT_AUTO)
{
// If we're in the sound engine initialization
chosen_fmt.speed, chosen_fmt.channels, chosen_fmt.width * 8);
// Update the cvars
- snd_speed.integer = chosen_fmt.speed;
- snd_width.integer = chosen_fmt.width;
- snd_channels.integer = chosen_fmt.channels;
+ if (snd_speed.integer != (int)chosen_fmt.speed)
+ Cvar_SetValueQuick(&snd_speed, chosen_fmt.speed);
+ if (snd_width.integer != chosen_fmt.width)
+ Cvar_SetValueQuick(&snd_width, chosen_fmt.width);
+ if (snd_channels.integer != chosen_fmt.channels)
+ Cvar_SetValueQuick(&snd_channels, chosen_fmt.channels);
current_channellayout_used = SND_CHANNELLAYOUT_AUTO;
S_SetChannelLayout();
if (snd_renderbuffer == NULL || nosound.integer)
return;
-
- if (snd_blocked > 0 && !cls.capturevideo_soundfile)
+
+ if (snd_blocked > 0 && !cls.capturevideo.soundfile)
return;
// Update sound time
- if (cls.capturevideo_soundfile) // SUPER NASTY HACK to record non-realtime sound
- newsoundtime = (unsigned int)((double)cls.capturevideo_frame * (double)snd_renderbuffer->format.speed / (double)cls.capturevideo_framerate);
+ if (cls.capturevideo.soundfile) // SUPER NASTY HACK to record non-realtime sound
+ newsoundtime = (unsigned int)((double)cls.capturevideo.frame * (double)snd_renderbuffer->format.speed / (double)cls.capturevideo.framerate);
else if (simsound)
newsoundtime = (unsigned int)((realtime - snd_starttime) * (double)snd_renderbuffer->format.speed);
else
newsoundtime += extrasoundtime;
if (newsoundtime < soundtime)
{
- if ((cls.capturevideo_soundfile != NULL) != recording_sound)
+ if ((cls.capturevideo.soundfile != NULL) != recording_sound)
{
unsigned int additionaltime;
// some modules write directly to a shared (DMA) buffer
additionaltime = (soundtime - newsoundtime) + snd_renderbuffer->maxframes - 1;
additionaltime -= additionaltime % snd_renderbuffer->maxframes;
-
+
extrasoundtime += additionaltime;
newsoundtime += additionaltime;
Con_DPrintf("S_PaintAndSubmit: new extra sound time = %u\n",
newsoundtime, soundtime);
}
soundtime = newsoundtime;
- recording_sound = (cls.capturevideo_soundfile != NULL);
+ recording_sound = (cls.capturevideo.soundfile != NULL);
// Check to make sure that we haven't overshot
paintedtime = snd_renderbuffer->endframe;
if (snd_renderbuffer == NULL || nosound.integer)
return;
-
- if (snd_blocked > 0 && !cls.capturevideo_soundfile)
+
+ if (snd_blocked > 0 && !cls.capturevideo.soundfile)
return;
// If snd_swapstereo or snd_channellayout has changed, recompute the channel layout