OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // AlsaPcmOutputStream object is *not* thread-safe and should only be used | 7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used |
8 // from the audio thread. We DCHECK on this assumption whenever we can. | 8 // from the audio thread. We DCHECK on this assumption whenever we can. |
9 // | 9 // |
10 // SEMANTICS OF Close() | 10 // SEMANTICS OF Close() |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "base/message_loop.h" | 42 #include "base/message_loop.h" |
43 #include "base/stl_util.h" | 43 #include "base/stl_util.h" |
44 #include "base/time.h" | 44 #include "base/time.h" |
45 #include "media/audio/audio_util.h" | 45 #include "media/audio/audio_util.h" |
46 #include "media/audio/linux/alsa_util.h" | 46 #include "media/audio/linux/alsa_util.h" |
47 #include "media/audio/linux/alsa_wrapper.h" | 47 #include "media/audio/linux/alsa_wrapper.h" |
48 #include "media/audio/linux/audio_manager_linux.h" | 48 #include "media/audio/linux/audio_manager_linux.h" |
49 #include "media/base/data_buffer.h" | 49 #include "media/base/data_buffer.h" |
50 #include "media/base/seekable_buffer.h" | 50 #include "media/base/seekable_buffer.h" |
51 | 51 |
| 52 namespace media { |
| 53 |
52 // Amount of time to wait if we've exhausted the data source. This is to avoid | 54 // Amount of time to wait if we've exhausted the data source. This is to avoid |
53 // busy looping. | 55 // busy looping. |
54 static const uint32 kNoDataSleepMilliseconds = 10; | 56 static const uint32 kNoDataSleepMilliseconds = 10; |
55 | 57 |
56 // Mininum interval between OnMoreData() calls. | 58 // Mininum interval between OnMoreData() calls. |
57 const uint32 kMinIntervalBetweenOnMoreDataCallsInMs = 5; | 59 const uint32 kMinIntervalBetweenOnMoreDataCallsInMs = 5; |
58 | 60 |
59 // According to the linux nanosleep manpage, nanosleep on linux can miss the | 61 // According to the linux nanosleep manpage, nanosleep on linux can miss the |
60 // deadline by up to 10ms because the kernel timeslice is 10ms. Give a 2x | 62 // deadline by up to 10ms because the kernel timeslice is 10ms. Give a 2x |
61 // buffer to compensate for the timeslice, and any additional slowdowns. | 63 // buffer to compensate for the timeslice, and any additional slowdowns. |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 if (source_callback_) | 792 if (source_callback_) |
791 source_callback_->OnError(this, code); | 793 source_callback_->OnError(this, code); |
792 } | 794 } |
793 | 795 |
794 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to | 796 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to |
795 // release ownership of the currently registered callback. | 797 // release ownership of the currently registered callback. |
796 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { | 798 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { |
797 DCHECK(IsOnAudioThread()); | 799 DCHECK(IsOnAudioThread()); |
798 source_callback_ = callback; | 800 source_callback_ = callback; |
799 } | 801 } |
| 802 |
| 803 } // namespace media |
OLD | NEW |