| 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/mediums/audio/audio_manager_impl.h" | 5 #include "components/copresence/mediums/audio/audio_manager_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 return token; | 33 return token; |
| 34 } | 34 } |
| 35 | 35 |
| 36 const int kSampleExpiryTimeMs = 60 * 60 * 1000; // 60 minutes. | 36 const int kSampleExpiryTimeMs = 60 * 60 * 1000; // 60 minutes. |
| 37 const int kMaxSamples = 10000; | 37 const int kMaxSamples = 10000; |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 // Public methods. | 41 // Public methods. |
| 42 | 42 |
| 43 AudioManagerImpl::AudioManagerImpl() : recorder_(NULL) { | 43 AudioManagerImpl::AudioManagerImpl() : recorder_(nullptr) { |
| 44 // TODO(rkc): Move all of these into initializer lists once it is allowed. | 44 // TODO(rkc): Move all of these into initializer lists once it is allowed. |
| 45 playing_[AUDIBLE] = false; | 45 playing_[AUDIBLE] = false; |
| 46 playing_[INAUDIBLE] = false; | 46 playing_[INAUDIBLE] = false; |
| 47 recording_[AUDIBLE] = false; | 47 recording_[AUDIBLE] = false; |
| 48 recording_[INAUDIBLE] = false; | 48 recording_[INAUDIBLE] = false; |
| 49 | 49 |
| 50 player_[AUDIBLE] = NULL; | 50 player_[AUDIBLE] = nullptr; |
| 51 player_[INAUDIBLE] = NULL; | 51 player_[INAUDIBLE] = nullptr; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void AudioManagerImpl::Initialize(const DecodeSamplesCallback& decode_cb, | 54 void AudioManagerImpl::Initialize(const DecodeSamplesCallback& decode_cb, |
| 55 const EncodeTokenCallback& encode_cb) { | 55 const EncodeTokenCallback& encode_cb) { |
| 56 samples_cache_.resize(2); | 56 samples_cache_.resize(2); |
| 57 samples_cache_[AUDIBLE] = new SamplesMap( | 57 samples_cache_[AUDIBLE] = new SamplesMap( |
| 58 base::TimeDelta::FromMilliseconds(kSampleExpiryTimeMs), kMaxSamples); | 58 base::TimeDelta::FromMilliseconds(kSampleExpiryTimeMs), kMaxSamples); |
| 59 samples_cache_[INAUDIBLE] = new SamplesMap( | 59 samples_cache_[INAUDIBLE] = new SamplesMap( |
| 60 base::TimeDelta::FromMilliseconds(kSampleExpiryTimeMs), kMaxSamples); | 60 base::TimeDelta::FromMilliseconds(kSampleExpiryTimeMs), kMaxSamples); |
| 61 | 61 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 decode_type = BOTH; | 184 decode_type = BOTH; |
| 185 else if (recording_[AUDIBLE]) | 185 else if (recording_[AUDIBLE]) |
| 186 decode_type = AUDIBLE; | 186 decode_type = AUDIBLE; |
| 187 else if (recording_[INAUDIBLE]) | 187 else if (recording_[INAUDIBLE]) |
| 188 decode_type = INAUDIBLE; | 188 decode_type = INAUDIBLE; |
| 189 | 189 |
| 190 decode_cb_.Run(decode_type, samples); | 190 decode_cb_.Run(decode_type, samples); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace copresence | 193 } // namespace copresence |
| OLD | NEW |