Permalink
Browse files

Use s_khz with SDL sound backend

And remove s_sdlSpeed
  • Loading branch information...
xycaleth committed Jun 9, 2018
1 parent 9736ae6 commit 63e31e83454b0309d7dcb03d949ea7ab82497dfd
Showing with 17 additions and 54 deletions.
  1. +2 −1 code/client/snd_dma.cpp
  2. +0 −23 code/client/snd_local.h
  3. +2 −3 codemp/client/snd_dma.cpp
  4. +0 −23 codemp/client/snd_local.h
  5. +13 −4 shared/sdl/sdl_sound.cpp
View
@@ -30,6 +30,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "../server/exe_headers.h"
#include "sdl/sdl_sound.h"
#include "snd_local.h"
#include "cl_mp3.h"
#include "snd_music.h"
@@ -619,7 +620,7 @@ void S_Init( void ) {
else
{
#endif
r = SNDDMA_Init();
r = SNDDMA_Init(s_khz->integer);
if ( r ) {
s_soundStarted = 1;
View
@@ -184,29 +184,6 @@ typedef struct {
int dataofs; // chunk starts this many bytes from file start
} wavinfo_t;
/*
====================================================================
SYSTEM SPECIFIC FUNCTIONS
====================================================================
*/
// initializes cycling through a DMA buffer and returns information on it
qboolean SNDDMA_Init(void);
// gets the current DMA position
int SNDDMA_GetDMAPos(void);
// shutdown the DMA xfer.
void SNDDMA_Shutdown(void);
void SNDDMA_BeginPainting (void);
void SNDDMA_Submit(void);
//====================================================================
#define MAX_CHANNELS 32
@@ -28,6 +28,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*
*****************************************************************************/
#include "sdl/sdl_sound.h"
#include "snd_local.h"
#include "snd_mp3.h"
#include "snd_music.h"
@@ -436,8 +437,6 @@ void S_SoundInfo_f(void) {
Com_Printf("----------------------\n" );
}
/*
================
S_Init
@@ -618,7 +617,7 @@ void S_Init( void ) {
else
{
#endif
r = SNDDMA_Init();
r = SNDDMA_Init(s_khz->integer);
if ( r ) {
s_soundStarted = 1;
View
@@ -180,29 +180,6 @@ typedef struct wavinfo_s {
int dataofs; // chunk starts this many bytes from file start
} wavinfo_t;
/*
====================================================================
SYSTEM SPECIFIC FUNCTIONS
====================================================================
*/
// initializes cycling through a DMA buffer and returns information on it
qboolean SNDDMA_Init(void);
// gets the current DMA position
int SNDDMA_GetDMAPos(void);
// shutdown the DMA xfer.
void SNDDMA_Shutdown(void);
void SNDDMA_BeginPainting (void);
void SNDDMA_Submit(void);
//====================================================================
#define MAX_CHANNELS 32
View
@@ -132,12 +132,23 @@ static void SNDDMA_PrintAudiospec(const char *str, const SDL_AudioSpec *spec)
Com_Printf( " Channels: %d\n", (int) spec->channels );
}
static int SNDDMA_ExpandSampleFrequencyKHzToHz(int khz)
{
switch (khz)
{
default:
case 44: return 44100;
case 22: return 22050;
case 11: return 11025;
}
}
/*
===============
SNDDMA_Init
===============
*/
qboolean SNDDMA_Init(void)
qboolean SNDDMA_Init(int sampleFrequencyInKHz)
{
SDL_AudioSpec desired;
SDL_AudioSpec obtained;
@@ -148,7 +159,6 @@ qboolean SNDDMA_Init(void)
if (!s_sdlBits) {
s_sdlBits = Cvar_Get("s_sdlBits", "16", CVAR_ARCHIVE_ND);
s_sdlSpeed = Cvar_Get("s_sdlSpeed", "0", CVAR_ARCHIVE);
s_sdlChannels = Cvar_Get("s_sdlChannels", "2", CVAR_ARCHIVE_ND);
s_sdlDevSamps = Cvar_Get("s_sdlDevSamps", "0", CVAR_ARCHIVE_ND);
s_sdlMixSamps = Cvar_Get("s_sdlMixSamps", "0", CVAR_ARCHIVE_ND);
@@ -176,8 +186,7 @@ qboolean SNDDMA_Init(void)
if ((tmp != 16) && (tmp != 8))
tmp = 16;
desired.freq = (int) s_sdlSpeed->value;
if(!desired.freq) desired.freq = 44100;
desired.freq = SNDDMA_ExpandSampleFrequencyKHzToHz(sampleFrequencyInKHz);
desired.format = ((tmp == 16) ? AUDIO_S16SYS : AUDIO_U8);
// I dunno if this is the best idea, but I'll give it a try...

0 comments on commit 63e31e8

Please sign in to comment.