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 |
20 // A helper class that acquires pa_threaded_mainloop_lock() while in scope. | 22 // A helper class that acquires pa_threaded_mainloop_lock() while in scope. |
21 class AutoPulseLock { | 23 class AutoPulseLock { |
22 public: | 24 public: |
23 explicit AutoPulseLock(pa_threaded_mainloop* pa_mainloop) | 25 explicit AutoPulseLock(pa_threaded_mainloop* pa_mainloop) |
24 : pa_mainloop_(pa_mainloop) { | 26 : pa_mainloop_(pa_mainloop) { |
25 pa_threaded_mainloop_lock(pa_mainloop_); | 27 pa_threaded_mainloop_lock(pa_mainloop_); |
26 } | 28 } |
27 | 29 |
28 ~AutoPulseLock() { | 30 ~AutoPulseLock() { |
29 pa_threaded_mainloop_unlock(pa_mainloop_); | 31 pa_threaded_mainloop_unlock(pa_mainloop_); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 bool CreateOutputStream(pa_threaded_mainloop** mainloop, | 70 bool CreateOutputStream(pa_threaded_mainloop** mainloop, |
69 pa_context** context, | 71 pa_context** context, |
70 pa_stream** stream, | 72 pa_stream** stream, |
71 const AudioParameters& params, | 73 const AudioParameters& params, |
72 const std::string& device_id, | 74 const std::string& device_id, |
73 const std::string& app_name, | 75 const std::string& app_name, |
74 pa_stream_notify_cb_t stream_callback, | 76 pa_stream_notify_cb_t stream_callback, |
75 pa_stream_request_cb_t write_callback, | 77 pa_stream_request_cb_t write_callback, |
76 void* user_data); | 78 void* user_data); |
77 | 79 |
| 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); |
78 } // namespace pulse | 90 } // namespace pulse |
79 | 91 |
80 } // namespace media | 92 } // namespace media |
81 | 93 |
82 #endif // MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ | 94 #endif // MEDIA_AUDIO_PULSE_PULSE_UTIL_H_ |
OLD | NEW |