~ubuntu-branches/debian/experimental/kopete/experimental

« back to all changes in this revision

Viewing changes to protocols/jabber/googletalk/libjingle/talk/sound/nullsoundsystem.cc

  • Committer: Package Import Robot
  • Author(s): Maximiliano Curia
  • Date: 2015-02-24 11:32:57 UTC
  • mfrom: (1.1.41 vivid)
  • Revision ID: package-import@ubuntu.com-20150224113257-gnupg4v7lzz18ij0
Tags: 4:14.12.2-1
* New upstream release (14.12.2).
* Bump Standards-Version to 3.9.6, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * libjingle
3
 
 * Copyright 2004--2010, Google Inc.
4
 
 *
5
 
 * Redistribution and use in source and binary forms, with or without
6
 
 * modification, are permitted provided that the following conditions are met:
7
 
 *
8
 
 *  1. Redistributions of source code must retain the above copyright notice,
9
 
 *     this list of conditions and the following disclaimer.
10
 
 *  2. Redistributions in binary form must reproduce the above copyright notice,
11
 
 *     this list of conditions and the following disclaimer in the documentation
12
 
 *     and/or other materials provided with the distribution.
13
 
 *  3. The name of the author may not be used to endorse or promote products
14
 
 *     derived from this software without specific prior written permission.
15
 
 *
16
 
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17
 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18
 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19
 
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22
 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23
 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24
 
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25
 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 
 */
27
 
 
28
 
#include "talk/sound/nullsoundsystem.h"
29
 
 
30
 
#include "talk/base/logging.h"
31
 
#include "talk/sound/sounddevicelocator.h"
32
 
#include "talk/sound/soundinputstreaminterface.h"
33
 
#include "talk/sound/soundoutputstreaminterface.h"
34
 
 
35
 
namespace talk_base {
36
 
 
37
 
class Thread;
38
 
 
39
 
}
40
 
 
41
 
namespace cricket {
42
 
 
43
 
// Name used for the single device and the sound system itself.
44
 
static const char kNullName[] = "null";
45
 
 
46
 
class NullSoundDeviceLocator : public SoundDeviceLocator {
47
 
 public:
48
 
  NullSoundDeviceLocator() : SoundDeviceLocator(kNullName, kNullName) {}
49
 
 
50
 
  virtual SoundDeviceLocator *Copy() const {
51
 
    return new NullSoundDeviceLocator();
52
 
  }
53
 
};
54
 
 
55
 
class NullSoundInputStream : public SoundInputStreamInterface {
56
 
 public:
57
 
  virtual bool StartReading() {
58
 
    return true;
59
 
  }
60
 
 
61
 
  virtual bool StopReading() {
62
 
    return true;
63
 
  }
64
 
 
65
 
  virtual bool GetVolume(int *volume) {
66
 
    *volume = SoundSystemInterface::kMinVolume;
67
 
    return true;
68
 
  }
69
 
 
70
 
  virtual bool SetVolume(int volume) {
71
 
    return false;
72
 
  }
73
 
 
74
 
  virtual bool Close() {
75
 
    return true;
76
 
  }
77
 
 
78
 
  virtual int LatencyUsecs() {
79
 
    return 0;
80
 
  }
81
 
};
82
 
 
83
 
class NullSoundOutputStream : public SoundOutputStreamInterface {
84
 
 public:
85
 
  virtual bool EnableBufferMonitoring() {
86
 
    return true;
87
 
  }
88
 
 
89
 
  virtual bool DisableBufferMonitoring() {
90
 
    return true;
91
 
  }
92
 
 
93
 
  virtual bool WriteSamples(const void *sample_data,
94
 
                            size_t size) {
95
 
    LOG(LS_VERBOSE) << "Got " << size << " bytes of playback samples";
96
 
    return true;
97
 
  }
98
 
 
99
 
  virtual bool GetVolume(int *volume) {
100
 
    *volume = SoundSystemInterface::kMinVolume;
101
 
    return true;
102
 
  }
103
 
 
104
 
  virtual bool SetVolume(int volume) {
105
 
    return false;
106
 
  }
107
 
 
108
 
  virtual bool Close() {
109
 
    return true;
110
 
  }
111
 
 
112
 
  virtual int LatencyUsecs() {
113
 
    return 0;
114
 
  }
115
 
};
116
 
 
117
 
NullSoundSystem::~NullSoundSystem() {
118
 
}
119
 
 
120
 
bool NullSoundSystem::Init() {
121
 
  return true;
122
 
}
123
 
 
124
 
void NullSoundSystem::Terminate() {
125
 
  // Nothing to do.
126
 
}
127
 
 
128
 
bool NullSoundSystem::EnumeratePlaybackDevices(
129
 
      SoundSystemInterface::SoundDeviceLocatorList *devices) {
130
 
  ClearSoundDeviceLocatorList(devices);
131
 
  SoundDeviceLocator *device;
132
 
  GetDefaultPlaybackDevice(&device);
133
 
  devices->push_back(device);
134
 
  return true;
135
 
}
136
 
 
137
 
bool NullSoundSystem::EnumerateCaptureDevices(
138
 
      SoundSystemInterface::SoundDeviceLocatorList *devices) {
139
 
  ClearSoundDeviceLocatorList(devices);
140
 
  SoundDeviceLocator *device;
141
 
  GetDefaultCaptureDevice(&device);
142
 
  devices->push_back(device);
143
 
  return true;
144
 
}
145
 
 
146
 
bool NullSoundSystem::GetDefaultPlaybackDevice(
147
 
    SoundDeviceLocator **device) {
148
 
  *device = new NullSoundDeviceLocator();
149
 
  return true;
150
 
}
151
 
 
152
 
bool NullSoundSystem::GetDefaultCaptureDevice(
153
 
    SoundDeviceLocator **device) {
154
 
  *device = new NullSoundDeviceLocator();
155
 
  return true;
156
 
}
157
 
 
158
 
SoundOutputStreamInterface *NullSoundSystem::OpenPlaybackDevice(
159
 
      const SoundDeviceLocator *device,
160
 
      const OpenParams &params) {
161
 
  return new NullSoundOutputStream();
162
 
}
163
 
 
164
 
SoundInputStreamInterface *NullSoundSystem::OpenCaptureDevice(
165
 
      const SoundDeviceLocator *device,
166
 
      const OpenParams &params) {
167
 
  return new NullSoundInputStream();
168
 
}
169
 
 
170
 
const char *NullSoundSystem::GetName() const {
171
 
  return kNullName;
172
 
}
173
 
 
174
 
}  // namespace cricket