3
* Ekiga -- A VoIP and Video-Conferencing application
4
* Copyright (C) 2000-2009 Damien Sandras <dsandras@seconix.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or (at
9
* your option) any later version. This program is distributed in the hope
10
* that it will be useful, but WITHOUT ANY WARRANTY; without even the
11
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18
* Ekiga is licensed under the GPL license and as a special exception, you
19
* have permission to link or otherwise combine this program with the
20
* programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
21
* applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
22
* programs, as long as you do follow the requirements of the GNU GPL for all
23
* the rest of the software thus combined.
28
* audiooutput-manager.h - description
29
* ------------------------------------------
30
* begin : written in 2008 by Matthias Schneider
31
* copyright : (c) 2008 by Matthias Schneider
32
* description : Declaration of the interface of an audiooutput manager
33
* implementation backend.
38
#ifndef __AUDIOOUTPUT_MANAGER_H__
39
#define __AUDIOOUTPUT_MANAGER_H__
42
#include <sigc++/sigc++.h>
44
#include "audiooutput-info.h"
50
* @addtogroup audiooutput
54
/** Generic implementation for the Ekiga::AudioOutputManager class.
56
* Each AudioOutputManager will represent a specific backend able to play back audio.
57
* Each AudioOutputManager will manage one or more devices.
58
* The AudioOutputCore will control the different managers and their devices.
60
class AudioOutputManager
67
AudioOutputManager () {}
71
virtual ~AudioOutputManager () {}
74
/*** API for audio output ***/
76
/** Get a list of all devices supported by the manager.
77
* Add it to the list of devices already collected by the core.
78
* @param devices a vector of device names to be filled by the manager.
80
virtual void get_devices (std::vector <AudioOutputDevice> & devices) = 0;
82
/** Set the current device.
83
* Must be called before opening the device.
84
* In case a different device of the same manager was opened before, it must be
85
* closed before setting the new device.
86
* @param prim whether to set the primary or secondary device.
87
* @param device the device to be used.
89
virtual bool set_device (AudioOutputPS ps, const AudioOutputDevice & device) = 0;
92
* The device must be opened before calling set_frame_data(), set_buffer_size() and set_volume().
93
* Requires the set_device() to be called before.
94
* Returns false if the device cannot be opened. Also sends a GUI callback to the main thread in that case.
95
* @param prim whether the device shall be opened as primary or secondary device.
96
* @param channels number of channels (1=mono, 2=stereo).
97
* @param samplerate the samplerate.
98
* @param bits_per_sample the number bits per sample.
99
* @return true if the opening succeeded. False if the device cannot be opened.
101
virtual bool open (AudioOutputPS ps, unsigned channels, unsigned samplerate, unsigned bits_per_sample) = 0;
103
/** Close the device.
105
virtual void close (AudioOutputPS /*ps*/) {};
107
/** Set the buffer size.
108
* The buffer size must be set before calling set_frame_data().
109
* Requires the device to be opened.
110
* @param prim whether buffers of the primary or secodnary device shall be set.
111
* @param buffer_size the size of each buffer in bytes.
112
* @param num_buffers the number of buffers.
114
virtual void set_buffer_size (AudioOutputPS /*ps*/, unsigned /*buffer_size*/, unsigned /*num_buffers*/) {};
116
/** Set one audio buffer.
117
* Requires the device to be opened and the buffer size to be set.
118
* Returns false if writing the device fails. Also sends a GUI callback to the main thread in that case.
119
* @param data a pointer to the buffer with the data to be written. It will not be freed.
120
* @param size the size of the buffer to be written.
121
* @param bytes_written returns the number of bytes actually written. Should be equal to size.
122
* @return false if the writing failed.
124
virtual bool set_frame_data (AudioOutputPS ps,
127
unsigned & bytes_written) = 0;
129
/** Set the volume level for the current device.
130
* Requires the device to be opened.
131
* @param prim wether the volume of the primary or secondary device shall be set.
132
* @param volume the new volume (0..255).
134
virtual void set_volume (AudioOutputPS /*ps*/, unsigned /* volume */ ) {};
136
/** Returns true if a specific device is supported by the manager.
137
* If the device specified by sink and device_name is supported by the manager, true
138
* is returned and an AudioOutputDevice structure filled with the respective details.
139
* @param sink the sink type of the device (e.g. alsa, oss, etc.).
140
* @param device_name the name of the device.
141
* @param device in case the device is supported by the manager, this structure will be filled with the device details.
142
* @return true if the device is supported by the manager.
144
virtual bool has_device (const std::string & sink, const std::string & device_name, AudioOutputDevice & device) = 0;
147
/*** API to act on AudioOutputDevice events ***/
149
/** This signal is emitted when an audio output device is opened.
150
* @param prim whether the primary or secondary audio output device was opened.
151
* @param device the audio output device that was opened.
152
* @param config the current audio output device configuration (current volume, etc.).
154
sigc::signal3<void, AudioOutputPS, AudioOutputDevice, AudioOutputSettings> device_opened;
156
/** This signal is emitted when an audio output device is closed.
157
* @param prim whether the primary or secondary audio output device was closed.
158
* @param device the audio output device that was closed.
160
sigc::signal2<void, AudioOutputPS, AudioOutputDevice> device_closed;
162
/** This signal is emitted when an error occurs when opening an audio output device.
163
* @param prim whether the primary or secondary audio output device caused the error.
164
* @param device the audio output device that caused the error.
165
* @param error_code the audio output device error code.
167
sigc::signal3<void, AudioOutputPS, AudioOutputDevice, AudioOutputErrorCodes> device_error;
170
typedef struct ManagerState {
174
unsigned bits_per_sample;
175
AudioOutputDevice device;
178
ManagerState current_state[2];