| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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/alsasoundsystem.h" | 11 #include "webrtc/sound/alsasoundsystem.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <string> |
| 14 | 15 |
| 15 #include "webrtc/base/arraysize.h" | 16 #include "webrtc/base/arraysize.h" |
| 16 #include "webrtc/base/common.h" | 17 #include "webrtc/base/common.h" |
| 17 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
| 18 #include "webrtc/base/scoped_ptr.h" | 19 #include "webrtc/base/scoped_ptr.h" |
| 19 #include "webrtc/base/stringutils.h" | 20 #include "webrtc/base/stringutils.h" |
| 20 #include "webrtc/base/timeutils.h" | 21 #include "webrtc/base/timeutils.h" |
| 21 #include "webrtc/base/worker.h" | 22 #include "webrtc/base/worker.h" |
| 22 #include "webrtc/sound/sounddevicelocator.h" | 23 #include "webrtc/sound/sounddevicelocator.h" |
| 23 #include "webrtc/sound/soundinputstreaminterface.h" | 24 #include "webrtc/sound/soundinputstreaminterface.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 253 |
| 253 bool StartReading() override { | 254 bool StartReading() override { |
| 254 return StartWork(); | 255 return StartWork(); |
| 255 } | 256 } |
| 256 | 257 |
| 257 bool StopReading() override { | 258 bool StopReading() override { |
| 258 return StopWork(); | 259 return StopWork(); |
| 259 } | 260 } |
| 260 | 261 |
| 261 bool GetVolume(int *volume) override { | 262 bool GetVolume(int *volume) override { |
| 262 // TODO: Implement this. | 263 // TODO(henrika): Implement this. |
| 263 return false; | 264 return false; |
| 264 } | 265 } |
| 265 | 266 |
| 266 bool SetVolume(int volume) override { | 267 bool SetVolume(int volume) override { |
| 267 // TODO: Implement this. | 268 // TODO(henrika): Implement this. |
| 268 return false; | 269 return false; |
| 269 } | 270 } |
| 270 | 271 |
| 271 bool Close() override { | 272 bool Close() override { |
| 272 return StopReading() && stream_.Close(); | 273 return StopReading() && stream_.Close(); |
| 273 } | 274 } |
| 274 | 275 |
| 275 int LatencyUsecs() override { | 276 int LatencyUsecs() override { |
| 276 return stream_.CurrentDelayUsecs(); | 277 return stream_.CurrentDelayUsecs(); |
| 277 } | 278 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } else if (static_cast<snd_pcm_uframes_t>(written) < frames) { | 384 } else if (static_cast<snd_pcm_uframes_t>(written) < frames) { |
| 384 // Shouldn't happen. Drop the rest of the data. | 385 // Shouldn't happen. Drop the rest of the data. |
| 385 LOG(LS_ERROR) << "Stream wrote only " << written << " of " << frames | 386 LOG(LS_ERROR) << "Stream wrote only " << written << " of " << frames |
| 386 << " frames!"; | 387 << " frames!"; |
| 387 return false; | 388 return false; |
| 388 } | 389 } |
| 389 return true; | 390 return true; |
| 390 } | 391 } |
| 391 | 392 |
| 392 bool GetVolume(int *volume) override { | 393 bool GetVolume(int *volume) override { |
| 393 // TODO: Implement this. | 394 // TODO(henrika): Implement this. |
| 394 return false; | 395 return false; |
| 395 } | 396 } |
| 396 | 397 |
| 397 bool SetVolume(int volume) override { | 398 bool SetVolume(int volume) override { |
| 398 // TODO: Implement this. | 399 // TODO(henrika): Implement this. |
| 399 return false; | 400 return false; |
| 400 } | 401 } |
| 401 | 402 |
| 402 bool Close() override { | 403 bool Close() override { |
| 403 return DisableBufferMonitoring() && stream_.Close(); | 404 return DisableBufferMonitoring() && stream_.Close(); |
| 404 } | 405 } |
| 405 | 406 |
| 406 int LatencyUsecs() override { | 407 int LatencyUsecs() override { |
| 407 return stream_.CurrentDelayUsecs(); | 408 return stream_.CurrentDelayUsecs(); |
| 408 } | 409 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 LOG(LS_ERROR) << "Device has no name???"; | 563 LOG(LS_ERROR) << "Device has no name???"; |
| 563 // Skip it. | 564 // Skip it. |
| 564 continue; | 565 continue; |
| 565 } | 566 } |
| 566 | 567 |
| 567 // Now check if we actually want to show this device. | 568 // Now check if we actually want to show this device. |
| 568 if (strcmp(name, ignore_default) != 0 && | 569 if (strcmp(name, ignore_default) != 0 && |
| 569 strcmp(name, ignore_null) != 0 && | 570 strcmp(name, ignore_null) != 0 && |
| 570 strcmp(name, ignore_pulse) != 0 && | 571 strcmp(name, ignore_pulse) != 0 && |
| 571 !rtc::starts_with(name, ignore_prefix)) { | 572 !rtc::starts_with(name, ignore_prefix)) { |
| 572 | |
| 573 // Yes, we do. | 573 // Yes, we do. |
| 574 char *desc = symbol_table_.snd_device_name_get_hint()(*list, "DESC"); | 574 char *desc = symbol_table_.snd_device_name_get_hint()(*list, "DESC"); |
| 575 if (!desc) { | 575 if (!desc) { |
| 576 // Virtual devices don't necessarily have descriptions. Use their names | 576 // Virtual devices don't necessarily have descriptions. Use their names |
| 577 // instead (not pretty!). | 577 // instead (not pretty!). |
| 578 desc = name; | 578 desc = name; |
| 579 } | 579 } |
| 580 | 580 |
| 581 AlsaDeviceLocator *device = new AlsaDeviceLocator(desc, name); | 581 AlsaDeviceLocator *device = new AlsaDeviceLocator(desc, name); |
| 582 | 582 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 StreamInterface *AlsaSoundSystem::OpenDevice( | 615 StreamInterface *AlsaSoundSystem::OpenDevice( |
| 616 const SoundDeviceLocator *device, | 616 const SoundDeviceLocator *device, |
| 617 const OpenParams ¶ms, | 617 const OpenParams ¶ms, |
| 618 snd_pcm_stream_t type, | 618 snd_pcm_stream_t type, |
| 619 StreamInterface *(AlsaSoundSystem::*start_fn)( | 619 StreamInterface *(AlsaSoundSystem::*start_fn)( |
| 620 snd_pcm_t *handle, | 620 snd_pcm_t *handle, |
| 621 size_t frame_size, | 621 size_t frame_size, |
| 622 int wait_timeout_ms, | 622 int wait_timeout_ms, |
| 623 int flags, | 623 int flags, |
| 624 int freq)) { | 624 int freq)) { |
| 625 | |
| 626 if (!IsInitialized()) { | 625 if (!IsInitialized()) { |
| 627 return NULL; | 626 return NULL; |
| 628 } | 627 } |
| 629 | 628 |
| 630 StreamInterface *stream; | 629 StreamInterface *stream; |
| 631 int err; | 630 int err; |
| 632 | 631 |
| 633 const char *dev = static_cast<const AlsaDeviceLocator *>(device)-> | 632 const char *dev = static_cast<const AlsaDeviceLocator *>(device)-> |
| 634 device_name().c_str(); | 633 device_name().c_str(); |
| 635 | 634 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 } | 732 } |
| 734 return new AlsaInputStream( | 733 return new AlsaInputStream( |
| 735 this, handle, frame_size, wait_timeout_ms, flags, freq); | 734 this, handle, frame_size, wait_timeout_ms, flags, freq); |
| 736 } | 735 } |
| 737 | 736 |
| 738 inline const char *AlsaSoundSystem::GetError(int err) { | 737 inline const char *AlsaSoundSystem::GetError(int err) { |
| 739 return symbol_table_.snd_strerror()(err); | 738 return symbol_table_.snd_strerror()(err); |
| 740 } | 739 } |
| 741 | 740 |
| 742 } // namespace rtc | 741 } // namespace rtc |
| OLD | NEW |