| 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 #ifndef MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ | 5 #ifndef MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ |
| 6 #define MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ | 6 #define MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ |
| 7 | 7 |
| 8 #include <pulse/pulseaudio.h> | 8 #include <pulse/pulseaudio.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "media/audio/audio_device_name.h" | 11 #include "media/audio/audio_device_name.h" |
| 12 #include "media/base/channel_layout.h" | 12 #include "media/base/channel_layout.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 class AudioParameters; | 16 class AudioParameters; |
| 17 | 17 |
| 18 namespace pulse { | 18 namespace pulse { |
| 19 | 19 |
| 20 enum class RequestType : int8_t { INPUT, OUTPUT }; | |
| 21 | |
| 22 // A helper class that acquires pa_threaded_mainloop_lock() while in scope. | 20 // A helper class that acquires pa_threaded_mainloop_lock() while in scope. |
| 23 class AutoPulseLock { | 21 class AutoPulseLock { |
| 24 public: | 22 public: |
| 25 explicit AutoPulseLock(pa_threaded_mainloop* pa_mainloop) | 23 explicit AutoPulseLock(pa_threaded_mainloop* pa_mainloop) |
| 26 : pa_mainloop_(pa_mainloop) { | 24 : pa_mainloop_(pa_mainloop) { |
| 27 pa_threaded_mainloop_lock(pa_mainloop_); | 25 pa_threaded_mainloop_lock(pa_mainloop_); |
| 28 } | 26 } |
| 29 | 27 |
| 30 ~AutoPulseLock() { | 28 ~AutoPulseLock() { |
| 31 pa_threaded_mainloop_unlock(pa_mainloop_); | 29 pa_threaded_mainloop_unlock(pa_mainloop_); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 bool CreateOutputStream(pa_threaded_mainloop** mainloop, | 68 bool CreateOutputStream(pa_threaded_mainloop** mainloop, |
| 71 pa_context** context, | 69 pa_context** context, |
| 72 pa_stream** stream, | 70 pa_stream** stream, |
| 73 const AudioParameters& params, | 71 const AudioParameters& params, |
| 74 const std::string& device_id, | 72 const std::string& device_id, |
| 75 const std::string& app_name, | 73 const std::string& app_name, |
| 76 pa_stream_notify_cb_t stream_callback, | 74 pa_stream_notify_cb_t stream_callback, |
| 77 pa_stream_request_cb_t write_callback, | 75 pa_stream_request_cb_t write_callback, |
| 78 void* user_data); | 76 void* user_data); |
| 79 | 77 |
| 80 // Utility functions to match up outputs and inputs. | |
| 81 std::string GetBusOfInput(pa_threaded_mainloop* mainloop, | |
| 82 pa_context* context, | |
| 83 const std::string& name); | |
| 84 std::string GetOutputCorrespondingTo(pa_threaded_mainloop* mainloop, | |
| 85 pa_context* context, | |
| 86 const std::string& bus); | |
| 87 std::string GetRealDefaultDeviceId(pa_threaded_mainloop* mainloop, | |
| 88 pa_context* context, | |
| 89 RequestType type); | |
| 90 } // namespace pulse | 78 } // namespace pulse |
| 91 | 79 |
| 92 } // namespace media | 80 } // namespace media |
| 93 | 81 |
| 94 #endif // MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ | 82 #endif // MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ |
| OLD | NEW |