2 /// Provides a sample queue encapsulation
6 // Copyright (C) 2010 Erik Hofman <erik@ehofman.com>
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
23 #define _SG_QUEUE_HXX 1
28 #include <simgear/compiler.h>
29 #include <simgear/structure/SGReferenced.hxx>
30 #include <simgear/structure/SGSharedPtr.hxx>
32 #include "sample_openal.hxx"
35 * manages everything we need to know for an individual audio sample
38 class SGSampleQueue : public SGSoundSample {
43 * Empty constructor, can be used to read data to the systems
44 * memory and not to the driver.
45 * @param freq sample frequentie of the samples
46 * @param format OpenAL format id of the data
48 SGSampleQueue(int freq, int format = AL_FORMAT_MONO8);
56 * Schedule this audio sample to stop playing.
61 * Queue new data for this audio sample.
63 * @param data Pointer to a memory block containg this audio sample data.
64 * @param len Length of the sample buffer in bytes.
66 void add( const void* data, size_t len );
69 * Set the source id of this source.
71 * @param sid OpenAL source-id
73 virtual void set_source(unsigned int sid);
76 * Test if the buffer-id of this audio sample may be passed to OpenAL.
78 * @return false for sample queue
80 inline bool is_valid_buffer() const { return false; }
82 inline virtual bool is_queue() const { return true; }
85 std::string _refname; // sample name
86 std::vector<unsigned int> _buffers;
90 std::string random_string();
94 #endif // _SG_QUEUE_HXX