OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/histogram.h" | 5 #include "base/histogram.h" |
6 #include "base/lock.h" | 6 #include "base/lock.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/process.h" | 8 #include "base/process.h" |
9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.h" |
10 #include "base/waitable_event.h" | 10 #include "base/waitable_event.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 | 145 |
146 void AudioRendererHost::IPCAudioSource::Play() { | 146 void AudioRendererHost::IPCAudioSource::Play() { |
147 // We can start from created or paused state. | 147 // We can start from created or paused state. |
148 if (!stream_ || (state_ != kCreated && state_ != kPaused)) | 148 if (!stream_ || (state_ != kCreated && state_ != kPaused)) |
149 return; | 149 return; |
150 | 150 |
151 stream_->Start(this); | 151 stream_->Start(this); |
152 | 152 |
153 // Update the state and notify renderer. | 153 // Update the state and notify renderer. |
154 state_ = kPaused; | 154 state_ = kPlaying; |
155 | 155 |
156 ViewMsg_AudioStreamState state; | 156 ViewMsg_AudioStreamState state; |
157 state.state = ViewMsg_AudioStreamState::kPlaying; | 157 state.state = ViewMsg_AudioStreamState::kPlaying; |
158 host_->Send(new ViewMsg_NotifyAudioStreamStateChanged( | 158 host_->Send(new ViewMsg_NotifyAudioStreamStateChanged( |
159 route_id_, stream_id_, state)); | 159 route_id_, stream_id_, state)); |
160 } | 160 } |
161 | 161 |
162 void AudioRendererHost::IPCAudioSource::Pause() { | 162 void AudioRendererHost::IPCAudioSource::Pause() { |
163 // We can pause from started state. | 163 // We can pause from started state. |
164 if (!stream_ || state_ != kPlaying) | 164 if (!stream_ || state_ != kPlaying) |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 if (MessageLoop::current() == io_loop_) { | 548 if (MessageLoop::current() == io_loop_) { |
549 OnDestroySource(source); | 549 OnDestroySource(source); |
550 } else { | 550 } else { |
551 // TODO(hclam): make sure it's always safe to post a task to IO loop. | 551 // TODO(hclam): make sure it's always safe to post a task to IO loop. |
552 // It is possible that IO message loop is destroyed but there's still some | 552 // It is possible that IO message loop is destroyed but there's still some |
553 // dangling audio hardware threads that try to call this method. | 553 // dangling audio hardware threads that try to call this method. |
554 io_loop_->PostTask(FROM_HERE, | 554 io_loop_->PostTask(FROM_HERE, |
555 NewRunnableMethod(this, &AudioRendererHost::OnDestroySource, source)); | 555 NewRunnableMethod(this, &AudioRendererHost::OnDestroySource, source)); |
556 } | 556 } |
557 } | 557 } |
OLD | NEW |