| 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 #include "media/base/filter_host.h" | 5 #include "media/base/filter_host.h" |
| 6 #include "media/filters/audio_renderer_base.h" | 6 #include "media/filters/audio_renderer_base.h" |
| 7 | 7 |
| 8 namespace media { | 8 namespace media { |
| 9 | 9 |
| 10 // The maximum size of the queue, which also acts as the number of initial reads | 10 // The maximum size of the queue, which also acts as the number of initial reads |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 size_t dest_written = 0; | 137 size_t dest_written = 0; |
| 138 | 138 |
| 139 // The timestamp of the last buffer written during the last call to | 139 // The timestamp of the last buffer written during the last call to |
| 140 // FillBuffer(). | 140 // FillBuffer(). |
| 141 base::TimeDelta last_fill_buffer_time; | 141 base::TimeDelta last_fill_buffer_time; |
| 142 { | 142 { |
| 143 AutoLock auto_lock(lock_); | 143 AutoLock auto_lock(lock_); |
| 144 | 144 |
| 145 // Mute audio by returning 0 when not playing. | 145 // Mute audio by returning 0 when not playing. |
| 146 if (state_ != kPlaying) { | 146 if (state_ != kPlaying) { |
| 147 return 0; | 147 // TODO(scherkus): To keep the audio hardware busy we write at most 8k of |
| 148 // zeros. This gets around the tricky situation of pausing and resuming |
| 149 // the audio IPC layer in Chrome. Ideally, we should return zero and then |
| 150 // the subclass can restart the conversation. |
| 151 dest_written = std::min(8192u, dest_len); |
| 152 memset(dest, 0, dest_written); |
| 153 return dest_written; |
| 148 } | 154 } |
| 149 | 155 |
| 150 // Save a local copy of last fill buffer time and reset the member. | 156 // Save a local copy of last fill buffer time and reset the member. |
| 151 last_fill_buffer_time = last_fill_buffer_time_; | 157 last_fill_buffer_time = last_fill_buffer_time_; |
| 152 last_fill_buffer_time_ = base::TimeDelta(); | 158 last_fill_buffer_time_ = base::TimeDelta(); |
| 153 | 159 |
| 154 // Loop until the buffer has been filled. | 160 // Loop until the buffer has been filled. |
| 155 while (dest_len > 0 && !queue_.empty()) { | 161 while (dest_len > 0 && !queue_.empty()) { |
| 156 scoped_refptr<Buffer> buffer = queue_.front(); | 162 scoped_refptr<Buffer> buffer = queue_.front(); |
| 157 | 163 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // TODO(scherkus): might be handy to support NULL parameters. | 269 // TODO(scherkus): might be handy to support NULL parameters. |
| 264 std::string mime_type; | 270 std::string mime_type; |
| 265 return media_format.GetAsString(MediaFormat::kMimeType, &mime_type) && | 271 return media_format.GetAsString(MediaFormat::kMimeType, &mime_type) && |
| 266 media_format.GetAsInteger(MediaFormat::kChannels, channels_out) && | 272 media_format.GetAsInteger(MediaFormat::kChannels, channels_out) && |
| 267 media_format.GetAsInteger(MediaFormat::kSampleRate, sample_rate_out) && | 273 media_format.GetAsInteger(MediaFormat::kSampleRate, sample_rate_out) && |
| 268 media_format.GetAsInteger(MediaFormat::kSampleBits, sample_bits_out) && | 274 media_format.GetAsInteger(MediaFormat::kSampleBits, sample_bits_out) && |
| 269 mime_type.compare(mime_type::kUncompressedAudio) == 0; | 275 mime_type.compare(mime_type::kUncompressedAudio) == 0; |
| 270 } | 276 } |
| 271 | 277 |
| 272 } // namespace media | 278 } // namespace media |
| OLD | NEW |