2
* Ekiga -- A VoIP and Video-Conferencing application
3
* Copyright (C) 2000-2009 Damien Sandras <dsandras@seconix.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or (at
8
* your option) any later version. This program is distributed in the hope
9
* that it will be useful, but WITHOUT ANY WARRANTY; without even the
10
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
* See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17
* Ekiga is licensed under the GPL license and as a special exception, you
18
* have permission to link or otherwise combine this program with the
19
* programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
20
* applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
21
* programs, as long as you do follow the requirements of the GNU GPL for all
22
* the rest of the software thus combined.
27
* audioinput-manager-null.cpp - description
28
* ------------------------------------------
29
* begin : written in 2008 by Matthias Schneider
30
* copyright : (c) 2008 by Matthias Schneider
31
* description : declaration of a NULL audio input manager
35
#include "audioinput-manager-null.h"
37
#define DEVICE_TYPE "Ekiga"
38
#define DEVICE_SOURCE "Ekiga"
39
#define DEVICE_NAME "SILENT"
42
GMAudioInputManager_null::GMAudioInputManager_null (Ekiga::ServiceCore & _core)
45
gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
46
smart->reference (); // take a reference in the main thread
48
current_state.opened = false;
51
GMAudioInputManager_null::~GMAudioInputManager_null ()
53
runtime->unreference (); // leave a reference in the main thread
56
void GMAudioInputManager_null::get_devices(std::vector <Ekiga::AudioInputDevice> & devices)
58
Ekiga::AudioInputDevice device;
59
device.type = DEVICE_TYPE;
60
device.source = DEVICE_SOURCE;
61
device.name = DEVICE_NAME;
62
devices.push_back(device);
65
bool GMAudioInputManager_null::set_device (const Ekiga::AudioInputDevice & device)
67
if ( ( device.type == DEVICE_TYPE ) &&
68
( device.source == DEVICE_SOURCE) &&
69
( device.name == DEVICE_NAME) ) {
71
PTRACE(4, "GMAudioInputManager_null\tSetting Device " << device);
72
current_state.device = device;
78
bool GMAudioInputManager_null::open (unsigned channels, unsigned samplerate, unsigned bits_per_sample)
80
PTRACE(4, "GMAudioInputManager_null\tOpening Device " << current_state.device);
81
PTRACE(4, "GMAudioInputManager_null\tOpening Device with " << channels << "-" << samplerate << "/" << bits_per_sample);
83
current_state.channels = channels;
84
current_state.samplerate = samplerate;
85
current_state.bits_per_sample = bits_per_sample;
86
current_state.opened = true;
88
adaptive_delay.Restart();
90
Ekiga::AudioInputSettings settings;
92
settings.modifyable = false;
93
runtime->run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
98
void GMAudioInputManager_null::close()
100
current_state.opened = false;
101
runtime->run_in_main (sigc::bind (device_closed.make_slot (), current_state.device));
105
bool GMAudioInputManager_null::get_frame_data (char *data,
106
unsigned size, unsigned & bytes_read)
108
if (!current_state.opened) {
109
PTRACE(1, "GMAudioInputManager_null\tTrying to get frame from closed device");
113
memset (data, 0, size);
117
adaptive_delay.Delay(size * 8 / current_state.bits_per_sample * 1000 / current_state.samplerate);
122
bool GMAudioInputManager_null::has_device(const std::string & /*source*/, const std::string & /*device_name*/, Ekiga::AudioInputDevice & /*device*/)