2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2009-07-06 02:10:26 +00:00
|
|
|
|
|
|
|
// 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, version 2.0.
|
|
|
|
|
|
|
|
// 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 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
#ifndef _OPENALSTREAM_H_
|
|
|
|
#define _OPENALSTREAM_H_
|
|
|
|
|
2010-06-26 13:11:34 +00:00
|
|
|
#include "Common.h"
|
2009-07-06 02:10:26 +00:00
|
|
|
#include "SoundStream.h"
|
|
|
|
#include "Thread.h"
|
|
|
|
|
|
|
|
#if defined HAVE_OPENAL && HAVE_OPENAL
|
|
|
|
#ifdef _WIN32
|
2013-01-09 20:43:59 +00:00
|
|
|
#include <OpenAL/include/al.h>
|
|
|
|
#include <OpenAL/include/alc.h>
|
2013-01-11 03:03:09 +00:00
|
|
|
#include <OpenAL/include/alext.h>
|
2011-02-08 12:35:43 +00:00
|
|
|
#elif defined __APPLE__
|
|
|
|
#include <OpenAL/al.h>
|
|
|
|
#include <OpenAL/alc.h>
|
2010-07-22 03:29:35 +00:00
|
|
|
#else
|
2010-01-31 23:46:50 +00:00
|
|
|
#include <AL/al.h>
|
|
|
|
#include <AL/alc.h>
|
2013-01-11 03:03:09 +00:00
|
|
|
#include <AL/alext.h>
|
2010-06-01 22:23:16 +00:00
|
|
|
#endif
|
|
|
|
|
2013-01-09 16:26:12 +00:00
|
|
|
#include "Core.h"
|
|
|
|
#include "HW/SystemTimers.h"
|
|
|
|
#include "HW/AudioInterface.h"
|
|
|
|
#include <soundtouch/SoundTouch.h>
|
|
|
|
#include <soundtouch/STTypes.h>
|
2013-01-09 11:57:32 +00:00
|
|
|
|
2009-12-23 15:34:14 +00:00
|
|
|
// 16 bit Stereo
|
2009-12-20 02:23:26 +00:00
|
|
|
#define SFX_MAX_SOURCE 1
|
2013-01-12 13:05:30 +00:00
|
|
|
#define OAL_MAX_BUFFERS 32
|
|
|
|
#define OAL_MAX_SAMPLES 256
|
2013-01-11 03:03:09 +00:00
|
|
|
#define SURROUND_CHANNELS 6 // number of channels in surround mode
|
|
|
|
#define SIZE_FLOAT 4 // size of a float in bytes
|
2009-07-06 02:10:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
class OpenALStream: public SoundStream
|
|
|
|
{
|
|
|
|
#if defined HAVE_OPENAL && HAVE_OPENAL
|
|
|
|
public:
|
2009-12-20 13:54:14 +00:00
|
|
|
OpenALStream(CMixer *mixer, void *hWnd = NULL)
|
|
|
|
: SoundStream(mixer)
|
|
|
|
, uiSource(0)
|
|
|
|
{};
|
|
|
|
|
2009-07-06 02:10:26 +00:00
|
|
|
virtual ~OpenALStream() {};
|
|
|
|
|
|
|
|
virtual bool Start();
|
|
|
|
virtual void SoundLoop();
|
2009-12-20 13:54:14 +00:00
|
|
|
virtual void SetVolume(int volume);
|
2009-07-06 02:10:26 +00:00
|
|
|
virtual void Stop();
|
2009-12-13 11:51:29 +00:00
|
|
|
virtual void Clear(bool mute);
|
2009-07-06 02:10:26 +00:00
|
|
|
static bool isValid() { return true; }
|
|
|
|
virtual bool usesMixer() const { return true; }
|
|
|
|
virtual void Update();
|
|
|
|
|
|
|
|
private:
|
2011-01-27 20:47:58 +00:00
|
|
|
std::thread thread;
|
2011-03-05 06:11:26 +00:00
|
|
|
Common::Event soundSyncEvent;
|
2013-01-09 11:57:32 +00:00
|
|
|
|
2009-12-23 15:34:14 +00:00
|
|
|
short realtimeBuffer[OAL_MAX_SAMPLES * 2];
|
2013-01-12 13:05:30 +00:00
|
|
|
soundtouch::SAMPLETYPE sampleBuffer[OAL_MAX_SAMPLES * SIZE_FLOAT * SURROUND_CHANNELS * OAL_MAX_BUFFERS];
|
|
|
|
ALuint uiBuffers[OAL_MAX_BUFFERS];
|
2009-12-20 02:23:26 +00:00
|
|
|
ALuint uiSource;
|
2009-12-20 13:54:14 +00:00
|
|
|
ALfloat fVolume;
|
2013-01-12 13:05:30 +00:00
|
|
|
|
|
|
|
u8 numBuffers;
|
2009-07-06 02:10:26 +00:00
|
|
|
#else
|
|
|
|
public:
|
|
|
|
OpenALStream(CMixer *mixer, void *hWnd = NULL): SoundStream(mixer) {}
|
|
|
|
#endif // HAVE_OPENAL
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // OPENALSTREAM
|