| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <limits> | 5 #include <limits> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "services/media/audio/audio_pipe.h" | 8 #include "services/media/audio/audio_pipe.h" |
| 9 #include "services/media/audio/audio_server_impl.h" | 9 #include "services/media/audio/audio_server_impl.h" |
| 10 #include "services/media/audio/audio_track_impl.h" | 10 #include "services/media/audio/audio_track_impl.h" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 namespace media { | 13 namespace media { |
| 14 namespace audio { | 14 namespace audio { |
| 15 | 15 |
| 16 AudioPipe::AudioPacketRef::AudioPacketRef( | 16 AudioPipe::AudioPacketRef::AudioPacketRef( |
| 17 MediaPacketStatePtr state, | 17 MediaPacketStatePtr state, |
| 18 AudioServerImpl* server, | 18 AudioServerImpl* server, |
| 19 std::vector<Region>&& regions, // NOLINT(build/c++11) | 19 std::vector<Region>&& regions, // NOLINT(build/c++11) |
| 20 int64_t start_pts, | 20 int64_t start_pts, |
| 21 int64_t end_pts) | 21 int64_t end_pts, |
| 22 uint32_t frame_count) |
| 22 : state_(std::move(state)), | 23 : state_(std::move(state)), |
| 23 server_(server), | 24 server_(server), |
| 24 regions_(std::move(regions)), | 25 regions_(std::move(regions)), |
| 25 start_pts_(start_pts), | 26 start_pts_(start_pts), |
| 26 end_pts_(end_pts) { | 27 end_pts_(end_pts), |
| 28 frame_count_(frame_count) { |
| 27 DCHECK(state_); | 29 DCHECK(state_); |
| 28 DCHECK(server_); | 30 DCHECK(server_); |
| 29 } | 31 } |
| 30 | 32 |
| 31 AudioPipe::AudioPacketRef::~AudioPacketRef() { | 33 AudioPipe::AudioPacketRef::~AudioPacketRef() { |
| 32 DCHECK(server_); | 34 DCHECK(server_); |
| 33 server_->SchedulePacketCleanup(std::move(state_)); | 35 server_->SchedulePacketCleanup(std::move(state_)); |
| 34 } | 36 } |
| 35 | 37 |
| 36 AudioPipe::AudioPipe(AudioTrackImpl* owner, | 38 AudioPipe::AudioPipe(AudioTrackImpl* owner, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 int64_t pts_delta = (static_cast<int64_t>(frame_count) | 125 int64_t pts_delta = (static_cast<int64_t>(frame_count) |
| 124 << AudioTrackImpl::PTS_FRACTIONAL_BITS); | 126 << AudioTrackImpl::PTS_FRACTIONAL_BITS); |
| 125 next_pts_ = start_pts + pts_delta; | 127 next_pts_ = start_pts + pts_delta; |
| 126 next_pts_known_ = true; | 128 next_pts_known_ = true; |
| 127 | 129 |
| 128 owner_->OnPacketReceived(AudioPacketRefPtr( | 130 owner_->OnPacketReceived(AudioPacketRefPtr( |
| 129 new AudioPacketRef(std::move(state), | 131 new AudioPacketRef(std::move(state), |
| 130 server_, | 132 server_, |
| 131 std::move(regions), | 133 std::move(regions), |
| 132 start_pts, | 134 start_pts, |
| 133 next_pts_))); | 135 next_pts_, |
| 136 frame_count))); |
| 134 | 137 |
| 135 if (!prime_callback_.is_null()) { | 138 if (!prime_callback_.is_null()) { |
| 136 // Prime was requested. Call the callback to indicate priming is complete. | 139 // Prime was requested. Call the callback to indicate priming is complete. |
| 137 // TODO(dalesat): Don't do this until low water mark is reached. | 140 // TODO(dalesat): Don't do this until low water mark is reached. |
| 138 prime_callback_.Run(); | 141 prime_callback_.Run(); |
| 139 prime_callback_.reset(); | 142 prime_callback_.reset(); |
| 140 } | 143 } |
| 141 } | 144 } |
| 142 | 145 |
| 143 void AudioPipe::OnPrimeRequested(const PrimeCallback& cbk) { | 146 void AudioPipe::OnPrimeRequested(const PrimeCallback& cbk) { |
| 144 if (!prime_callback_.is_null()) { | 147 if (!prime_callback_.is_null()) { |
| 145 // Prime was already requested. Complete the old one and warn. | 148 // Prime was already requested. Complete the old one and warn. |
| 146 LOG(WARNING) << "multiple prime requests received"; | 149 LOG(WARNING) << "multiple prime requests received"; |
| 147 prime_callback_.Run(); | 150 prime_callback_.Run(); |
| 148 } | 151 } |
| 149 prime_callback_ = cbk; | 152 prime_callback_ = cbk; |
| 150 } | 153 } |
| 151 | 154 |
| 152 bool AudioPipe::OnFlushRequested(const FlushCallback& cbk) { | 155 bool AudioPipe::OnFlushRequested(const FlushCallback& cbk) { |
| 153 DCHECK(owner_); | 156 DCHECK(owner_); |
| 154 next_pts_known_ = false; | 157 next_pts_known_ = false; |
| 155 return owner_->OnFlushRequested(cbk); | 158 return owner_->OnFlushRequested(cbk); |
| 156 } | 159 } |
| 157 | 160 |
| 158 } // namespace audio | 161 } // namespace audio |
| 159 } // namespace media | 162 } // namespace media |
| 160 } // namespace mojo | 163 } // namespace mojo |
| OLD | NEW |