1
/**************************************************************************
2
Lightspark, a free flash player implementation
4
Copyright (C) 2009,2010 Alessandro Pignotti (a.pignotti@sssup.it)
6
This program is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Lesser General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
**************************************************************************/
20
#ifndef OPENALPLUGIN_H
21
#define OPENALPLUGIN_H
25
#include "../IAudioPlugin.h"
26
#include "../../../decoder.h"
27
#include "../../../../compat.h"
36
class OpenALPlugin : public IAudioPlugin
40
ALCdevice *playbackDevice;
41
ALCdevice *captureDevice;
42
ALuint pbBuffers[NUM_BUFFERS];
43
ALuint pbSources[NUM_SOURCES];
44
void initPlayback ( OpenALPlugin *th );
45
void initCapture ( OpenALPlugin *th );
46
static void contextStatusCB ( pa_context *context, OpenALPlugin *th );
47
static void streamStatusCB ( pa_stream *stream, AudioStream *th );
48
static void streamWriteCB ( pa_stream *stream, size_t nbytes, AudioStream *th );
49
void addDeviceToList ( vector<string *> *devicesList, string *deviceName );
50
void generateDevicesList ( vector<string *> *devicesList, DEVICE_TYPES desiredType ); //To populate the devices lists, devicesType must be playback or capture
52
vector<AudioStream*> streams;
54
OpenALPlugin ( PLUGIN_TYPES init_Type = AUDIO, string init_Name = "OpenAL plugin",
55
string init_audiobackend = "openal", bool init_contextReady = false,
56
bool init_noServer = false, bool init_stopped = false );
57
void set_device ( string desiredDevice, DEVICE_TYPES desiredType );
58
uint32_t createStream ( lightspark::AudioDecoder *decoder );
59
void freeStream ( uint32_t id );
60
void fill ( uint32_t id );
62
uint32_t getPlayedTime ( uint32_t streamId );
69
enum STREAM_STATUS { STREAM_STARTING = 0, STREAM_READY = 1, STREAM_DEAD = 2 };
71
lightspark::AudioDecoder *decoder;
72
OpenALPlugin *manager;
73
volatile STREAM_STATUS streamStatus;
74
AudioStream ( OpenALPlugin *m ) : stream ( NULL ), decoder ( NULL ), manager ( m ), streamStatus ( STREAM_STARTING ) {}