Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: components/copresence/handlers/audio/audio_directive_handler_impl.cc

Issue 704923002: Add polling and audio check to copresence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_impl.h" 5 #include "components/copresence/handlers/audio/audio_directive_handler_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 AudioDirectiveHandlerImpl::AudioDirectiveHandlerImpl( 48 AudioDirectiveHandlerImpl::AudioDirectiveHandlerImpl(
49 scoped_ptr<AudioManager> audio_manager, 49 scoped_ptr<AudioManager> audio_manager,
50 scoped_ptr<base::Timer> timer, 50 scoped_ptr<base::Timer> timer,
51 const scoped_refptr<TickClockRefCounted>& clock) 51 const scoped_refptr<TickClockRefCounted>& clock)
52 : audio_manager_(audio_manager.Pass()), 52 : audio_manager_(audio_manager.Pass()),
53 audio_event_timer_(timer.Pass()), 53 audio_event_timer_(timer.Pass()),
54 clock_(clock) {} 54 clock_(clock) {}
55 55
56 AudioDirectiveHandlerImpl::~AudioDirectiveHandlerImpl() {} 56 AudioDirectiveHandlerImpl::~AudioDirectiveHandlerImpl() {}
57 57
58 void AudioDirectiveHandlerImpl::Initialize( 58 void AudioDirectiveHandlerImpl::Initialize(WhispernetClient* whispernet_client,
59 const AudioManager::DecodeSamplesCallback& decode_cb, 59 const TokensCallback& tokens_cb) {
60 const AudioManager::EncodeTokenCallback& encode_cb) {
61 if (!audio_manager_) 60 if (!audio_manager_)
62 audio_manager_.reset(new AudioManagerImpl()); 61 audio_manager_.reset(new AudioManagerImpl());
63 audio_manager_->Initialize(decode_cb, encode_cb); 62 audio_manager_->Initialize(whispernet_client, tokens_cb);
64 63
65 DCHECK(transmits_lists_.empty()); 64 DCHECK(transmits_lists_.empty());
66 transmits_lists_.push_back(new AudioDirectiveList(clock_)); 65 transmits_lists_.push_back(new AudioDirectiveList(clock_));
67 transmits_lists_.push_back(new AudioDirectiveList(clock_)); 66 transmits_lists_.push_back(new AudioDirectiveList(clock_));
68 67
69 DCHECK(receives_lists_.empty()); 68 DCHECK(receives_lists_.empty());
70 receives_lists_.push_back(new AudioDirectiveList(clock_)); 69 receives_lists_.push_back(new AudioDirectiveList(clock_));
71 receives_lists_.push_back(new AudioDirectiveList(clock_)); 70 receives_lists_.push_back(new AudioDirectiveList(clock_));
72 } 71 }
73 72
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 receives_lists_[INAUDIBLE]->RemoveDirective(op_id); 129 receives_lists_[INAUDIBLE]->RemoveDirective(op_id);
131 130
132 ProcessNextInstruction(); 131 ProcessNextInstruction();
133 } 132 }
134 133
135 const std::string AudioDirectiveHandlerImpl::PlayingToken( 134 const std::string AudioDirectiveHandlerImpl::PlayingToken(
136 AudioType type) const { 135 AudioType type) const {
137 return audio_manager_->GetToken(type); 136 return audio_manager_->GetToken(type);
138 } 137 }
139 138
139 bool AudioDirectiveHandlerImpl::IsPlayingTokenHeard(AudioType type) const {
140 return audio_manager_->IsPlayingTokenHeard(type);
141 }
140 142
141 // Private functions. 143 // Private functions.
142 144
143 void AudioDirectiveHandlerImpl::ProcessNextInstruction() { 145 void AudioDirectiveHandlerImpl::ProcessNextInstruction() {
144 DCHECK(audio_event_timer_); 146 DCHECK(audio_event_timer_);
145 audio_event_timer_->Stop(); 147 audio_event_timer_->Stop();
146 148
147 // Change |audio_manager_| state for audible transmits. 149 // Change |audio_manager_| state for audible transmits.
148 if (transmits_lists_[AUDIBLE]->GetActiveDirective()) 150 if (transmits_lists_[AUDIBLE]->GetActiveDirective())
149 audio_manager_->StartPlaying(AUDIBLE); 151 audio_manager_->StartPlaying(AUDIBLE);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 186
185 *expiry = GetEarliestEventTime(transmits_lists_[AUDIBLE], base::TimeTicks()); 187 *expiry = GetEarliestEventTime(transmits_lists_[AUDIBLE], base::TimeTicks());
186 *expiry = GetEarliestEventTime(transmits_lists_[INAUDIBLE], *expiry); 188 *expiry = GetEarliestEventTime(transmits_lists_[INAUDIBLE], *expiry);
187 *expiry = GetEarliestEventTime(receives_lists_[AUDIBLE], *expiry); 189 *expiry = GetEarliestEventTime(receives_lists_[AUDIBLE], *expiry);
188 *expiry = GetEarliestEventTime(receives_lists_[INAUDIBLE], *expiry); 190 *expiry = GetEarliestEventTime(receives_lists_[INAUDIBLE], *expiry);
189 191
190 return !expiry->is_null(); 192 return !expiry->is_null();
191 } 193 }
192 194
193 } // namespace copresence 195 } // namespace copresence
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698