| 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <mmsystem.h> | 6 #include <mmsystem.h> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 audio_bus->Zero(); | 54 audio_bus->Zero(); |
| 55 return audio_bus->frames(); | 55 return audio_bus->frames(); |
| 56 } | 56 } |
| 57 virtual int OnMoreIOData(AudioBus* source, | 57 virtual int OnMoreIOData(AudioBus* source, |
| 58 AudioBus* dest, | 58 AudioBus* dest, |
| 59 AudioBuffersState buffers_state) { | 59 AudioBuffersState buffers_state) { |
| 60 NOTREACHED(); | 60 NOTREACHED(); |
| 61 return 0; | 61 return 0; |
| 62 } | 62 } |
| 63 // AudioSourceCallback::OnError implementation: | 63 // AudioSourceCallback::OnError implementation: |
| 64 virtual void OnError(AudioOutputStream* stream, int code) { | 64 virtual void OnError(AudioOutputStream* stream) { |
| 65 ++had_error_; | 65 ++had_error_; |
| 66 } | 66 } |
| 67 // Returns how many times OnMoreData() has been called. | 67 // Returns how many times OnMoreData() has been called. |
| 68 int callback_count() const { | 68 int callback_count() const { |
| 69 return callback_count_; | 69 return callback_count_; |
| 70 } | 70 } |
| 71 // Returns how many times the OnError callback was called. | 71 // Returns how many times the OnError callback was called. |
| 72 int had_error() const { | 72 int had_error() const { |
| 73 return had_error_; | 73 return had_error_; |
| 74 } | 74 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 104 int lag_in_ms_; | 104 int lag_in_ms_; |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 class MockAudioSource : public AudioOutputStream::AudioSourceCallback { | 107 class MockAudioSource : public AudioOutputStream::AudioSourceCallback { |
| 108 public: | 108 public: |
| 109 MOCK_METHOD2(OnMoreData, int(AudioBus* audio_bus, | 109 MOCK_METHOD2(OnMoreData, int(AudioBus* audio_bus, |
| 110 AudioBuffersState buffers_state)); | 110 AudioBuffersState buffers_state)); |
| 111 MOCK_METHOD3(OnMoreIOData, int(AudioBus* source, | 111 MOCK_METHOD3(OnMoreIOData, int(AudioBus* source, |
| 112 AudioBus* dest, | 112 AudioBus* dest, |
| 113 AudioBuffersState buffers_state)); | 113 AudioBuffersState buffers_state)); |
| 114 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); | 114 MOCK_METHOD1(OnError, void(AudioOutputStream* stream)); |
| 115 | 115 |
| 116 static int ClearData(AudioBus* audio_bus, AudioBuffersState buffers_state) { | 116 static int ClearData(AudioBus* audio_bus, AudioBuffersState buffers_state) { |
| 117 audio_bus->Zero(); | 117 audio_bus->Zero(); |
| 118 return audio_bus->frames(); | 118 return audio_bus->frames(); |
| 119 } | 119 } |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 // Helper class to memory map an entire file. The mapping is read-only. Don't | 122 // Helper class to memory map an entire file. The mapping is read-only. Don't |
| 123 // use for gigabyte-sized files. Attempts to write to this memory generate | 123 // use for gigabyte-sized files. Attempts to write to this memory generate |
| 124 // memory access violations. | 124 // memory access violations. |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 audio_bus_->CopyTo(audio_bus); | 582 audio_bus_->CopyTo(audio_bus); |
| 583 return audio_bus_->frames(); | 583 return audio_bus_->frames(); |
| 584 } | 584 } |
| 585 virtual int OnMoreIOData(AudioBus* source, | 585 virtual int OnMoreIOData(AudioBus* source, |
| 586 AudioBus* dest, | 586 AudioBus* dest, |
| 587 AudioBuffersState buffers_state) { | 587 AudioBuffersState buffers_state) { |
| 588 NOTREACHED(); | 588 NOTREACHED(); |
| 589 return 0; | 589 return 0; |
| 590 } | 590 } |
| 591 // AudioSourceCallback::OnError implementation: | 591 // AudioSourceCallback::OnError implementation: |
| 592 virtual void OnError(AudioOutputStream* stream, int code) { | 592 virtual void OnError(AudioOutputStream* stream) { |
| 593 } | 593 } |
| 594 | 594 |
| 595 private: | 595 private: |
| 596 base::SyncSocket* socket_; | 596 base::SyncSocket* socket_; |
| 597 int data_size_; | 597 int data_size_; |
| 598 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> data_; | 598 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> data_; |
| 599 scoped_ptr<AudioBus> audio_bus_; | 599 scoped_ptr<AudioBus> audio_bus_; |
| 600 }; | 600 }; |
| 601 | 601 |
| 602 struct SyncThreadContext { | 602 struct SyncThreadContext { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 oas->Start(&source); | 685 oas->Start(&source); |
| 686 | 686 |
| 687 ::WaitForSingleObject(thread, INFINITE); | 687 ::WaitForSingleObject(thread, INFINITE); |
| 688 ::CloseHandle(thread); | 688 ::CloseHandle(thread); |
| 689 | 689 |
| 690 oas->Stop(); | 690 oas->Stop(); |
| 691 oas->Close(); | 691 oas->Close(); |
| 692 } | 692 } |
| 693 | 693 |
| 694 } // namespace media | 694 } // namespace media |
| OLD | NEW |