From 9f9141823ae95392b8b4ef9bb663d1cf7aa157ff Mon Sep 17 00:00:00 2001 From: SNMetamorph <25657591+SNMetamorph@users.noreply.github.com> Date: Sat, 20 Aug 2022 13:59:14 +0400 Subject: [PATCH] engine: added audio backend print to s_info command --- engine/client/s_main.c | 3 ++- engine/client/sound.h | 7 ++++--- engine/platform/android/snd_opensles.c | 2 +- engine/platform/linux/s_alsa.c | 4 ++-- engine/platform/sdl/s_sdl.c | 4 +++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/engine/client/s_main.c b/engine/client/s_main.c index 5e1f8429..5a77e24f 100644 --- a/engine/client/s_main.c +++ b/engine/client/s_main.c @@ -1851,7 +1851,7 @@ S_SoundInfo_f */ void S_SoundInfo_f( void ) { - Con_Printf( "Audio: DirectSound\n" ); + Con_Printf( "Audio backend: %s\n", dma.backendName ); Con_Printf( "%5d channel(s)\n", 2 ); Con_Printf( "%5d samples\n", dma.samples ); Con_Printf( "%5d bits/sample\n", 16 ); @@ -1927,6 +1927,7 @@ qboolean S_Init( void ) Cmd_AddCommand( "spk", S_SayReliable_f, "reliable play a specified sententce" ); Cmd_AddCommand( "speak", S_Say_f, "playing a specified sententce" ); + dma.backendName = "None"; if( !SNDDMA_Init( ) ) { Con_Printf( "Audio: sound system can't be initialized\n" ); diff --git a/engine/client/sound.h b/engine/client/sound.h index 326f842b..c290fca8 100644 --- a/engine/client/sound.h +++ b/engine/client/sound.h @@ -114,10 +114,11 @@ typedef struct snd_format_s typedef struct { snd_format_t format; - int samples; // mono samples in buffer - int samplepos; // in mono samples - byte *buffer; + int samples; // mono samples in buffer + int samplepos; // in mono samples + byte *buffer; qboolean initialized; // sound engine is active + const char *backendName; } dma_t; #include "vox.h" diff --git a/engine/platform/android/snd_opensles.c b/engine/platform/android/snd_opensles.c index fb729025..9916a269 100644 --- a/engine/platform/android/snd_opensles.c +++ b/engine/platform/android/snd_opensles.c @@ -209,7 +209,7 @@ qboolean SNDDMA_Init( void ) } Msg( "OpenSL ES audio initialized.\n" ); - + dma.backendName = "OpenSL ES"; return true; } diff --git a/engine/platform/linux/s_alsa.c b/engine/platform/linux/s_alsa.c index 806e9151..eb738975 100644 --- a/engine/platform/linux/s_alsa.c +++ b/engine/platform/linux/s_alsa.c @@ -185,12 +185,12 @@ qboolean SNDDMA_Init( void ) } dma.buffer = Z_Malloc( samples * 2 ); //allocate pcm frame buffer - dma.samplepos = 0; - dma.samples = samples; dma.format.width = 2; dma.initialized = 1; + dma.backendName = "ALSA"; + snd_pcm_prepare( s_alsa.pcm_handle ); snd_pcm_writei( s_alsa.pcm_handle, dma.buffer, 2 * s_alsa.period_size ); snd_pcm_start( s_alsa.pcm_handle ); diff --git a/engine/platform/sdl/s_sdl.c b/engine/platform/sdl/s_sdl.c index 51e303f5..2a0b9d41 100644 --- a/engine/platform/sdl/s_sdl.c +++ b/engine/platform/sdl/s_sdl.c @@ -46,6 +46,7 @@ so it can unlock and free the data block after it has been played. static int sdl_dev; static SDL_AudioDeviceID in_dev = 0; static SDL_AudioFormat sdl_format; +static char sdl_backend_name[32]; //static qboolean snd_firsttime = true; //static qboolean primary_format_set; @@ -139,8 +140,9 @@ qboolean SNDDMA_Init( void ) sdl_format = obtained.format; Con_Printf( "Using SDL audio driver: %s @ %d Hz\n", SDL_GetCurrentAudioDriver( ), obtained.freq ); - + Q_snprintf( sdl_backend_name, sizeof( sdl_backend_name ), "SDL (%s)", SDL_GetCurrentAudioDriver( )); dma.initialized = true; + dma.backendName = sdl_backend_name; SNDDMA_Activate( true );