mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-23 10:52:38 +01:00
Set up OpenAL buffers etc for MADStream
This commit is contained in:
parent
62243b0382
commit
b539b09975
@ -11,6 +11,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <rw/defines.hpp>
|
#include <rw/defines.hpp>
|
||||||
|
#include <AL/al.h>
|
||||||
|
#include <AL/alc.h>
|
||||||
|
#include "audio/alCheck.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -25,6 +28,10 @@ class MADStream : public sf::SoundStream
|
|||||||
unsigned int mReadProgress;
|
unsigned int mReadProgress;
|
||||||
std::vector<int16_t> mCurrentSamples;
|
std::vector<int16_t> mCurrentSamples;
|
||||||
|
|
||||||
|
constexpr static size_t numALbuffers = 8;
|
||||||
|
ALuint buffers[numALbuffers];
|
||||||
|
ALuint alSource;
|
||||||
|
|
||||||
static inline signed int scale(mad_fixed_t sample);
|
static inline signed int scale(mad_fixed_t sample);
|
||||||
static mad_flow ms_header(void* user, mad_header const* header);
|
static mad_flow ms_header(void* user, mad_header const* header);
|
||||||
static mad_flow ms_input(void* user, mad_stream* stream);
|
static mad_flow ms_input(void* user, mad_stream* stream);
|
||||||
|
@ -94,7 +94,8 @@ void MADStream::onSeek(sf::Time timeOffset)
|
|||||||
MADStream::MADStream()
|
MADStream::MADStream()
|
||||||
: mFdm(nullptr)
|
: mFdm(nullptr)
|
||||||
{
|
{
|
||||||
|
alCheck(alGenBuffers(numALbuffers, buffers));
|
||||||
|
alCheck(alGenSources(1, &alSource));
|
||||||
}
|
}
|
||||||
|
|
||||||
MADStream::~MADStream()
|
MADStream::~MADStream()
|
||||||
@ -136,5 +137,11 @@ bool MADStream::openFromFile(const std::string& loc)
|
|||||||
|
|
||||||
this->initialize(2, mMadSampleRate);
|
this->initialize(2, mMadSampleRate);
|
||||||
|
|
||||||
|
alCheck(alSourcef(alSource, AL_PITCH, 1));
|
||||||
|
alCheck(alSourcef(alSource, AL_GAIN, 1));
|
||||||
|
alCheck(alSource3f(alSource, AL_POSITION, 0, 0, 0));
|
||||||
|
alCheck(alSource3f(alSource, AL_VELOCITY, 0, 0, 0));
|
||||||
|
alCheck(alSourcei(alSource, AL_LOOPING, AL_FALSE));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user