SDL works a bit better now
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@768 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
0ce5b03f32
commit
b192d3a175
7 changed files with 549 additions and 29 deletions
|
@ -15,8 +15,14 @@ int snd_firsttime = 0;
|
|||
|
||||
int aimedforguid;
|
||||
|
||||
//lamocodec.
|
||||
static char buffer[SOUND_BUFFER_SIZE];
|
||||
int sndpos;
|
||||
|
||||
void SNDDMA_Submit(soundcardinfo_t *sc)
|
||||
{
|
||||
{ //We already wrote it into the 'dma' buffer (heh, the closest we can get to it at least)
|
||||
//so we now wait for sdl to request it.
|
||||
//yes, this can result in slow sound.
|
||||
}
|
||||
void SNDDMA_Shutdown(soundcardinfo_t *sc)
|
||||
{
|
||||
|
@ -28,7 +34,22 @@ void SNDDMA_Shutdown(soundcardinfo_t *sc)
|
|||
}
|
||||
int SNDDMA_GetDMAPos(soundcardinfo_t *sc)
|
||||
{
|
||||
return 0;
|
||||
sc->sn.samplepos = (sndpos / (sc->sn.samplebits/8)) % sc->sn.samples;
|
||||
return sc->sn.samplepos;
|
||||
}
|
||||
|
||||
void SNDDMA_Paint(void *userdata, qbyte *stream, int len)
|
||||
{
|
||||
if (len > SOUND_BUFFER_SIZE)
|
||||
len = SOUND_BUFFER_SIZE; //whoa nellie!
|
||||
if (len > SOUND_BUFFER_SIZE - sndpos)
|
||||
{ //buffer will wrap, fill in the rest
|
||||
memcpy(stream, buffer + sndpos, SOUND_BUFFER_SIZE - sndpos);
|
||||
len -= SOUND_BUFFER_SIZE - sndpos;
|
||||
sndpos = 0;
|
||||
} //and finish from the start
|
||||
memcpy(stream, buffer + sndpos, len);
|
||||
sndpos += len;
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,13 +60,17 @@ void S_UpdateCapture(void) //any ideas how to get microphone input?
|
|||
int SNDDMA_Init(soundcardinfo_t *sc)
|
||||
{
|
||||
SDL_AudioSpec desired, obtained;
|
||||
|
||||
MessageBox(NULL, "hello", "fnar", 0);
|
||||
|
||||
if (snd_inited)
|
||||
{ //our init code actually calls this function multiple times, in the case that the user has multiple sound cards
|
||||
// Con_Printf("Sound was already inited\n");
|
||||
return 2; //erm. SDL won't allow multiple sound cards anyway.
|
||||
}
|
||||
|
||||
Con_Printf("SDL AUDIO INITING\n");
|
||||
if(SDL_InitSubSystem(SDL_INIT_AUDIO))
|
||||
{
|
||||
Con_Print("Couldn't initialize SDL audio subsystem\n");
|
||||
MessageBox(NULL, "hjkl", "fnar", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -67,20 +92,27 @@ int SNDDMA_Init(soundcardinfo_t *sc)
|
|||
desired.channels = 2;
|
||||
desired.samples = SOUND_BUFFER_SIZE;
|
||||
desired.format = AUDIO_S16;
|
||||
desired.callback = paint;
|
||||
|
||||
desired.callback = SNDDMA_Paint;
|
||||
desired.userdata = sc;
|
||||
|
||||
|
||||
if ( SDL_OpenAudio(&desired, &obtained) < 0 )
|
||||
{
|
||||
Con_Printf("SDL: SNDDMA_Init: couldn't open sound device (%s).\n", SDL_GetError());
|
||||
MessageBox(NULL, "hello", "fghjfghjfgfnar", 0);
|
||||
return false;
|
||||
}
|
||||
sc->sn.numchannels = obtained.channels;
|
||||
sc->sn.speed = desired.freq;
|
||||
sc->sn.samplebits = 16;
|
||||
sc->sn.samples = SOUND_BUFFER_SIZE;
|
||||
sc->sn.buffer = buffer;
|
||||
Con_Printf("Got sound %i-%i\n", obtained.freq, obtained.format);
|
||||
snd_inited = true;
|
||||
SDL_PauseAudio(0);
|
||||
MessageBox(NULL, "he;'lk'khjllo", "fnghkfghar", 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SNDDMA_SetUnderWater(qboolean underwater)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue