| 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 // Creates an audio output stream based on the PulseAudio asynchronous API; | 5 // Creates an audio output stream based on the PulseAudio asynchronous API; |
| 6 // specifically using the pa_threaded_mainloop model. | 6 // specifically using the pa_threaded_mainloop model. |
| 7 // | 7 // |
| 8 // If the stream is successfully opened, Close() must be called before the | 8 // If the stream is successfully opened, Close() must be called before the |
| 9 // stream is deleted as Close() is responsible for ensuring resource cleanup | 9 // stream is deleted as Close() is responsible for ensuring resource cleanup |
| 10 // occurs. | 10 // occurs. |
| 11 // | 11 // |
| 12 // This object is designed so that all AudioOutputStream methods will be called | 12 // This object is designed so that all AudioOutputStream methods will be called |
| 13 // on the same thread that created the object. | 13 // on the same thread that created the object. |
| 14 // | 14 // |
| 15 // WARNING: This object blocks on internal PulseAudio calls in Open() while | 15 // WARNING: This object blocks on internal PulseAudio calls in Open() while |
| 16 // waiting for PulseAudio's context structure to be ready. It also blocks in | 16 // waiting for PulseAudio's context structure to be ready. It also blocks in |
| 17 // inside PulseAudio in Start() and repeated during playback, waiting for | 17 // inside PulseAudio in Start() and repeated during playback, waiting for |
| 18 // PulseAudio write callbacks to occur. | 18 // PulseAudio write callbacks to occur. |
| 19 | 19 |
| 20 #ifndef MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_ | 20 #ifndef MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_ |
| 21 #define MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_ | 21 #define MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_ |
| 22 | 22 |
| 23 #include <pulse/pulseaudio.h> | 23 #include <pulse/pulseaudio.h> |
| 24 #include <stddef.h> | 24 #include <stddef.h> |
| 25 | 25 |
| 26 #include <memory> |
| 26 #include <string> | 27 #include <string> |
| 27 | 28 |
| 28 #include "base/macros.h" | 29 #include "base/macros.h" |
| 29 #include "base/memory/scoped_ptr.h" | |
| 30 #include "base/threading/thread_checker.h" | 30 #include "base/threading/thread_checker.h" |
| 31 #include "media/audio/audio_io.h" | 31 #include "media/audio/audio_io.h" |
| 32 #include "media/base/audio_parameters.h" | 32 #include "media/base/audio_parameters.h" |
| 33 | 33 |
| 34 struct pa_context; | 34 struct pa_context; |
| 35 struct pa_operation; | 35 struct pa_operation; |
| 36 struct pa_stream; | 36 struct pa_stream; |
| 37 struct pa_threaded_mainloop; | 37 struct pa_threaded_mainloop; |
| 38 | 38 |
| 39 namespace media { | 39 namespace media { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 pa_stream* pa_stream_; | 104 pa_stream* pa_stream_; |
| 105 | 105 |
| 106 // Float representation of volume from 0.0 to 1.0. | 106 // Float representation of volume from 0.0 to 1.0. |
| 107 float volume_; | 107 float volume_; |
| 108 | 108 |
| 109 // Callback to audio data source. Must only be modified while holding a lock | 109 // Callback to audio data source. Must only be modified while holding a lock |
| 110 // on |pa_mainloop_| via pa_threaded_mainloop_lock(). | 110 // on |pa_mainloop_| via pa_threaded_mainloop_lock(). |
| 111 AudioSourceCallback* source_callback_; | 111 AudioSourceCallback* source_callback_; |
| 112 | 112 |
| 113 // Container for retrieving data from AudioSourceCallback::OnMoreData(). | 113 // Container for retrieving data from AudioSourceCallback::OnMoreData(). |
| 114 scoped_ptr<AudioBus> audio_bus_; | 114 std::unique_ptr<AudioBus> audio_bus_; |
| 115 | 115 |
| 116 base::ThreadChecker thread_checker_; | 116 base::ThreadChecker thread_checker_; |
| 117 | 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(PulseAudioOutputStream); | 118 DISALLOW_COPY_AND_ASSIGN(PulseAudioOutputStream); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 } // namespace media | 121 } // namespace media |
| 122 | 122 |
| 123 #endif // MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_ | 123 #endif // MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_ |
| OLD | NEW |