OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "ppapi/shared_impl/audio_impl.h" | 5 #include "ppapi/shared_impl/audio_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace ppapi { | 9 namespace ppapi { |
10 | 10 |
11 AudioImpl::AudioImpl() | 11 AudioImpl::AudioImpl() |
12 : playing_(false), | 12 : playing_(false), |
13 shared_memory_size_(0), | 13 shared_memory_size_(0), |
14 callback_(NULL), | 14 callback_(NULL), |
15 user_data_(NULL) { | 15 user_data_(NULL) { |
16 } | 16 } |
17 | 17 |
18 AudioImpl::~AudioImpl() { | 18 AudioImpl::~AudioImpl() { |
19 // Closing the socket causes the thread to exit - wait for it. | 19 // Closing the socket causes the thread to exit - wait for it. |
20 if (socket_.get()) | 20 if (socket_.get()) |
21 socket_->Close(); | 21 socket_->Close(); |
22 if (audio_thread_.get()) { | 22 if (audio_thread_.get()) { |
23 audio_thread_->Join(); | 23 audio_thread_->Join(); |
24 audio_thread_.reset(); | 24 audio_thread_.reset(); |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 ::ppapi::thunk::PPB_Audio_API* AudioImpl::AsAudio_API() { | 28 ::ppapi::thunk::PPB_Audio_API* AudioImpl::AsPPB_Audio_API() { |
29 return this; | 29 return this; |
30 } | 30 } |
31 | 31 |
32 void AudioImpl::SetCallback(PPB_Audio_Callback callback, void* user_data) { | 32 void AudioImpl::SetCallback(PPB_Audio_Callback callback, void* user_data) { |
33 callback_ = callback; | 33 callback_ = callback; |
34 user_data_ = user_data; | 34 user_data_ = user_data; |
35 } | 35 } |
36 | 36 |
37 void AudioImpl::SetStartPlaybackState() { | 37 void AudioImpl::SetStartPlaybackState() { |
38 DCHECK(!playing_); | 38 DCHECK(!playing_); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 socket_->Receive(&pending_data, sizeof(pending_data)) && | 90 socket_->Receive(&pending_data, sizeof(pending_data)) && |
91 pending_data >= 0) { | 91 pending_data >= 0) { |
92 // Exit the thread on pause. | 92 // Exit the thread on pause. |
93 if (pending_data < 0) | 93 if (pending_data < 0) |
94 return; | 94 return; |
95 callback_(buffer, shared_memory_size_, user_data_); | 95 callback_(buffer, shared_memory_size_, user_data_); |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 } // namespace ppapi | 99 } // namespace ppapi |
OLD | NEW |