OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ |
| 6 #define MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ |
| 7 |
| 8 #include <pulse/pulseaudio.h> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "media/audio/audio_device_name.h" |
| 12 #include "media/base/channel_layout.h" |
| 13 |
| 14 namespace media { |
| 15 |
| 16 // A helper class that acquires pa_threaded_mainloop_lock() while in scope. |
| 17 class AutoPulseLock { |
| 18 public: |
| 19 explicit AutoPulseLock(pa_threaded_mainloop* pa_mainloop) |
| 20 : pa_mainloop_(pa_mainloop) { |
| 21 pa_threaded_mainloop_lock(pa_mainloop_); |
| 22 } |
| 23 |
| 24 ~AutoPulseLock() { |
| 25 pa_threaded_mainloop_unlock(pa_mainloop_); |
| 26 } |
| 27 |
| 28 private: |
| 29 pa_threaded_mainloop* pa_mainloop_; |
| 30 DISALLOW_COPY_AND_ASSIGN(AutoPulseLock); |
| 31 }; |
| 32 |
| 33 // Triggers pa_threaded_mainloop_signal() to avoid deadlocks. |
| 34 void StreamSuccessCallback(pa_stream* s, int error, void* mainloop); |
| 35 |
| 36 // Triggers pa_threaded_mainloop_signal() to avoid deadlocks. |
| 37 void ContextStateCallback(pa_context* context, void* user_data); |
| 38 |
| 39 pa_sample_format_t BitsToPASampleFormat(int bits_per_sample); |
| 40 |
| 41 pa_channel_map ChannelLayoutToPAChannelMap(ChannelLayout channel_layout); |
| 42 |
| 43 void WaitForOperationCompletion(pa_threaded_mainloop* pa_mainloop, |
| 44 pa_operation* operation); |
| 45 |
| 46 int GetHardwareLatencyInBytes(pa_stream* stream, |
| 47 int sample_rate, |
| 48 int bytes_per_frame); |
| 49 |
| 50 } // namespace media |
| 51 |
| 52 #endif // MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ |
OLD | NEW |