| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // The audio stream implementation is made difficult because different methods | 5 // The audio stream implementation is made difficult because different methods |
| 6 // are available for calling depending on what state the stream is. Here is the | 6 // are available for calling depending on what state the stream is. Here is the |
| 7 // state transition table for the stream. | 7 // state transition table for the stream. |
| 8 // | 8 // |
| 9 // STATE_CREATED -> Open() -> STATE_OPENED | 9 // STATE_CREATED -> Open() -> STATE_OPENED |
| 10 // STATE_OPENED -> Start() -> STATE_STARTED | 10 // STATE_OPENED -> Start() -> STATE_STARTED |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 source_callback_(NULL), | 83 source_callback_(NULL), |
| 84 playback_thread_("PlaybackThread"), | 84 playback_thread_("PlaybackThread"), |
| 85 channels_(channels), | 85 channels_(channels), |
| 86 sample_rate_(sample_rate), | 86 sample_rate_(sample_rate), |
| 87 bits_per_sample_(bits_per_sample), | 87 bits_per_sample_(bits_per_sample), |
| 88 min_buffer_frames_((min_buffer_ms * sample_rate_) / | 88 min_buffer_frames_((min_buffer_ms * sample_rate_) / |
| 89 base::Time::kMillisecondsPerSecond), | 89 base::Time::kMillisecondsPerSecond), |
| 90 packet_size_(0), | 90 packet_size_(0), |
| 91 device_write_suspended_(true), // Start suspended. | 91 device_write_suspended_(true), // Start suspended. |
| 92 resources_released_(false) { | 92 resources_released_(false) { |
| 93 CHECK(channels_ == 2) << "Only 2-channel audio is supported right now."; | |
| 94 CHECK(AudioManager::AUDIO_PCM_LINEAR == format) | |
| 95 << "Only linear PCM supported."; | |
| 96 CHECK(bits_per_sample % 8 == 0) << "Only allow byte-aligned samples"; | |
| 97 | |
| 98 // Reference self to avoid accidental deletion before the message loop is | 93 // Reference self to avoid accidental deletion before the message loop is |
| 99 // done. | 94 // done. |
| 100 AddRef(); | 95 AddRef(); |
| 101 | 96 |
| 97 // Sanity check input values. |
| 98 if (channels_ != 2) { |
| 99 LOG(WARNING) << "Only 2-channel audio is supported right now."; |
| 100 state_ = STATE_ERROR; |
| 101 } |
| 102 |
| 103 if (AudioManager::AUDIO_PCM_LINEAR != format) { |
| 104 LOG(WARNING) << "Only linear PCM supported."; |
| 105 state_ = STATE_ERROR; |
| 106 } |
| 107 |
| 108 if (bits_per_sample % 8 != 0) { |
| 109 // We do this explicitly just incase someone messes up the switch below. |
| 110 LOG(WARNING) << "Only allow byte-aligned samples"; |
| 111 state_ = STATE_ERROR; |
| 112 } |
| 113 |
| 102 switch (bits_per_sample) { | 114 switch (bits_per_sample) { |
| 103 case 8: | 115 case 8: |
| 104 pcm_format_ = SND_PCM_FORMAT_S8; | 116 pcm_format_ = SND_PCM_FORMAT_S8; |
| 105 break; | 117 break; |
| 106 | 118 |
| 107 case 16: | 119 case 16: |
| 108 pcm_format_ = SND_PCM_FORMAT_S16; | 120 pcm_format_ = SND_PCM_FORMAT_S16; |
| 109 break; | 121 break; |
| 110 | 122 |
| 111 case 24: | 123 case 24: |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 NOTIMPLEMENTED(); | 524 NOTIMPLEMENTED(); |
| 513 } | 525 } |
| 514 | 526 |
| 515 void AlsaPCMOutputStream::GetVolume(double* left_level, double* right_level) { | 527 void AlsaPCMOutputStream::GetVolume(double* left_level, double* right_level) { |
| 516 NOTIMPLEMENTED(); | 528 NOTIMPLEMENTED(); |
| 517 } | 529 } |
| 518 | 530 |
| 519 size_t AlsaPCMOutputStream::GetNumBuffers() { | 531 size_t AlsaPCMOutputStream::GetNumBuffers() { |
| 520 return 0; | 532 return 0; |
| 521 } | 533 } |
| OLD | NEW |