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
|
#ifdef DUMB
|
||||||
#include "globaldef.h"
|
#include "globaldef.h"
|
||||||
#include "dumb.h"
|
#include "dumb.h"
|
||||||
#include <unistd.h>
|
#include <AL/al.h>
|
||||||
#include <fcntl.h>
|
#include <AL/alc.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>
|
|
||||||
|
|
||||||
// eukara - added in tracker playback using DUMB - UNIX ONLY!
|
// eukara - added in tracker playback using DUMB - UNIX ONLY!
|
||||||
char name[256];
|
char name[256];
|
||||||
DUH *trackmod; // The music file ~eukara
|
DUH *trackmod; // The music file ~eukara
|
||||||
DUH_SIGRENDERER *sr; // The DUMB renderer
|
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;
|
static qboolean bTracker_Initialized = false;
|
||||||
|
|
||||||
// Set up the renderer options
|
// Set up the renderer options
|
||||||
|
@ -63,6 +56,14 @@ void Tracker_Play(byte track, qboolean looping)
|
||||||
if(bTracker_Initialized == false)
|
if(bTracker_Initialized == false)
|
||||||
return;
|
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
|
dumb_register_stdfiles(); // Initialize loading files
|
||||||
|
|
||||||
// Attempt to load every format imaginable, TODO: better method?
|
// 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!
|
alBufferData(oss_buffer, AL_FORMAT_STEREO16, &tracker_buffer.s8, 4096, freq);
|
||||||
write (oss_device, &tracker_buffer, 4096);
|
alSourceQueueBuffers(oss_source, 1, &oss_buffer);
|
||||||
|
alSourcePlay(oss_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Tracker_Init(void)
|
int Tracker_Init(void)
|
||||||
|
@ -209,7 +211,9 @@ int Tracker_Init(void)
|
||||||
if (COM_CheckParm("-notracker"))
|
if (COM_CheckParm("-notracker"))
|
||||||
return -1;
|
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");
|
perror("/dev/dsp");
|
||||||
return 0; // just get out if there's none
|
return 0; // just get out if there's none
|
||||||
}
|
}
|
||||||
|
@ -224,6 +228,6 @@ void Tracker_Shutdown(void)
|
||||||
{
|
{
|
||||||
Tracker_Stop(); // First stop the track
|
Tracker_Stop(); // First stop the track
|
||||||
dumb_exit(); // Kill DUMB
|
dumb_exit(); // Kill DUMB
|
||||||
close(oss_device); // Close the device
|
alcCloseDevice(oss_device);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue