~ubuntu-branches/ubuntu/vivid/ekiga/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/engine/components/null-audiooutput/audiooutput-manager-null.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kilian Krause
  • Date: 2011-07-17 00:24:50 UTC
  • mfrom: (5.1.5 upstream) (7.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110717002450-ytg3wsrc1ptd3153
Tags: 3.3.1-1
* New upstream release.
 - Required libpt-dev 2.10 and libopal-dev 3.10
* Fix debian/watch to catch new version
* Remove libnotify0.7.patch - included upstream
* Add libboost-dev and libboost-signals-dev to Build-Depends
* debian/rules: Don't install *.la files for new internal shared libs
* Fix Vcs URIs to point to correct desktop/experimental/ekiga tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Ekiga -- A VoIP and Video-Conferencing application
 
3
 * Copyright (C) 2000-2009 Damien Sandras <dsandras@seconix.com>
 
4
 
 
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.
 
12
 *
 
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.
 
16
 *
 
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.
 
23
 */
 
24
 
 
25
 
 
26
/*
 
27
 *                         audiooutput-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 output manager
 
32
 *
 
33
 */
 
34
 
 
35
#include "audiooutput-manager-null.h"
 
36
 
 
37
#define DEVICE_TYPE   "Ekiga"
 
38
#define DEVICE_SOURCE "Ekiga"
 
39
#define DEVICE_NAME   "SILENT"
 
40
 
 
41
GMAudioOutputManager_null::GMAudioOutputManager_null (Ekiga::ServiceCore & _core)
 
42
: core (_core)
 
43
{
 
44
  current_state[Ekiga::primary].opened = false;
 
45
  current_state[Ekiga::secondary].opened = false;
 
46
}
 
47
 
 
48
GMAudioOutputManager_null::~GMAudioOutputManager_null ()
 
49
{
 
50
}
 
51
 
 
52
void GMAudioOutputManager_null::get_devices(std::vector <Ekiga::AudioOutputDevice> & devices)
 
53
{
 
54
#if DEBUG
 
55
  Ekiga::AudioOutputDevice device;
 
56
  device.type   = DEVICE_TYPE;
 
57
  device.source = DEVICE_SOURCE;
 
58
  device.name   = DEVICE_NAME;
 
59
  devices.push_back(device);
 
60
#endif
 
61
}
 
62
 
 
63
 
 
64
bool GMAudioOutputManager_null::set_device (Ekiga::AudioOutputPS ps, const Ekiga::AudioOutputDevice & device)
 
65
{
 
66
  if ( ( device.type   == DEVICE_TYPE ) &&
 
67
       ( device.source == DEVICE_SOURCE) &&
 
68
       ( device.name   == DEVICE_NAME) ) {
 
69
 
 
70
    PTRACE(4, "GMAudioOutputManager_null\tSetting Device[" << ps << "] " << device);
 
71
    current_state[ps].device = device;
 
72
    return true;
 
73
  }
 
74
  return false;
 
75
}
 
76
 
 
77
bool GMAudioOutputManager_null::open (Ekiga::AudioOutputPS ps, unsigned channels, unsigned samplerate, unsigned bits_per_sample)
 
78
{
 
79
  current_state[ps].channels        = channels;
 
80
  current_state[ps].samplerate      = samplerate;
 
81
  current_state[ps].bits_per_sample = bits_per_sample;
 
82
  current_state[ps].opened = true;
 
83
 
 
84
  PTRACE(4, "GMAudioOutputManager_null\tOpening Device[" << ps << "] " << current_state[ps].device);
 
85
  PTRACE(4, "GMAudioOutputManager_null\tOpening Device with " << channels << "-" << samplerate << "/" << bits_per_sample);
 
86
 
 
87
  adaptive_delay[ps].Restart();
 
88
 
 
89
  Ekiga::AudioOutputSettings settings;
 
90
  settings.volume = 0;
 
91
  settings.modifyable = false;
 
92
  Ekiga::Runtime::run_in_main (boost::bind (&GMAudioOutputManager_null::device_opened_in_main, this, ps, current_state[ps].device, settings));
 
93
 
 
94
  return true;
 
95
}
 
96
 
 
97
void GMAudioOutputManager_null::close(Ekiga::AudioOutputPS ps)
 
98
{
 
99
  current_state[ps].opened = false;
 
100
  Ekiga::Runtime::run_in_main (boost::bind (&GMAudioOutputManager_null::device_closed_in_main, this, ps, current_state[ps].device));
 
101
}
 
102
 
 
103
 
 
104
bool GMAudioOutputManager_null::set_frame_data (Ekiga::AudioOutputPS ps, 
 
105
                     const char */*data*/, 
 
106
                     unsigned size,
 
107
                     unsigned & bytes_written)
 
108
{
 
109
  if (!current_state[ps].opened) {
 
110
    PTRACE(1, "GMAudioOutputManager_null\tTrying to get frame from closed device[" << ps << "]");
 
111
    return true;
 
112
  }
 
113
 
 
114
  bytes_written = size;
 
115
 
 
116
  adaptive_delay[ps].Delay(size * 8 / current_state[ps].bits_per_sample * 1000 / current_state[ps].samplerate);
 
117
  return true;
 
118
}
 
119
 
 
120
bool GMAudioOutputManager_null::has_device(const std::string & /*sink*/, const std::string & /*device_name*/, Ekiga::AudioOutputDevice & /*device*/)
 
121
{
 
122
  return false;
 
123
}
 
124
 
 
125
void
 
126
GMAudioOutputManager_null::device_opened_in_main (Ekiga::AudioOutputPS ps,
 
127
                                                  Ekiga::AudioOutputDevice device,
 
128
                                                  Ekiga::AudioOutputSettings settings)
 
129
{
 
130
  device_opened (ps, device, settings);
 
131
}
 
132
 
 
133
void
 
134
GMAudioOutputManager_null::device_closed_in_main (Ekiga::AudioOutputPS ps,
 
135
                                                  Ekiga::AudioOutputDevice device)
 
136
{
 
137
  device_closed (ps, device);
 
138
}