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. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 virtual void SetVolume(double volume) OVERRIDE; | 47 virtual void SetVolume(double volume) OVERRIDE; |
48 virtual void GetVolume(double* volume) OVERRIDE; | 48 virtual void GetVolume(double* volume) OVERRIDE; |
49 | 49 |
50 private: | 50 private: |
51 // Called by PulseAudio when |pa_context_| and |pa_stream_| change state. If | 51 // Called by PulseAudio when |pa_context_| and |pa_stream_| change state. If |
52 // an unexpected failure state change happens and |source_callback_| is set | 52 // an unexpected failure state change happens and |source_callback_| is set |
53 // these methods will forward the error via OnError(). | 53 // these methods will forward the error via OnError(). |
54 static void ContextNotifyCallback(pa_context* c, void* p_this); | 54 static void ContextNotifyCallback(pa_context* c, void* p_this); |
55 static void StreamNotifyCallback(pa_stream* s, void* p_this); | 55 static void StreamNotifyCallback(pa_stream* s, void* p_this); |
56 | 56 |
57 // Triggers pa_threaded_mainloop_signal() to avoid deadlocks. | |
58 static void StreamSuccessCallback(pa_stream* s, int success, void* p_this); | |
59 | |
60 // Called by PulseAudio when it needs more audio data. | 57 // Called by PulseAudio when it needs more audio data. |
61 static void StreamRequestCallback(pa_stream* s, size_t len, void* p_this); | 58 static void StreamRequestCallback(pa_stream* s, size_t len, void* p_this); |
62 | 59 |
63 // Fulfill a write request from the write request callback. Outputs silence | 60 // Fulfill a write request from the write request callback. Outputs silence |
64 // if the request could not be fulfilled. | 61 // if the request could not be fulfilled. |
65 void FulfillWriteRequest(size_t requested_bytes); | 62 void FulfillWriteRequest(size_t requested_bytes); |
66 | 63 |
67 // Close() helper function to free internal structs. | 64 // Close() helper function to free internal structs. |
68 void Reset(); | 65 void Reset(); |
69 | 66 |
(...skipping 23 matching lines...) Expand all Loading... |
93 | 90 |
94 // Container for retrieving data from AudioSourceCallback::OnMoreData(). | 91 // Container for retrieving data from AudioSourceCallback::OnMoreData(). |
95 scoped_ptr<AudioBus> audio_bus_; | 92 scoped_ptr<AudioBus> audio_bus_; |
96 | 93 |
97 DISALLOW_COPY_AND_ASSIGN(PulseAudioOutputStream); | 94 DISALLOW_COPY_AND_ASSIGN(PulseAudioOutputStream); |
98 }; | 95 }; |
99 | 96 |
100 } // namespace media | 97 } // namespace media |
101 | 98 |
102 #endif // MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_ | 99 #endif // MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_ |
OLD | NEW |