Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: media/audio/pulse/pulse_output.h

Issue 8499029: make pulseaudio available for all posix platforms because it's not linux only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: re-sync with the linux code Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // 6 //
7 // If the stream is successfully opened, Close() must be called before the 7 // If the stream is successfully opened, Close() must be called before the
8 // stream is deleted as Close() is responsible for ensuring resource cleanup 8 // stream is deleted as Close() is responsible for ensuring resource cleanup
9 // occurs. 9 // occurs.
10 // 10 //
11 // This object is designed so that all AudioOutputStream methods will be called 11 // This object is designed so that all AudioOutputStream methods will be called
12 // on the same thread that created the object. 12 // on the same thread that created the object.
13 // 13 //
14 // WARNING: This object blocks on internal PulseAudio calls in Open() while 14 // WARNING: This object blocks on internal PulseAudio calls in Open() while
15 // waiting for PulseAudio's context structure to be ready. It also blocks in 15 // waiting for PulseAudio's context structure to be ready. It also blocks in
16 // inside PulseAudio in Start() and repeated during playback, waiting for 16 // inside PulseAudio in Start() and repeated during playback, waiting for
17 // PulseAudio write callbacks to occur. 17 // PulseAudio write callbacks to occur.
18 18
19 #ifndef MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_ 19 #ifndef MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_
scherkus (not reviewing) 2011/11/16 00:57:56 update header guard
Robert Nagy 2011/11/16 11:59:59 Done.
20 #define MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_ 20 #define MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_
21 21
22 #include <pulse/pulseaudio.h> 22 #include <pulse/pulseaudio.h>
23 23
24 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
25 #include "base/memory/weak_ptr.h" 25 #include "base/memory/weak_ptr.h"
26 #include "base/task.h" 26 #include "base/task.h"
27 #include "media/audio/audio_io.h" 27 #include "media/audio/audio_io.h"
28 #include "media/base/channel_layout.h" 28 #include "media/base/channel_layout.h"
29 29
30 namespace media { 30 namespace media {
31 class SeekableBuffer; 31 class SeekableBuffer;
32 } 32 }
33 33
34 #if defined(OS_LINUX)
34 class AudioManagerLinux; 35 class AudioManagerLinux;
36 typedef AudioManagerLinux AudioManagerPulse;
37 #elif defined(OS_OPENBSD)
38 class AudioManagerOpenBSD;
39 typedef AudioManagerOpenBSD AudioManagerPulse;
40 #else
41 #error Unsupported platform
42 #endif
43
35 struct AudioParameters; 44 struct AudioParameters;
36 class MessageLoop; 45 class MessageLoop;
37 46
38 class PulseAudioOutputStream : public AudioOutputStream { 47 class PulseAudioOutputStream : public AudioOutputStream {
39 public: 48 public:
40 PulseAudioOutputStream(const AudioParameters& params, 49 PulseAudioOutputStream(const AudioParameters& params,
41 AudioManagerLinux* manager, 50 AudioManagerPulse* manager,
42 MessageLoop* message_loop); 51 MessageLoop* message_loop);
43 52
44 virtual ~PulseAudioOutputStream(); 53 virtual ~PulseAudioOutputStream();
45 54
46 // Implementation of AudioOutputStream. 55 // Implementation of AudioOutputStream.
47 virtual bool Open(); 56 virtual bool Open();
48 virtual void Close(); 57 virtual void Close();
49 virtual void Start(AudioSourceCallback* callback); 58 virtual void Start(AudioSourceCallback* callback);
50 virtual void Stop(); 59 virtual void Stop();
51 virtual void SetVolume(double volume); 60 virtual void SetVolume(double volume);
(...skipping 27 matching lines...) Expand all
79 88
80 // Configuration constants from the constructor. Referencable by all threads 89 // Configuration constants from the constructor. Referencable by all threads
81 // since they are constants. 90 // since they are constants.
82 const ChannelLayout channel_layout_; 91 const ChannelLayout channel_layout_;
83 const uint32 channel_count_; 92 const uint32 channel_count_;
84 const pa_sample_format_t sample_format_; 93 const pa_sample_format_t sample_format_;
85 const uint32 sample_rate_; 94 const uint32 sample_rate_;
86 const uint32 bytes_per_frame_; 95 const uint32 bytes_per_frame_;
87 96
88 // Audio manager that created us. Used to report that we've closed. 97 // Audio manager that created us. Used to report that we've closed.
89 AudioManagerLinux* manager_; 98 AudioManagerPulse* manager_;
90 99
91 // PulseAudio API structs. 100 // PulseAudio API structs.
92 pa_context* pa_context_; 101 pa_context* pa_context_;
93 pa_mainloop* pa_mainloop_; 102 pa_mainloop* pa_mainloop_;
94 103
95 // Handle to the actual PulseAudio playback stream. 104 // Handle to the actual PulseAudio playback stream.
96 pa_stream* playback_handle_; 105 pa_stream* playback_handle_;
97 106
98 // Device configuration data. Populated after Open() completes. 107 // Device configuration data. Populated after Open() completes.
99 uint32 packet_size_; 108 uint32 packet_size_;
(...skipping 21 matching lines...) Expand all
121 // Allows us to run tasks on the PulseAudioOutputStream instance which are 130 // Allows us to run tasks on the PulseAudioOutputStream instance which are
122 // bound by its lifetime. 131 // bound by its lifetime.
123 base::WeakPtrFactory<PulseAudioOutputStream> weak_factory_; 132 base::WeakPtrFactory<PulseAudioOutputStream> weak_factory_;
124 133
125 // Callback to audio data source. 134 // Callback to audio data source.
126 AudioSourceCallback* source_callback_; 135 AudioSourceCallback* source_callback_;
127 136
128 DISALLOW_COPY_AND_ASSIGN(PulseAudioOutputStream); 137 DISALLOW_COPY_AND_ASSIGN(PulseAudioOutputStream);
129 }; 138 };
130 139
131 #endif // MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_ 140 #endif // MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_
scherkus (not reviewing) 2011/11/16 00:57:56 down here too
Robert Nagy 2011/11/16 11:59:59 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698