X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=snd_main.c;h=bed848683f79fee32c6985bf26f02f5753b9e071;hb=84661191e0819cf88c208b4ad314fcd23e8e1fbd;hp=e67eac70819fc23eff1d95a32c24f0c97e81f87c;hpb=a0232e5103d89640521aba7bec20ed2be5745e7d;p=xonotic%2Fdarkplaces.git diff --git a/snd_main.c b/snd_main.c index e67eac70..bed84868 100644 --- a/snd_main.c +++ b/snd_main.c @@ -301,6 +301,12 @@ void S_SoundInfo_f(void) } +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 [] = @@ -338,7 +344,7 @@ static qboolean S_ChooseCheaperFormat (snd_format_t* format, qboolean fixed_spee CHECK_BOUNDARIES(width); CHECK_BOUNDARIES(channels); #undef CHECK_BOUNDARIES - + // Find the level of each parameter #define FIND_LEVEL(param) \ param##_level = 0; \ @@ -420,7 +426,7 @@ static void S_SetChannelLayout (void) 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 @@ -627,9 +633,12 @@ void S_Startup (void) 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(); @@ -1381,13 +1390,13 @@ static void S_PaintAndSubmit (void) 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 @@ -1396,7 +1405,7 @@ static void S_PaintAndSubmit (void) newsoundtime += extrasoundtime; if (newsoundtime < soundtime) { - if ((cls.capturevideo_soundfile != NULL) != recording_sound) + if ((cls.capturevideo.soundfile != NULL) != recording_sound) { unsigned int additionaltime; @@ -1407,7 +1416,7 @@ static void S_PaintAndSubmit (void) // 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", @@ -1418,7 +1427,7 @@ static void S_PaintAndSubmit (void) 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; @@ -1454,8 +1463,8 @@ void S_Update(const matrix4x4_t *listenermatrix) 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