Tapping into OpenAL (WIP)
This commit is contained in:
parent
4365340dd9
commit
7f07775450
1 changed files with 20 additions and 16 deletions
|
@ -22,23 +22,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#ifdef DUMB
|
||||
#include "globaldef.h"
|
||||
#include "dumb.h"
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/wait.h>
|
||||
#include <linux/soundcard.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
|
||||
// eukara - added in tracker playback using DUMB - UNIX ONLY!
|
||||
char name[256];
|
||||
DUH *trackmod; // The music file ~eukara
|
||||
DUH_SIGRENDERER *sr; // The DUMB renderer
|
||||
int oss_device; // output device (by default /dev/dsp for OSS)
|
||||
ALCdevice *oss_device;
|
||||
ALuint oss_source;
|
||||
ALuint oss_buffer;
|
||||
static qboolean bTracker_Initialized = false;
|
||||
|
||||
// Set up the renderer options
|
||||
|
@ -63,6 +56,14 @@ void Tracker_Play(byte track, qboolean looping)
|
|||
if(bTracker_Initialized == false)
|
||||
return;
|
||||
|
||||
alGenSources((ALuint)1, &oss_source);
|
||||
alSourcef(oss_source, AL_PITCH, 1);
|
||||
alSourcef(oss_source, AL_GAIN, 1);
|
||||
alSource3f(oss_source, AL_POSITION, 0, 0, 0);
|
||||
alSource3f(oss_source, AL_VELOCITY, 0, 0, 0);
|
||||
alSourcei(oss_source, AL_LOOPING, AL_FALSE);
|
||||
alGenBuffers((ALuint)1, &oss_buffer);
|
||||
|
||||
dumb_register_stdfiles(); // Initialize loading files
|
||||
|
||||
// Attempt to load every format imaginable, TODO: better method?
|
||||
|
@ -200,8 +201,9 @@ void Tracker_Update(void)
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Write this into the engine's soundbuffer instead for speed!
|
||||
write (oss_device, &tracker_buffer, 4096);
|
||||
alBufferData(oss_buffer, AL_FORMAT_STEREO16, &tracker_buffer.s8, 4096, freq);
|
||||
alSourceQueueBuffers(oss_source, 1, &oss_buffer);
|
||||
alSourcePlay(oss_source);
|
||||
}
|
||||
|
||||
int Tracker_Init(void)
|
||||
|
@ -209,7 +211,9 @@ int Tracker_Init(void)
|
|||
if (COM_CheckParm("-notracker"))
|
||||
return -1;
|
||||
|
||||
if((oss_device = open ("/dev/dsp", O_RDWR)) == -1){ // /dev/dsp is the standard OSS output
|
||||
oss_device = alcOpenDevice(NULL);
|
||||
if (!oss_device)
|
||||
{
|
||||
perror("/dev/dsp");
|
||||
return 0; // just get out if there's none
|
||||
}
|
||||
|
@ -224,6 +228,6 @@ void Tracker_Shutdown(void)
|
|||
{
|
||||
Tracker_Stop(); // First stop the track
|
||||
dumb_exit(); // Kill DUMB
|
||||
close(oss_device); // Close the device
|
||||
alcCloseDevice(oss_device);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue