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;
37 * This device plays is a generic device with software mixing.
38 * Classes implementing this have to:
39 * - Implement the playing function.
40 * - Prepare the m_specs, m_mixer variables.
41 * - Call the create and destroy functions.
42 * - Call the mix function to retrieve their audio data.
44 class AUD_SoftwareDevice : public AUD_IDevice
48 * The specification of the device.
50 AUD_DeviceSpecs m_specs;
58 * Initializes member variables.
63 * Uninitializes member variables.
68 * Mixes the next samples into the buffer.
69 * \param buffer The target buffer.
70 * \param length The length in samples to be filled.
72 void mix(data_t* buffer, int length);
75 * This function tells the device, to start or pause playback.
76 * \param playing True if device should playback.
78 virtual void playing(bool playing)=0;
82 * The list of sounds that are currently playing.
84 std::list<AUD_SoftwareHandle*>* m_playingSounds;
87 * The list of sounds that are currently paused.
89 std::list<AUD_SoftwareHandle*>* m_pausedSounds;
92 * Whether there is currently playback.
97 * The mutex for locking.
99 pthread_mutex_t m_mutex;
102 * The overall volume of the device.
107 * Checks if a handle is valid.
108 * \param handle The handle to check.
109 * \return Whether the handle is valid.
111 bool isValid(AUD_Handle* handle);
114 virtual AUD_DeviceSpecs getSpecs() const;
115 virtual AUD_Handle* play(AUD_IFactory* factory, bool keep = false);
116 virtual bool pause(AUD_Handle* handle);
117 virtual bool resume(AUD_Handle* handle);
118 virtual bool stop(AUD_Handle* handle);
119 virtual bool getKeep(AUD_Handle* handle);
120 virtual bool setKeep(AUD_Handle* handle, bool keep);
121 virtual bool seek(AUD_Handle* handle, float position);
122 virtual float getPosition(AUD_Handle* handle);
123 virtual AUD_Status getStatus(AUD_Handle* handle);
125 virtual void unlock();
126 virtual float getVolume() const;
127 virtual void setVolume(float volume);
128 virtual float getVolume(AUD_Handle* handle);
129 virtual bool setVolume(AUD_Handle* handle, float volume);
130 virtual float getPitch(AUD_Handle* handle);
131 virtual bool setPitch(AUD_Handle* handle, float pitch);
134 #endif //AUD_SOFTWAREDEVICE