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 // THREAD SAFETY | 5 // THREAD SAFETY |
6 // | 6 // |
7 // The AlsaPcmOutputStream object's internal state is accessed by two threads: | 7 // The AlsaPcmOutputStream object's internal state is accessed by two threads: |
8 // | 8 // |
9 // client thread - creates the object and calls the public APIs. | 9 // client thread - creates the object and calls the public APIs. |
10 // message loop thread - executes all the internal tasks including querying | 10 // message loop thread - executes all the internal tasks including querying |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 // TODO(ajwong): Retry on certain errors? | 749 // TODO(ajwong): Retry on certain errors? |
750 LOG(WARNING) << "Unable to close audio device. Leaking handle."; | 750 LOG(WARNING) << "Unable to close audio device. Leaking handle."; |
751 } | 751 } |
752 return NULL; | 752 return NULL; |
753 } | 753 } |
754 | 754 |
755 return handle; | 755 return handle; |
756 } | 756 } |
757 | 757 |
758 bool AlsaPcmOutputStream::CloseDevice(snd_pcm_t* handle) { | 758 bool AlsaPcmOutputStream::CloseDevice(snd_pcm_t* handle) { |
759 std::string name = wrapper_->PcmName(handle); | |
760 int error = wrapper_->PcmClose(handle); | 759 int error = wrapper_->PcmClose(handle); |
761 if (error < 0) { | 760 if (error < 0) { |
762 LOG(ERROR) << "Error closing audio device (" << name << "): " | 761 LOG(ERROR) << "Cannot close audio device (" << wrapper_->PcmName(handle) |
763 << wrapper_->StrError(error); | 762 << "): " << wrapper_->StrError(error); |
764 return false; | 763 return false; |
765 } | 764 } |
766 | 765 |
767 return true; | 766 return true; |
768 } | 767 } |
769 | 768 |
770 snd_pcm_sframes_t AlsaPcmOutputStream::GetAvailableFrames() { | 769 snd_pcm_sframes_t AlsaPcmOutputStream::GetAvailableFrames() { |
771 DCHECK_EQ(MessageLoop::current(), message_loop_); | 770 DCHECK_EQ(MessageLoop::current(), message_loop_); |
772 | 771 |
773 if (stop_stream_) { | 772 if (stop_stream_) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 } | 948 } |
950 | 949 |
951 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to | 950 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to |
952 // release ownership of the currently registered callback. | 951 // release ownership of the currently registered callback. |
953 void AlsaPcmOutputStream::SharedData::set_source_callback( | 952 void AlsaPcmOutputStream::SharedData::set_source_callback( |
954 AudioSourceCallback* callback) { | 953 AudioSourceCallback* callback) { |
955 DCHECK_EQ(MessageLoop::current(), state_transition_loop_); | 954 DCHECK_EQ(MessageLoop::current(), state_transition_loop_); |
956 AutoLock l(lock_); | 955 AutoLock l(lock_); |
957 source_callback_ = callback; | 956 source_callback_ = callback; |
958 } | 957 } |
OLD | NEW |