mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 14:52:00 +00:00
Enable SDL audio capture for SDL 2.0.5 and newer
The version check is required for supporting macOS PPC with SDL 2.0.1 and Travis-CI (Ubuntu Trusty) with SDL 2.0.2. The client now requires SDL 2.0.5 runtime if compiled against SDL 2.0.5 or newer.
This commit is contained in:
parent
45af2594a0
commit
92935df37b
2 changed files with 27 additions and 11 deletions
|
@ -47,11 +47,11 @@ static int dmasize = 0;
|
||||||
|
|
||||||
static SDL_AudioDeviceID sdlPlaybackDevice;
|
static SDL_AudioDeviceID sdlPlaybackDevice;
|
||||||
|
|
||||||
#ifdef USE_VOIP
|
#if defined USE_VOIP && SDL_VERSION_ATLEAST( 2, 0, 5 )
|
||||||
|
#define USE_SDL_AUDIO_CAPTURE
|
||||||
|
|
||||||
static SDL_AudioDeviceID sdlCaptureDevice;
|
static SDL_AudioDeviceID sdlCaptureDevice;
|
||||||
#if 0 // !!! FIXME: reenable after updating prebuild SDL libraries to 2.0.8!
|
|
||||||
static cvar_t *s_sdlCapture;
|
static cvar_t *s_sdlCapture;
|
||||||
#endif
|
|
||||||
static float sdlMasterGain = 1.0f;
|
static float sdlMasterGain = 1.0f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ static void SNDDMA_AudioCallback(void *userdata, Uint8 *stream, int len)
|
||||||
if (dmapos >= dmasize)
|
if (dmapos >= dmasize)
|
||||||
dmapos = 0;
|
dmapos = 0;
|
||||||
|
|
||||||
#ifdef USE_VOIP
|
#ifdef USE_SDL_AUDIO_CAPTURE
|
||||||
if (sdlMasterGain != 1.0f)
|
if (sdlMasterGain != 1.0f)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -283,8 +283,7 @@ qboolean SNDDMA_Init(void)
|
||||||
dmasize = (dma.samples * (dma.samplebits/8));
|
dmasize = (dma.samples * (dma.samplebits/8));
|
||||||
dma.buffer = calloc(1, dmasize);
|
dma.buffer = calloc(1, dmasize);
|
||||||
|
|
||||||
#ifdef USE_VOIP
|
#ifdef USE_SDL_AUDIO_CAPTURE
|
||||||
#if 0 // !!! FIXME: reenable after updating prebuild SDL libraries to 2.0.8!
|
|
||||||
// !!! FIXME: some of these SDL_OpenAudioDevice() values should be cvars.
|
// !!! FIXME: some of these SDL_OpenAudioDevice() values should be cvars.
|
||||||
s_sdlCapture = Cvar_Get( "s_sdlCapture", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
s_sdlCapture = Cvar_Get( "s_sdlCapture", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||||
if (!s_sdlCapture->integer)
|
if (!s_sdlCapture->integer)
|
||||||
|
@ -310,10 +309,9 @@ qboolean SNDDMA_Init(void)
|
||||||
Com_Printf( "SDL capture device %s.\n",
|
Com_Printf( "SDL capture device %s.\n",
|
||||||
(sdlCaptureDevice == 0) ? "failed to open" : "opened");
|
(sdlCaptureDevice == 0) ? "failed to open" : "opened");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sdlMasterGain = 1.0f;
|
sdlMasterGain = 1.0f;
|
||||||
|
#endif
|
||||||
|
|
||||||
Com_Printf("Starting SDL audio callback...\n");
|
Com_Printf("Starting SDL audio callback...\n");
|
||||||
SDL_PauseAudioDevice(sdlPlaybackDevice, 0); // start callback.
|
SDL_PauseAudioDevice(sdlPlaybackDevice, 0); // start callback.
|
||||||
|
@ -349,6 +347,7 @@ void SNDDMA_Shutdown(void)
|
||||||
sdlPlaybackDevice = 0;
|
sdlPlaybackDevice = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_SDL_AUDIO_CAPTURE
|
||||||
if (sdlCaptureDevice)
|
if (sdlCaptureDevice)
|
||||||
{
|
{
|
||||||
Com_Printf("Closing SDL audio capture device...\n");
|
Com_Printf("Closing SDL audio capture device...\n");
|
||||||
|
@ -356,6 +355,7 @@ void SNDDMA_Shutdown(void)
|
||||||
Com_Printf("SDL audio capture device closed.\n");
|
Com_Printf("SDL audio capture device closed.\n");
|
||||||
sdlCaptureDevice = 0;
|
sdlCaptureDevice = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||||
free(dma.buffer);
|
free(dma.buffer);
|
||||||
|
@ -391,7 +391,7 @@ void SNDDMA_BeginPainting (void)
|
||||||
#ifdef USE_VOIP
|
#ifdef USE_VOIP
|
||||||
void SNDDMA_StartCapture(void)
|
void SNDDMA_StartCapture(void)
|
||||||
{
|
{
|
||||||
#if 0 // !!! FIXME: reenable after updating prebuild SDL libraries to 2.0.8!
|
#ifdef USE_SDL_AUDIO_CAPTURE
|
||||||
if (sdlCaptureDevice)
|
if (sdlCaptureDevice)
|
||||||
{
|
{
|
||||||
SDL_ClearQueuedAudio(sdlCaptureDevice);
|
SDL_ClearQueuedAudio(sdlCaptureDevice);
|
||||||
|
@ -402,7 +402,7 @@ void SNDDMA_StartCapture(void)
|
||||||
|
|
||||||
int SNDDMA_AvailableCaptureSamples(void)
|
int SNDDMA_AvailableCaptureSamples(void)
|
||||||
{
|
{
|
||||||
#if 0 // !!! FIXME: reenable after updating prebuild SDL libraries to 2.0.8!
|
#ifdef USE_SDL_AUDIO_CAPTURE
|
||||||
// divided by 2 to convert from bytes to (mono16) samples.
|
// divided by 2 to convert from bytes to (mono16) samples.
|
||||||
return sdlCaptureDevice ? (SDL_GetQueuedAudioSize(sdlCaptureDevice) / 2) : 0;
|
return sdlCaptureDevice ? (SDL_GetQueuedAudioSize(sdlCaptureDevice) / 2) : 0;
|
||||||
#else
|
#else
|
||||||
|
@ -412,7 +412,7 @@ int SNDDMA_AvailableCaptureSamples(void)
|
||||||
|
|
||||||
void SNDDMA_Capture(int samples, byte *data)
|
void SNDDMA_Capture(int samples, byte *data)
|
||||||
{
|
{
|
||||||
#if 0 // !!! FIXME: reenable after updating prebuild SDL libraries to 2.0.8!
|
#ifdef USE_SDL_AUDIO_CAPTURE
|
||||||
// multiplied by 2 to convert from (mono16) samples to bytes.
|
// multiplied by 2 to convert from (mono16) samples to bytes.
|
||||||
if (sdlCaptureDevice)
|
if (sdlCaptureDevice)
|
||||||
{
|
{
|
||||||
|
@ -427,15 +427,19 @@ void SNDDMA_Capture(int samples, byte *data)
|
||||||
|
|
||||||
void SNDDMA_StopCapture(void)
|
void SNDDMA_StopCapture(void)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_SDL_AUDIO_CAPTURE
|
||||||
if (sdlCaptureDevice)
|
if (sdlCaptureDevice)
|
||||||
{
|
{
|
||||||
SDL_PauseAudioDevice(sdlCaptureDevice, 1);
|
SDL_PauseAudioDevice(sdlCaptureDevice, 1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SNDDMA_MasterGain( float val )
|
void SNDDMA_MasterGain( float val )
|
||||||
{
|
{
|
||||||
|
#ifdef USE_SDL_AUDIO_CAPTURE
|
||||||
sdlMasterGain = val;
|
sdlMasterGain = val;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,22 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include "../qcommon/q_shared.h"
|
#include "../qcommon/q_shared.h"
|
||||||
#include "../qcommon/qcommon.h"
|
#include "../qcommon/qcommon.h"
|
||||||
|
|
||||||
|
#ifndef DEDICATED
|
||||||
|
#ifdef USE_LOCAL_HEADERS
|
||||||
|
# include "SDL_version.h"
|
||||||
|
#else
|
||||||
|
# include <SDL_version.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// Require a minimum version of SDL
|
// Require a minimum version of SDL
|
||||||
#define MINSDL_MAJOR 2
|
#define MINSDL_MAJOR 2
|
||||||
#define MINSDL_MINOR 0
|
#define MINSDL_MINOR 0
|
||||||
|
#if SDL_VERSION_ATLEAST( 2, 0, 5 )
|
||||||
|
#define MINSDL_PATCH 5
|
||||||
|
#else
|
||||||
#define MINSDL_PATCH 0
|
#define MINSDL_PATCH 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// Console
|
// Console
|
||||||
void CON_Shutdown( void );
|
void CON_Shutdown( void );
|
||||||
|
|
Loading…
Reference in a new issue