Browse Source

engine: added audio backend print to s_info command

pull/2/head
SNMetamorph 2 years ago committed by Alibek Omarov
parent
commit
9f9141823a
  1. 3
      engine/client/s_main.c
  2. 7
      engine/client/sound.h
  3. 2
      engine/platform/android/snd_opensles.c
  4. 4
      engine/platform/linux/s_alsa.c
  5. 4
      engine/platform/sdl/s_sdl.c

3
engine/client/s_main.c

@ -1851,7 +1851,7 @@ S_SoundInfo_f @@ -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 ) @@ -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" );

7
engine/client/sound.h

@ -114,10 +114,11 @@ typedef struct snd_format_s @@ -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"

2
engine/platform/android/snd_opensles.c

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

4
engine/platform/linux/s_alsa.c

@ -185,12 +185,12 @@ qboolean SNDDMA_Init( void ) @@ -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 );

4
engine/platform/sdl/s_sdl.c

@ -46,6 +46,7 @@ so it can unlock and free the data block after it has been played. @@ -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 ) @@ -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 );

Loading…
Cancel
Save