mirror of
https://github.com/nzp-team/dquakeplus.git
synced 2024-11-22 20:02:37 +00:00
Merge pull request #8 from nzp-team/sdl-audio
Move Audio handling from internal to SDL
This commit is contained in:
commit
d1d2671880
9 changed files with 182 additions and 237 deletions
11
MakePHAT
11
MakePHAT
|
@ -13,7 +13,6 @@ PSP_FW_VERSION=660
|
|||
|
||||
MODE=-DKERNEL_MODE
|
||||
|
||||
|
||||
ifeq ($(USE_GPROF),1)
|
||||
GPROF_LIBS = -lpspprof
|
||||
GPROF_FLAGS = -pg -DPROFILE
|
||||
|
@ -28,7 +27,6 @@ COMMON_OBJS = \
|
|||
source/psp/input.o \
|
||||
source/psp/main.o \
|
||||
source/psp/math.o \
|
||||
source/psp/sound.o \
|
||||
source/psp/system.o \
|
||||
source/psp/module.o \
|
||||
source/psp/network.o \
|
||||
|
@ -64,6 +62,7 @@ COMMON_OBJS = \
|
|||
source/pr_cmds.o \
|
||||
source/pr_edict.o \
|
||||
source/pr_exec.o \
|
||||
source/snd_sdl.o \
|
||||
source/snd_dma.o \
|
||||
source/snd_mem.o \
|
||||
source/snd_mix.o \
|
||||
|
@ -109,16 +108,14 @@ HARDWARE_VIDEO_ONLY_FLAGS = -DPSP_HARDWARE_VIDEO
|
|||
|
||||
OBJS = $(COMMON_OBJS) $(HARDWARE_VIDEO_ONLY_OBJS)
|
||||
|
||||
|
||||
#LIBS = -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lpsppower -lpspwlan -lstdc++ -lm
|
||||
|
||||
SDL_LIBS = -lSDL2 -lvorbisfile -lvorbis -logg -lGL -lGLU -lglut
|
||||
GU_LIBS = -lpspgum_vfpu -lpspvfpu -lpspgu -lpspvram
|
||||
AUDIO_LIBS = -lpspaudiolib -lpspaudio -lpspmp3 source/psp/m33libs/libpspaudiocodec.a source/psp/m33libs/libpspkubridge.a
|
||||
|
||||
MISC_LIBS = -lpsprtc -lpspmath -lpsppower -lpsphprm -ljpeg -lpng source/psp/m33libs/libz.a
|
||||
MISC_LIBS = -lpsprtc -lpsppower -lpspmath -lpsphprm -ljpeg -lpng source/psp/m33libs/libz.a
|
||||
NET_LIBS = -lpspwlan -lpspnet_adhoc -lpspnet_adhocctl
|
||||
STD_LIBS = -lstdc++ -lm -lc
|
||||
LIBS = $(GPROF_LIBS) $(GU_LIBS) $(AUDIO_LIBS) $(MISC_LIBS) $(STD_LIBS) $(NET_LIBS)
|
||||
LIBS = $(GPROF_LIBS) $(SDL_LIBS) $(GU_LIBS) $(AUDIO_LIBS) $(MISC_LIBS) $(STD_LIBS) $(NET_LIBS)
|
||||
|
||||
CFLAGS = -ffast-math -O3 -G0 -Wall $(GPROF_FLAGS) -Did386="0" -DPSP $(MODE) $(HARDWARE_VIDEO_ONLY_FLAGS) -DSWIZZLE32 -DPSP_MP3_HWDECODE -DFULLBRIGHT -DHL_RENDER -Wno-strict-aliasing -DPSP_VFPU
|
||||
CXXFLAGS = -fno-rtti -Wcast-qual -Wno-write-strings -Wno-sign-compare -Wno-strict-aliasing
|
||||
|
|
8
MakeSLIM
8
MakeSLIM
|
@ -29,7 +29,6 @@ COMMON_OBJS = \
|
|||
source/psp/input.o \
|
||||
source/psp/main.o \
|
||||
source/psp/math.o \
|
||||
source/psp/sound.o \
|
||||
source/psp/system.o \
|
||||
source/psp/module.o \
|
||||
source/psp/network.o \
|
||||
|
@ -65,6 +64,7 @@ COMMON_OBJS = \
|
|||
source/pr_cmds.o \
|
||||
source/pr_edict.o \
|
||||
source/pr_exec.o \
|
||||
source/snd_sdl.o \
|
||||
source/snd_dma.o \
|
||||
source/snd_mem.o \
|
||||
source/snd_mix.o \
|
||||
|
@ -110,16 +110,14 @@ HARDWARE_VIDEO_ONLY_FLAGS = -DPSP_HARDWARE_VIDEO
|
|||
|
||||
OBJS = $(COMMON_OBJS) $(HARDWARE_VIDEO_ONLY_OBJS)
|
||||
|
||||
|
||||
#LIBS = -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lpsppower -lpspwlan -lstdc++ -lm
|
||||
|
||||
SDL_LIBS = -lSDL2 -lvorbisfile -lvorbis -logg -lGL -lGLU -lglut
|
||||
GU_LIBS = -lpspgum_vfpu -lpspvfpu -lpspgu -lpspvram
|
||||
AUDIO_LIBS = -lpspaudiolib -lpspaudio -lpspmp3 source/psp/m33libs/libpspaudiocodec.a source/psp/m33libs/libpspkubridge.a
|
||||
|
||||
MISC_LIBS = -lpsprtc -lpsppower -lpspmath -lpsphprm -ljpeg -lpng source/psp/m33libs/libz.a
|
||||
NET_LIBS = -lpspwlan -lpspnet_adhoc -lpspnet_adhocctl
|
||||
STD_LIBS = -lstdc++ -lm -lc
|
||||
LIBS = $(GPROF_LIBS) $(GU_LIBS) $(AUDIO_LIBS) $(MISC_LIBS) $(STD_LIBS) $(NET_LIBS)
|
||||
LIBS = $(GPROF_LIBS) $(SDL_LIBS) $(GU_LIBS) $(AUDIO_LIBS) $(MISC_LIBS) $(STD_LIBS) $(NET_LIBS)
|
||||
|
||||
CFLAGS = -ffast-math -O3 -G0 -Wall $(GPROF_FLAGS) -Did386="0" -DPSP $(MODE) $(HARDWARE_VIDEO_ONLY_FLAGS) -DSWIZZLE32 -DSLIM -DPSP_MP3_HWDECODE -DFULLBRIGHT -DHL_RENDER -Wno-strict-aliasing -DPSP_VFPU
|
||||
CXXFLAGS = -fno-rtti -Wcast-qual -Wno-write-strings -Wno-sign-compare -Wno-strict-aliasing
|
||||
|
|
|
@ -759,18 +759,11 @@ void _Host_Frame (float time)
|
|||
// update audio
|
||||
if (cls.signon == SIGNONS)
|
||||
{
|
||||
Thread_UpdateSound(r_origin, vpn, vright, vup);
|
||||
//S_Update (r_origin, vpn, vright, vup);
|
||||
S_Update (r_origin, vpn, vright, vup);
|
||||
CL_DecayLights ();
|
||||
}
|
||||
else
|
||||
Thread_UpdateSound(vec3_origin, vec3_origin, vec3_origin, vec3_origin);
|
||||
//S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
|
||||
|
||||
//if (bmg_type_changed == true) {
|
||||
CDAudio_Update();
|
||||
// bmg_type_changed = false;
|
||||
//}
|
||||
S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
|
||||
|
||||
if (host_speeds.value)
|
||||
{
|
||||
|
|
|
@ -180,7 +180,7 @@ void CDAudio_Track(char* trackname)
|
|||
|
||||
void CDAudio_Play(byte track, qboolean looping)
|
||||
{
|
||||
last_track = track;
|
||||
/*last_track = track;
|
||||
CDAudio_Stop();
|
||||
|
||||
if (track < 1)
|
||||
|
@ -207,7 +207,7 @@ void CDAudio_Play(byte track, qboolean looping)
|
|||
}
|
||||
|
||||
|
||||
CDAudio_VolumeChange(bgmvolume.value);
|
||||
CDAudio_VolumeChange(bgmvolume.value);*/
|
||||
}
|
||||
|
||||
void CDAudio_Stop(void)
|
||||
|
|
|
@ -36,6 +36,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <pspge.h>
|
||||
#include <pspsysevent.h>
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../quakedef.h"
|
||||
|
@ -86,7 +89,7 @@ namespace quake
|
|||
|
||||
#else
|
||||
|
||||
static size_t heapSize = 9 * 1024 * 1024;
|
||||
static size_t heapSize = 10 * 1024 * 1024;
|
||||
|
||||
#endif // SLIM
|
||||
|
||||
|
@ -528,9 +531,16 @@ int user_main(SceSize argc, void* argp)
|
|||
// operations.
|
||||
disableFloatingPointExceptions();
|
||||
|
||||
// Initialise the Common module.
|
||||
// Initialize the Common module.
|
||||
InitExtModules ();
|
||||
|
||||
// Initialize SDL
|
||||
if (SDL_Init(SDL_INIT_AUDIO) < 0)
|
||||
{
|
||||
Sys_Error("SDL2: Could not initialize!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the current working dir.
|
||||
char currentDirectory[1024];
|
||||
char gameDirectory[1024];
|
||||
|
@ -633,9 +643,6 @@ int user_main(SceSize argc, void* argp)
|
|||
u64 lastTicks;
|
||||
sceRtcGetCurrentTick(&lastTicks);
|
||||
|
||||
// Set up threads
|
||||
Sys_InitThreads();
|
||||
|
||||
// Enter the main loop.
|
||||
while (!quit)
|
||||
{
|
||||
|
|
|
@ -1,157 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
Copyright (C) 2007 Peter Mackay and Chris Swindle.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <pspaudiolib.h>
|
||||
#include <pspkernel.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../quakedef.h"
|
||||
}
|
||||
|
||||
namespace quake
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
struct Sample
|
||||
{
|
||||
short left;
|
||||
short right;
|
||||
};
|
||||
|
||||
static const unsigned int channelCount = 2;
|
||||
static const unsigned int inputBufferSize = 16384;
|
||||
static const unsigned int inputFrequency = 11025;
|
||||
static const unsigned int outputFrequency = 44100;
|
||||
static const unsigned int inputSamplesPerOutputSample = outputFrequency / inputFrequency;
|
||||
static Sample inputBuffer[inputBufferSize];
|
||||
static volatile unsigned int samplesRead;
|
||||
|
||||
static inline void copySamples(const Sample* first, const Sample* last, Sample* destination)
|
||||
{
|
||||
// just assume inputSamplesPerOutputSample is 4.
|
||||
for (const Sample* source = first; source != last; ++source)
|
||||
{
|
||||
const Sample sample = *source;
|
||||
*destination++ = sample;
|
||||
*destination++ = sample;
|
||||
*destination++ = sample;
|
||||
*destination++ = sample;
|
||||
}
|
||||
}
|
||||
|
||||
static void fillOutputBuffer(void* buffer, unsigned int samplesToWrite, void* userData)
|
||||
{
|
||||
// Where are we writing to?
|
||||
Sample* const destination = static_cast<Sample*> (buffer);
|
||||
|
||||
// Where are we reading from?
|
||||
const Sample* const firstSampleToRead = &inputBuffer[samplesRead];
|
||||
|
||||
// How many samples to read?
|
||||
const unsigned int samplesToRead = samplesToWrite / inputSamplesPerOutputSample;
|
||||
|
||||
// Going to wrap past the end of the input buffer?
|
||||
const unsigned int samplesBeforeEndOfInput = inputBufferSize - samplesRead;
|
||||
if (samplesToRead > samplesBeforeEndOfInput)
|
||||
{
|
||||
// Yes, so write the first chunk from the end of the input buffer.
|
||||
copySamples(
|
||||
firstSampleToRead,
|
||||
firstSampleToRead + samplesBeforeEndOfInput,
|
||||
&destination[0]);
|
||||
|
||||
// Write the second chunk from the start of the input buffer.
|
||||
const unsigned int samplesToReadFromBeginning = samplesToRead - samplesBeforeEndOfInput;
|
||||
copySamples(
|
||||
&inputBuffer[0],
|
||||
&inputBuffer[samplesToReadFromBeginning],
|
||||
&destination[samplesBeforeEndOfInput * inputSamplesPerOutputSample]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No wrapping, just copy.
|
||||
copySamples(
|
||||
firstSampleToRead,
|
||||
firstSampleToRead + samplesToRead,
|
||||
&destination[0]);
|
||||
}
|
||||
|
||||
// Update the read offset.
|
||||
samplesRead = (samplesRead + samplesToRead) % inputBufferSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using namespace quake;
|
||||
using namespace quake::sound;
|
||||
|
||||
qboolean SNDDMA_Init(void)
|
||||
{
|
||||
// Set up Quake's audio.
|
||||
shm = &sn;
|
||||
shm->channels = channelCount;
|
||||
shm->samplebits = 16;
|
||||
shm->speed = inputFrequency;
|
||||
shm->soundalive = qtrue;
|
||||
shm->splitbuffer = qfalse;
|
||||
shm->samples = inputBufferSize * channelCount;
|
||||
shm->samplepos = 0;
|
||||
shm->submission_chunk = 1;
|
||||
shm->buffer = (unsigned char *) inputBuffer;
|
||||
|
||||
// Initialise the audio system. This initialises it for the CD audio module
|
||||
// too.
|
||||
pspAudioInit();
|
||||
|
||||
// Set the channel callback.
|
||||
// Sound effects use channel 0, CD audio uses channel 1.
|
||||
pspAudioSetChannelCallback(0, fillOutputBuffer, 0);
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
void SNDDMA_Shutdown(void)
|
||||
{
|
||||
// Clear the mixing buffer so we don't get any noise during cleanup.
|
||||
memset(inputBuffer, 0, sizeof(inputBuffer));
|
||||
|
||||
// Clear the channel callback.
|
||||
pspAudioSetChannelCallback(0, 0, 0);
|
||||
|
||||
// Stop the audio system?
|
||||
pspAudioEndPre();
|
||||
|
||||
// Insert a false delay so the thread can be cleaned up.
|
||||
sceKernelDelayThread(50 * 1000);
|
||||
|
||||
// Shut down the audio system.
|
||||
pspAudioEnd();
|
||||
}
|
||||
|
||||
int SNDDMA_GetDMAPos(void)
|
||||
{
|
||||
return samplesRead * channelCount;
|
||||
}
|
||||
|
||||
void SNDDMA_Submit(void)
|
||||
{
|
||||
}
|
|
@ -2112,12 +2112,21 @@ void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype)
|
|||
COM_StripExtension(loadmodel->name, model);
|
||||
// HACK HACK HACK
|
||||
sprintf (model2, "%s.mdl_%i", model, i);
|
||||
|
||||
// Sigh.. something is totally awry with memory and the Slim kinda band-aids it..
|
||||
// Textures can occupy RAM and VRAM at the same time, ie RAM isnt being freed properly
|
||||
// So PHAT ends up kicking the bucket with a lot of external textures.
|
||||
#ifdef SLIM
|
||||
|
||||
pheader->gl_texturenum[i][0] =
|
||||
pheader->gl_texturenum[i][1] =
|
||||
pheader->gl_texturenum[i][2] =
|
||||
pheader->gl_texturenum[i][3] = loadtextureimage (model2, 0, 0, qtrue, GU_LINEAR);
|
||||
|
||||
if (pheader->gl_texturenum[i][0] == 0)// did not find a matching TGA...
|
||||
|
||||
#endif // SLIM
|
||||
|
||||
{
|
||||
sprintf (name, "%s_%i", loadmodel->name, i);
|
||||
if(mod_h2)
|
||||
|
|
|
@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// snd_dma.c -- main control for any streaming sound output device
|
||||
|
||||
#include "quakedef.h"
|
||||
#include "thread.h"
|
||||
|
||||
void S_Play(void);
|
||||
void S_PlayVol(void);
|
||||
|
@ -60,7 +59,7 @@ int num_sfx;
|
|||
|
||||
sfx_t *ambient_sfx[NUM_AMBIENTS];
|
||||
|
||||
int desired_speed = 11025;
|
||||
int desired_speed = 44100; //11025;
|
||||
int desired_bits = 16;
|
||||
|
||||
int sound_started=0;
|
||||
|
@ -184,14 +183,13 @@ void S_Init (void)
|
|||
Cvar_RegisterVariable(&loadas8bit);
|
||||
Cvar_RegisterVariable(&bgmvolume);
|
||||
Cvar_RegisterVariable(&bgmbuffer);
|
||||
Cvar_RegisterVariable(&bgmtype);
|
||||
Cvar_RegisterVariable(&ambient_level);
|
||||
Cvar_RegisterVariable(&ambient_fade);
|
||||
Cvar_RegisterVariable(&snd_noextraupdate);
|
||||
Cvar_RegisterVariable(&snd_show);
|
||||
Cvar_RegisterVariable(&_snd_mixahead);
|
||||
|
||||
if (host_parms.memsize < 0x800000)
|
||||
//if (host_parms.memsize < 0x800000)
|
||||
{
|
||||
Cvar_Set ("loadas8bit", "1");
|
||||
Con_Printf ("loading all sounds as 8bit\n");
|
||||
|
@ -225,15 +223,17 @@ void S_Init (void)
|
|||
shm->buffer = Hunk_AllocName(1<<16, "shmbuf");
|
||||
}
|
||||
|
||||
if ( shm ) {
|
||||
Con_Printf ("Sound sampling rate: %i\n", shm->speed);
|
||||
}
|
||||
|
||||
// provides a tick sound until washed clean
|
||||
|
||||
// if (shm->buffer)
|
||||
// shm->buffer[4] = shm->buffer[5] = 0x7f; // force a pop for debugging
|
||||
|
||||
ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("sounds/ambience/water1.wav");
|
||||
ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("sounds/ambience/wind2.wav");
|
||||
ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav");
|
||||
ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav");
|
||||
|
||||
S_StopAllSounds (true);
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ SND_Spatialize
|
|||
void SND_Spatialize(channel_t *ch)
|
||||
{
|
||||
vec_t dot;
|
||||
vec_t dist;
|
||||
vec_t ldist, rdist, dist;
|
||||
vec_t lscale, rscale, scale;
|
||||
vec3_t source_vec;
|
||||
sfx_t *snd;
|
||||
|
@ -566,11 +566,8 @@ void S_ClearBuffer (void)
|
|||
else
|
||||
clear = 0;
|
||||
|
||||
|
||||
{
|
||||
Q_memset(shm->buffer, clear, shm->samples * shm->samplebits/8);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -800,9 +797,6 @@ void GetSoundtime(void)
|
|||
|
||||
void S_ExtraUpdate (void)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (snd_noextraupdate.value)
|
||||
return; // don't pollute timings
|
||||
S_Update_();
|
||||
|
@ -810,6 +804,8 @@ void S_ExtraUpdate (void)
|
|||
|
||||
void S_Update_(void)
|
||||
{
|
||||
/*#ifndef SDL
|
||||
|
||||
unsigned endtime;
|
||||
int samps;
|
||||
|
||||
|
@ -835,6 +831,7 @@ void S_Update_(void)
|
|||
S_PaintChannels (endtime);
|
||||
|
||||
SNDDMA_Submit ();
|
||||
#endif*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -950,4 +947,3 @@ void S_BeginPrecaching (void)
|
|||
void S_EndPrecaching (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
102
source/snd_sdl.c
Normal file
102
source/snd_sdl.c
Normal file
|
@ -0,0 +1,102 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <SDL2/SDL_audio.h>
|
||||
#include "quakedef.h"
|
||||
|
||||
static dma_t the_shm;
|
||||
static int snd_inited;
|
||||
|
||||
extern int desired_speed;
|
||||
extern int desired_bits;
|
||||
|
||||
static void paint_audio(void *unused, Uint8 *stream, int len)
|
||||
{
|
||||
if ( shm ) {
|
||||
shm->buffer = stream;
|
||||
shm->samplepos += len/(shm->samplebits/8)/2;
|
||||
// Check for samplepos overflow?
|
||||
S_PaintChannels (shm->samplepos);
|
||||
}
|
||||
}
|
||||
|
||||
qboolean SNDDMA_Init(void)
|
||||
{
|
||||
SDL_AudioSpec desired, obtained;
|
||||
|
||||
snd_inited = 0;
|
||||
|
||||
/* Set up the desired format */
|
||||
desired.freq = desired_speed;
|
||||
switch (desired_bits) {
|
||||
case 8:
|
||||
desired.format = AUDIO_U8;
|
||||
break;
|
||||
case 16:
|
||||
desired.format = AUDIO_S16LSB;
|
||||
break;
|
||||
default:
|
||||
Con_Printf("Unknown number of audio bits: %d\n",
|
||||
desired_bits);
|
||||
return 0;
|
||||
}
|
||||
desired.channels = 2;
|
||||
desired.samples = 512;
|
||||
desired.callback = paint_audio;
|
||||
|
||||
/* Open the audio device */
|
||||
if ( SDL_OpenAudio(&desired, &obtained) < 0 ) {
|
||||
Con_Printf("Couldn't open SDL audio: %s\n", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Make sure we can support the audio format */
|
||||
switch (obtained.format) {
|
||||
case AUDIO_U8:
|
||||
/* Supported */
|
||||
break;
|
||||
case AUDIO_S16LSB:
|
||||
case AUDIO_S16MSB:
|
||||
/* Supported */
|
||||
break;
|
||||
/* Unsupported, fall through */;
|
||||
default:
|
||||
/* Not supported -- force SDL to do our bidding */
|
||||
SDL_CloseAudio();
|
||||
if ( SDL_OpenAudio(&desired, NULL) < 0 ) {
|
||||
Con_Printf("Couldn't open SDL audio: %s\n",
|
||||
SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
memcpy(&obtained, &desired, sizeof(desired));
|
||||
break;
|
||||
}
|
||||
SDL_PauseAudio(0);
|
||||
|
||||
/* Fill the audio DMA information block */
|
||||
shm = &the_shm;
|
||||
shm->splitbuffer = 0;
|
||||
shm->samplebits = (obtained.format & 0xFF);
|
||||
shm->speed = obtained.freq;
|
||||
shm->channels = obtained.channels;
|
||||
shm->samples = obtained.samples*shm->channels;
|
||||
shm->samplepos = 0;
|
||||
shm->submission_chunk = 1;
|
||||
shm->buffer = NULL;
|
||||
|
||||
snd_inited = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SNDDMA_GetDMAPos(void)
|
||||
{
|
||||
return shm->samplepos;
|
||||
}
|
||||
|
||||
void SNDDMA_Shutdown(void)
|
||||
{
|
||||
if (snd_inited)
|
||||
{
|
||||
SDL_CloseAudio();
|
||||
snd_inited = 0;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue