| 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 #ifndef MEDIA_AUDIO_SIMPLE_SOURCES_H_ | 5 #ifndef MEDIA_AUDIO_SIMPLE_SOURCES_H_ |
| 6 #define MEDIA_AUDIO_SIMPLE_SOURCES_H_ | 6 #define MEDIA_AUDIO_SIMPLE_SOURCES_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "media/audio/audio_io.h" | 10 #include "media/audio/audio_io.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 protected: | 41 protected: |
| 42 int channels_; | 42 int channels_; |
| 43 double f_; | 43 double f_; |
| 44 int time_state_; | 44 int time_state_; |
| 45 int cap_; | 45 int cap_; |
| 46 int callbacks_; | 46 int callbacks_; |
| 47 int errors_; | 47 int errors_; |
| 48 base::Lock time_lock_; | 48 base::Lock time_lock_; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 class FileSource : public AudioOutputStream::AudioSourceCallback, | 51 class MEDIA_EXPORT FileSource : public AudioOutputStream::AudioSourceCallback, |
| 52 public AudioConverter::InputCallback { | 52 public AudioConverter::InputCallback { |
| 53 public: | 53 public: |
| 54 FileSource(const AudioParameters& params, | 54 FileSource(const AudioParameters& params, |
| 55 const base::FilePath& path_to_wav_file); | 55 const base::FilePath& path_to_wav_file); |
| 56 ~FileSource() override; | 56 ~FileSource() override; |
| 57 | 57 |
| 58 // Implementation of AudioSourceCallback. | 58 // Implementation of AudioSourceCallback. |
| 59 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override; | 59 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override; |
| 60 void OnError(AudioOutputStream* stream) override; | 60 void OnError(AudioOutputStream* stream) override; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 AudioParameters params_; | 63 AudioParameters params_; |
| 64 base::FilePath path_to_wav_file_; | 64 base::FilePath path_to_wav_file_; |
| 65 scoped_ptr<uint8[]> wav_file_data_; | 65 |
| 66 // The WAV data at |path_to_wav_file_| is read into memory and kept here. |
| 67 // This memory needs to survive for the lifetime of |wav_audio_handler_|, |
| 68 // so declare it first. Do not access this member directly. |
| 69 scoped_ptr<char[]> raw_wav_data_; |
| 70 |
| 66 scoped_ptr<WavAudioHandler> wav_audio_handler_; | 71 scoped_ptr<WavAudioHandler> wav_audio_handler_; |
| 67 scoped_ptr<AudioConverter> file_audio_converter_; | 72 scoped_ptr<AudioConverter> file_audio_converter_; |
| 68 int wav_file_read_pos_; | 73 int wav_file_read_pos_; |
| 69 bool load_failed_; | 74 bool load_failed_; |
| 70 | 75 |
| 71 // Provides audio data from wav_audio_handler_ into the file audio converter. | 76 // Provides audio data from wav_audio_handler_ into the file audio converter. |
| 72 double ProvideInput(AudioBus* audio_bus, | 77 double ProvideInput(AudioBus* audio_bus, |
| 73 base::TimeDelta buffer_delay) override; | 78 base::TimeDelta buffer_delay) override; |
| 74 | 79 |
| 75 // Loads the wav file on the first OnMoreData invocation. | 80 // Loads the wav file on the first OnMoreData invocation. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 93 base::TimeTicks last_callback_time_; | 98 base::TimeTicks last_callback_time_; |
| 94 base::TimeDelta interval_from_last_beep_; | 99 base::TimeDelta interval_from_last_beep_; |
| 95 int beep_duration_in_buffers_; | 100 int beep_duration_in_buffers_; |
| 96 int beep_generated_in_buffers_; | 101 int beep_generated_in_buffers_; |
| 97 int beep_period_in_frames_; | 102 int beep_period_in_frames_; |
| 98 }; | 103 }; |
| 99 | 104 |
| 100 } // namespace media | 105 } // namespace media |
| 101 | 106 |
| 102 #endif // MEDIA_AUDIO_SIMPLE_SOURCES_H_ | 107 #endif // MEDIA_AUDIO_SIMPLE_SOURCES_H_ |
| OLD | NEW |