OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2010 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/sound/pulseaudiosoundsystem.h" | 11 #include "webrtc/sound/pulseaudiosoundsystem.h" |
12 | 12 |
13 #ifdef HAVE_LIBPULSE | 13 #ifdef HAVE_LIBPULSE |
14 | 14 |
15 #include <algorithm> | 15 #include <algorithm> |
16 #include "webrtc/sound/sounddevicelocator.h" | 16 |
17 #include "webrtc/sound/soundinputstreaminterface.h" | 17 #include "webrtc/base/arraysize.h" |
18 #include "webrtc/sound/soundoutputstreaminterface.h" | |
19 #include "webrtc/base/common.h" | 18 #include "webrtc/base/common.h" |
20 #include "webrtc/base/fileutils.h" // for GetApplicationName() | 19 #include "webrtc/base/fileutils.h" // for GetApplicationName() |
21 #include "webrtc/base/logging.h" | 20 #include "webrtc/base/logging.h" |
22 #include "webrtc/base/timeutils.h" | 21 #include "webrtc/base/timeutils.h" |
23 #include "webrtc/base/worker.h" | 22 #include "webrtc/base/worker.h" |
| 23 #include "webrtc/sound/sounddevicelocator.h" |
| 24 #include "webrtc/sound/soundinputstreaminterface.h" |
| 25 #include "webrtc/sound/soundoutputstreaminterface.h" |
24 | 26 |
25 namespace rtc { | 27 namespace rtc { |
26 | 28 |
27 // First PulseAudio protocol version that supports PA_STREAM_ADJUST_LATENCY. | 29 // First PulseAudio protocol version that supports PA_STREAM_ADJUST_LATENCY. |
28 static const uint32_t kAdjustLatencyProtocolVersion = 13; | 30 static const uint32_t kAdjustLatencyProtocolVersion = 13; |
29 | 31 |
30 // Lookup table from the rtc format enum in soundsysteminterface.h to | 32 // Lookup table from the rtc format enum in soundsysteminterface.h to |
31 // Pulse's enums. | 33 // Pulse's enums. |
32 static const pa_sample_format_t kCricketFormatToPulseFormatTable[] = { | 34 static const pa_sample_format_t kCricketFormatToPulseFormatTable[] = { |
33 // The order here must match the order in soundsysteminterface.h | 35 // The order here must match the order in soundsysteminterface.h |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 const pa_sample_spec &spec)) { | 1368 const pa_sample_spec &spec)) { |
1367 if (!IsInitialized()) { | 1369 if (!IsInitialized()) { |
1368 return NULL; | 1370 return NULL; |
1369 } | 1371 } |
1370 | 1372 |
1371 const char *dev = static_cast<const PulseAudioDeviceLocator *>(device)-> | 1373 const char *dev = static_cast<const PulseAudioDeviceLocator *>(device)-> |
1372 device_name().c_str(); | 1374 device_name().c_str(); |
1373 | 1375 |
1374 StreamInterface *stream_interface = NULL; | 1376 StreamInterface *stream_interface = NULL; |
1375 | 1377 |
1376 ASSERT(params.format < ARRAY_SIZE(kCricketFormatToPulseFormatTable)); | 1378 ASSERT(params.format < arraysize(kCricketFormatToPulseFormatTable)); |
1377 | 1379 |
1378 pa_sample_spec spec; | 1380 pa_sample_spec spec; |
1379 spec.format = kCricketFormatToPulseFormatTable[params.format]; | 1381 spec.format = kCricketFormatToPulseFormatTable[params.format]; |
1380 spec.rate = params.freq; | 1382 spec.rate = params.freq; |
1381 spec.channels = params.channels; | 1383 spec.channels = params.channels; |
1382 | 1384 |
1383 int pa_flags = 0; | 1385 int pa_flags = 0; |
1384 if (params.flags & FLAG_REPORT_LATENCY) { | 1386 if (params.flags & FLAG_REPORT_LATENCY) { |
1385 pa_flags |= PA_STREAM_INTERPOLATE_TIMING | | 1387 pa_flags |= PA_STREAM_INTERPOLATE_TIMING | |
1386 PA_STREAM_AUTO_TIMING_UPDATE; | 1388 PA_STREAM_AUTO_TIMING_UPDATE; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 | 1534 |
1533 // Must be called with the lock held. | 1535 // Must be called with the lock held. |
1534 const char *PulseAudioSoundSystem::LastError() { | 1536 const char *PulseAudioSoundSystem::LastError() { |
1535 return symbol_table_.pa_strerror()(symbol_table_.pa_context_errno()( | 1537 return symbol_table_.pa_strerror()(symbol_table_.pa_context_errno()( |
1536 context_)); | 1538 context_)); |
1537 } | 1539 } |
1538 | 1540 |
1539 } // namespace rtc | 1541 } // namespace rtc |
1540 | 1542 |
1541 #endif // HAVE_LIBPULSE | 1543 #endif // HAVE_LIBPULSE |
OLD | NEW |