| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/audio/fake_audio_input_stream.h" | 5 #include "media/audio/fake_audio_input_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 wav_file_data_ = ReadWavFile(wav_filename, &file_length); | 208 wav_file_data_ = ReadWavFile(wav_filename, &file_length); |
| 209 wav_audio_handler_ = CreateWavAudioHandler( | 209 wav_audio_handler_ = CreateWavAudioHandler( |
| 210 wav_filename, wav_file_data_.get(), file_length, params_); | 210 wav_filename, wav_file_data_.get(), file_length, params_); |
| 211 } | 211 } |
| 212 | 212 |
| 213 bool FakeAudioInputStream::PlayingFromFile() { | 213 bool FakeAudioInputStream::PlayingFromFile() { |
| 214 return wav_audio_handler_.get() != nullptr; | 214 return wav_audio_handler_.get() != nullptr; |
| 215 } | 215 } |
| 216 | 216 |
| 217 void FakeAudioInputStream::PlayFileLooping() { | 217 void FakeAudioInputStream::PlayFileLooping() { |
| 218 // TODO(phoglund): reinstate looping/make optional after wrapping up AGC test. |
| 219 if (wav_audio_handler_->AtEnd(wav_file_read_pos_)) |
| 220 //wav_file_read_pos_ = 0; |
| 221 return; |
| 222 |
| 218 // Unfilled frames will be zeroed by CopyTo. | 223 // Unfilled frames will be zeroed by CopyTo. |
| 219 size_t bytes_written; | 224 size_t bytes_written; |
| 220 wav_audio_handler_->CopyTo(audio_bus_.get(), wav_file_read_pos_, | 225 wav_audio_handler_->CopyTo(audio_bus_.get(), wav_file_read_pos_, |
| 221 &bytes_written); | 226 &bytes_written); |
| 222 wav_file_read_pos_ += bytes_written; | 227 wav_file_read_pos_ += bytes_written; |
| 223 if (wav_audio_handler_->AtEnd(wav_file_read_pos_)) | |
| 224 wav_file_read_pos_ = 0; | |
| 225 callback_->OnData(this, audio_bus_.get(), buffer_size_, 1.0); | 228 callback_->OnData(this, audio_bus_.get(), buffer_size_, 1.0); |
| 226 } | 229 } |
| 227 | 230 |
| 228 void FakeAudioInputStream::PlayBeep() { | 231 void FakeAudioInputStream::PlayBeep() { |
| 229 // Accumulate the time from the last beep. | 232 // Accumulate the time from the last beep. |
| 230 interval_from_last_beep_ += TimeTicks::Now() - last_callback_time_; | 233 interval_from_last_beep_ += TimeTicks::Now() - last_callback_time_; |
| 231 | 234 |
| 232 memset(buffer_.get(), 0, buffer_size_); | 235 memset(buffer_.get(), 0, buffer_size_); |
| 233 bool should_beep = false; | 236 bool should_beep = false; |
| 234 { | 237 { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 return false; | 316 return false; |
| 314 } | 317 } |
| 315 | 318 |
| 316 // static | 319 // static |
| 317 void FakeAudioInputStream::BeepOnce() { | 320 void FakeAudioInputStream::BeepOnce() { |
| 318 BeepContext* beep_context = g_beep_context.Pointer(); | 321 BeepContext* beep_context = g_beep_context.Pointer(); |
| 319 beep_context->SetBeepOnce(true); | 322 beep_context->SetBeepOnce(true); |
| 320 } | 323 } |
| 321 | 324 |
| 322 } // namespace media | 325 } // namespace media |
| OLD | NEW |