OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/copresence/handlers/audio/audio_directive_handler.h" | 5 #include "components/copresence/handlers/audio/audio_directive_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/time/default_tick_clock.h" | 10 #include "base/time/default_tick_clock.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 void AudioDirectiveHandler::RemoveInstructions(const std::string& op_id) { | 94 void AudioDirectiveHandler::RemoveInstructions(const std::string& op_id) { |
95 transmits_list_[AUDIBLE].RemoveDirective(op_id); | 95 transmits_list_[AUDIBLE].RemoveDirective(op_id); |
96 transmits_list_[INAUDIBLE].RemoveDirective(op_id); | 96 transmits_list_[INAUDIBLE].RemoveDirective(op_id); |
97 receives_list_[AUDIBLE].RemoveDirective(op_id); | 97 receives_list_[AUDIBLE].RemoveDirective(op_id); |
98 receives_list_[INAUDIBLE].RemoveDirective(op_id); | 98 receives_list_[INAUDIBLE].RemoveDirective(op_id); |
99 | 99 |
100 ProcessNextInstruction(); | 100 ProcessNextInstruction(); |
101 } | 101 } |
102 | 102 |
| 103 void AudioDirectiveHandler::set_clock_for_testing( |
| 104 const scoped_refptr<base::TickClock>& clock) { |
| 105 clock_ = clock; |
| 106 |
| 107 transmits_list_[AUDIBLE].set_clock_for_testing(clock); |
| 108 transmits_list_[INAUDIBLE].set_clock_for_testing(clock); |
| 109 receives_list_[AUDIBLE].set_clock_for_testing(clock); |
| 110 receives_list_[INAUDIBLE].set_clock_for_testing(clock); |
| 111 } |
| 112 |
| 113 void AudioDirectiveHandler::set_timer_for_testing( |
| 114 scoped_ptr<base::Timer> timer) { |
| 115 audio_event_timer_.swap(timer); |
| 116 } |
| 117 |
103 // Private methods. | 118 // Private methods. |
104 | 119 |
105 void AudioDirectiveHandler::ProcessNextInstruction() { | 120 void AudioDirectiveHandler::ProcessNextInstruction() { |
106 DCHECK(audio_event_timer_); | 121 DCHECK(audio_event_timer_); |
107 LOG(ERROR) << "RKC: Stopping the timer."; | |
108 audio_event_timer_->Stop(); | 122 audio_event_timer_->Stop(); |
109 | 123 |
110 // Change audio_manager_ state for audible transmits. | 124 // Change audio_manager_ state for audible transmits. |
111 if (transmits_list_[AUDIBLE].GetActiveDirective()) | 125 if (transmits_list_[AUDIBLE].GetActiveDirective()) |
112 audio_manager_->StartPlaying(AUDIBLE); | 126 audio_manager_->StartPlaying(AUDIBLE); |
113 else | 127 else |
114 audio_manager_->StopPlaying(AUDIBLE); | 128 audio_manager_->StopPlaying(AUDIBLE); |
115 | 129 |
116 // Change audio_manager_ state for inaudible transmits. | 130 // Change audio_manager_ state for inaudible transmits. |
117 if (transmits_list_[INAUDIBLE].GetActiveDirective()) | 131 if (transmits_list_[INAUDIBLE].GetActiveDirective()) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // directives; or that they are all due to expire a bazzilion years from now. | 172 // directives; or that they are all due to expire a bazzilion years from now. |
159 // The latter is not possible since the max life of a directive is 1 day, | 173 // The latter is not possible since the max life of a directive is 1 day, |
160 // this is enforced by the API. | 174 // this is enforced by the API. |
161 if (next_event == max) | 175 if (next_event == max) |
162 return false; | 176 return false; |
163 else | 177 else |
164 return true; | 178 return true; |
165 } | 179 } |
166 | 180 |
167 } // namespace copresence | 181 } // namespace copresence |
OLD | NEW |