4 * ***** BEGIN LGPL LICENSE BLOCK *****
6 * Copyright 2009 Jörg Hermann Müller
8 * This file is part of AudaSpace.
10 * AudaSpace is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * AudaSpace is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
23 * ***** END LGPL LICENSE BLOCK *****
26 #ifndef AUD_SOFTWAREDEVICE
27 #define AUD_SOFTWAREDEVICE
29 #include "AUD_IDevice.h"
30 struct AUD_SoftwareHandle;
38 * This device plays is a generic device with software mixing.
39 * Classes implementing this have to:
40 * - Implement the playing function.
41 * - Prepare the m_specs, m_mixer variables.
42 * - Call the create and destroy functions.
43 * - Call the mix function to retrieve their audio data.
45 class AUD_SoftwareDevice : public AUD_IDevice
49 * The specification of the device.
51 AUD_DeviceSpecs m_specs;
59 * Initializes member variables.
64 * Uninitializes member variables.
69 * Mixes the next samples into the buffer.
70 * \param buffer The target buffer.
71 * \param length The length in samples to be filled.
73 void mix(data_t* buffer, int length);
76 * This function tells the device, to start or pause playback.
77 * \param playing True if device should playback.
79 virtual void playing(bool playing)=0;
83 * The list of sounds that are currently playing.
85 std::list<AUD_SoftwareHandle*> m_playingSounds;
88 * The list of sounds that are currently paused.
90 std::list<AUD_SoftwareHandle*> m_pausedSounds;
93 * Whether there is currently playback.
98 * The mutex for locking.
100 pthread_mutex_t m_mutex;
103 * The overall volume of the device.
108 * Checks if a handle is valid.
109 * \param handle The handle to check.
110 * \return Whether the handle is valid.
112 bool isValid(AUD_Handle* handle);
115 virtual AUD_DeviceSpecs getSpecs() const;
116 virtual AUD_Handle* play(AUD_IFactory* factory, bool keep = false);
117 virtual bool pause(AUD_Handle* handle);
118 virtual bool resume(AUD_Handle* handle);
119 virtual bool stop(AUD_Handle* handle);
120 virtual bool getKeep(AUD_Handle* handle);
121 virtual bool setKeep(AUD_Handle* handle, bool keep);
122 virtual bool seek(AUD_Handle* handle, float position);
123 virtual float getPosition(AUD_Handle* handle);
124 virtual AUD_Status getStatus(AUD_Handle* handle);
126 virtual void unlock();
127 virtual float getVolume() const;
128 virtual void setVolume(float volume);
129 virtual float getVolume(AUD_Handle* handle);
130 virtual bool setVolume(AUD_Handle* handle, float volume);
131 virtual float getPitch(AUD_Handle* handle);
132 virtual bool setPitch(AUD_Handle* handle, float pitch);
133 virtual int getLoopCount(AUD_Handle* handle);
134 virtual bool setLoopCount(AUD_Handle* handle, int count);
137 #endif //AUD_SOFTWAREDEVICE