]> git.mxchange.org Git - simgear.git/blob - simgear/sound/sample_queue.hxx
Remove support for stereo sounds
[simgear.git] / simgear / sound / sample_queue.hxx
1 ///@file
2 /// Provides a sample queue encapsulation
3 //
4 // based on sample.hxx
5 // 
6 // Copyright (C) 2010 Erik Hofman <erik@ehofman.com>
7 //
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.
12 //
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.
17 //
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.
21
22 #ifndef _SG_QUEUE_HXX
23 #define _SG_QUEUE_HXX 1
24
25 #include <string>
26 #include <vector>
27
28 #include <simgear/compiler.h>
29 #include <simgear/structure/SGReferenced.hxx>
30 #include <simgear/structure/SGSharedPtr.hxx>
31
32 #include "sample_openal.hxx"
33
34 /**
35  * manages everything we need to know for an individual audio sample
36  */
37
38 class SGSampleQueue : public SGSoundSample {
39 public:
40
41
42      /**
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
47       */
48     SGSampleQueue(int freq, int format = SG_SAMPLE_MONO8);
49
50     /**
51      * Destructor
52      */
53     ~SGSampleQueue ();
54
55     /**
56      * Schedule this audio sample to stop playing.
57      */
58     virtual void stop();
59
60     /**
61      * Queue new data for this audio sample.
62      *
63      * @param data  Pointer to a memory block containg this audio sample data.
64      * @param len   Length of the sample buffer in bytes.
65      */
66     void add( const void* data, size_t len );
67
68     /**
69      * Set the source id of this source.
70      *
71      * @param sid OpenAL source-id
72      */
73     virtual void set_source(unsigned int sid);
74
75     /**
76      * Test if the buffer-id of this audio sample may be passed to OpenAL.
77      *
78      * @return false for sample queue
79      */
80     inline bool is_valid_buffer() const { return false; }
81
82     inline virtual bool is_queue() const { return true; }
83
84 private:
85     std::string _refname;       // sample name
86     std::vector<unsigned int> _buffers;
87
88     bool _playing;
89
90     std::string random_string();
91 };
92
93
94 #endif // _SG_QUEUE_HXX
95
96