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 pp { | 9 namespace pp { |
10 namespace shared_impl { | 10 namespace shared_impl { |
11 | 11 |
12 AudioImpl::AudioImpl() | 12 AudioImpl::AudioImpl() |
13 : playing_(false), | 13 : playing_(false), |
14 shared_memory_size_(0), | 14 shared_memory_size_(0), |
15 callback_(NULL), | 15 callback_(NULL), |
16 user_data_(NULL) { | 16 user_data_(NULL) { |
17 } | 17 } |
18 | 18 |
19 AudioImpl::~AudioImpl() { | 19 AudioImpl::~AudioImpl() { |
20 // Closing the socket causes the thread to exit - wait for it. | 20 // Closing the socket causes the thread to exit - wait for it. |
21 socket_->Close(); | 21 if (socket_.get()) |
| 22 socket_->Close(); |
22 if (audio_thread_.get()) { | 23 if (audio_thread_.get()) { |
23 audio_thread_->Join(); | 24 audio_thread_->Join(); |
24 audio_thread_.reset(); | 25 audio_thread_.reset(); |
25 } | 26 } |
26 } | 27 } |
27 | 28 |
28 void AudioImpl::SetCallback(PPB_Audio_Callback callback, void* user_data) { | 29 void AudioImpl::SetCallback(PPB_Audio_Callback callback, void* user_data) { |
29 callback_ = callback; | 30 callback_ = callback; |
30 user_data_ = user_data; | 31 user_data_ = user_data; |
31 } | 32 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 pending_data >= 0) { | 88 pending_data >= 0) { |
88 // Exit the thread on pause. | 89 // Exit the thread on pause. |
89 if (pending_data < 0) | 90 if (pending_data < 0) |
90 return; | 91 return; |
91 callback_(buffer, shared_memory_size_, user_data_); | 92 callback_(buffer, shared_memory_size_, user_data_); |
92 } | 93 } |
93 } | 94 } |
94 | 95 |
95 } // namespace shared_impl | 96 } // namespace shared_impl |
96 } // namespace pp | 97 } // namespace pp |
OLD | NEW |