engine: added audio backend print to s_info command

This commit is contained in:
SNMetamorph 2022-08-20 13:59:14 +04:00 committed by Alibek Omarov
parent d3437c70bd
commit 9f9141823a
5 changed files with 12 additions and 8 deletions

View File

@ -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" );

View File

@ -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"

View File

@ -209,7 +209,7 @@ qboolean SNDDMA_Init( void )
}
Msg( "OpenSL ES audio initialized.\n" );
dma.backendName = "OpenSL ES";
return true;
}

View File

@ -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 );

View File

@ -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 );