Skip to content

Commit f917706

Browse files
committed
Option to disable audio
May decrease the frame time by not accessing disk (depends on where SVR is located).
1 parent 97ecf06 commit f917706

File tree

8 files changed

+40
-3
lines changed

8 files changed

+40
-3
lines changed

bin/data/profiles/default.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,10 @@ velo_font_weight=bold
9292
# 0 in both axes mean the center of the screen. A positive value will increase to the right and down.
9393
# A negative value will increase to the left and up.
9494
velo_align=0 80
95+
96+
#################################################################
97+
# Audio
98+
#################################################################
99+
100+
# Enable if you want audio.
101+
audio_enabled=1

src/game_proc.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,9 +1992,12 @@ bool proc_start(ID3D11Device* d3d11_device, ID3D11DeviceContext* d3d11_context,
19921992
}
19931993
}
19941994

1995-
if (!create_audio())
1995+
if (movie_profile.audio_enabled)
19961996
{
1997-
goto rfail;
1997+
if (!create_audio())
1998+
{
1999+
goto rfail;
2000+
}
19982001
}
19992002

20002003
// We have a controlled environment until the ffmpeg thread is started.
@@ -2193,6 +2196,11 @@ bool proc_is_velo_enabled()
21932196
return movie_profile.veloc_enabled;
21942197
}
21952198

2199+
bool proc_is_audio_enabled()
2200+
{
2201+
return movie_profile.audio_enabled;
2202+
}
2203+
21962204
void write_wav_samples()
21972205
{
21982206
s32 buf_size = sizeof(SvrWaveSample) * wav_num_samples;
@@ -2253,7 +2261,10 @@ void proc_end()
22532261
{
22542262
end_ffmpeg_proc();
22552263

2256-
end_audio();
2264+
if (movie_profile.audio_enabled)
2265+
{
2266+
end_audio();
2267+
}
22572268

22582269
free_all_dynamic_sw_stuff();
22592270
free_all_dynamic_proc_stuff();

src/game_proc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ bool proc_start(ID3D11Device* d3d11_device, ID3D11DeviceContext* d3d11_context,
1414
void proc_frame(ID3D11DeviceContext* d3d11_context, ID3D11ShaderResourceView* game_content_srv, ID3D11RenderTargetView* game_content_rtv);
1515
void proc_give_velocity(float* xyz);
1616
bool proc_is_velo_enabled();
17+
bool proc_is_audio_enabled();
1718
void proc_give_audio(SvrWaveSample* samples, s32 num_samples);
1819
void proc_end();
1920
s32 proc_get_game_rate();

src/game_proc_profile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ bool read_profile(const char* full_profile_path, MovieProfile* p)
252252
else if OPT_STR_MAP("velo_font_style", p->veloc_font_style, FONT_STYLE_TABLE, DWRITE_FONT_STYLE_NORMAL)
253253
else if OPT_STR_MAP("velo_font_weight", p->veloc_font_weight, FONT_WEIGHT_TABLE, DWRITE_FONT_WEIGHT_BOLD)
254254
else if OPT_VEC2("velo_align", p->veloc_align)
255+
else if OPT_S32("audio_enabled", p->audio_enabled, 0, 1)
255256
}
256257

257258
svr_free_ini_line(&ini_line);

src/game_proc_profile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ struct MovieProfile
2828
enum DWRITE_FONT_STYLE veloc_font_style;
2929
enum DWRITE_FONT_WEIGHT veloc_font_weight;
3030
s32 veloc_align[2];
31+
32+
// Audio:
33+
s32 audio_enabled;
3134
};
3235

3336
bool read_profile(const char* full_profile_path, MovieProfile* p);

src/game_standalone.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,11 @@ void __cdecl snd_paint_chans_override2(s64 end_time, bool is_underwater)
557557

558558
void prepare_and_send_sound(GmSndSample* paint_buf, s32 num_samples)
559559
{
560+
if (!svr_is_audio_enabled())
561+
{
562+
return;
563+
}
564+
560565
SvrWaveSample* buf = (SvrWaveSample*)_alloca(sizeof(SvrWaveSample) * num_samples);
561566

562567
for (s32 i = 0; i < num_samples; i++)

src/svr_api.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ bool svr_is_velo_enabled()
287287
return proc_is_velo_enabled();
288288
}
289289

290+
bool svr_is_audio_enabled()
291+
{
292+
return proc_is_audio_enabled();
293+
}
294+
290295
void svr_give_velocity(float* xyz)
291296
{
292297
proc_give_velocity(xyz);

src/svr_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ SVR_API void svr_frame();
124124
// Must only be called after svr_start.
125125
SVR_API bool svr_is_velo_enabled();
126126

127+
// Returns if audio is enabled in the active profile.
128+
// Must only be called after svr_start.
129+
SVR_API bool svr_is_audio_enabled();
130+
127131
// For the velocity extension, call this to give the player xyz velocity so it can be drawn to the encoded video.
128132
// Must be called before svr_frame.
129133
SVR_API void svr_give_velocity(float* xyz);

0 commit comments

Comments
 (0)