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

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

Issue 7473021: PulseAudio Sound Playback on Linux (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: "Preprocessor define added Created 9 years, 4 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_
6 #define MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_
7
8 #include <pulse/pulseaudio.h>
9
10 #include <string>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "media/audio/audio_io.h"
14 #include "media/audio/audio_parameters.h"
15
16 namespace media {
17 class SeekableBuffer;
18 }
19
20 class AudioManagerLinux;
21
22 class PulseAudioOutputStream : public AudioOutputStream {
23 public:
24 PulseAudioOutputStream(const AudioParameters& params,
25 AudioManagerLinux* manager);
26
27 virtual ~PulseAudioOutputStream();
28
29 // Implementation of AudioOutputStream.
30 virtual bool Open();
31 virtual void Close();
32 virtual void Start(AudioSourceCallback* callback);
33 virtual void Stop();
34 virtual void SetVolume(double volume);
35 virtual void GetVolume(double* volume);
36
37 private:
38 // PulseAudio Callbacks.
39 static void ContextStateCallback(pa_context* context, void* userdata);
40 static void WriteCallback(pa_stream* stream, size_t length, void* userdata);
41
42 // Functions to get another packet from the data source and write it into the
43 // PulseAudio device.
44 void ClientBufferLoop();
45 void BufferPacketInClient();
46
47 // API for Proxying calls to the AudioSourceCallback provided during Start().
48 uint32 RunDataCallback(uint8* dest,
vrk (LEFT CHROMIUM) 2011/08/10 16:34:51 Can these parameters fit on one line?
slock 2011/08/10 22:41:04 Done. Well two of them can anyway.
49 uint32 max_size,
50 AudioBuffersState buffers_state);
51
52 // Configuration constants from the constructor. Referencable by all threads
53 // since they are constants.
54 const ChannelLayout channel_layout_;
55 const pa_sample_format_t sample_format_;
56 const uint32 sample_rate_;
57 const uint32 bytes_per_frame_;
58
59 // Device configuration data. Populated after OpenTask() completes.
60 uint32 packet_size_;
61 uint32 frames_per_packet_;
62
63 // Flag indicating the code should stop reading from the data source or
64 // writing to the PulseAudio server. This is set because the device has
65 // entered an unrecoverable error state, or the Close() has executed.
66 bool stream_stopped_;
67
68 // Audio manager that created us. Used to report that we've closed.
69 AudioManagerLinux* manager_;
70
71 // PulseAudio API structs.
72 pa_mainloop* pa_mainloop_;
73 pa_mainloop_api* pa_mainloop_api_;
74 pa_context* pa_context_;
75
76 // PulseAudio attribute and specification structs.
77 pa_sample_spec pa_sample_specs_;
78 pa_buffer_attr pa_buffer_attributes_;
79 pa_cvolume pa_volume_;
80
81 // Handle to the actual PulseAudio playback stream.
82 pa_stream* playback_handle_;
83
84 // Internal buffer.
85 scoped_ptr<media::SeekableBuffer> client_buffer_;
86 bool source_exhausted_;
87
88 AudioSourceCallback* source_callback_;
89
90 DISALLOW_COPY_AND_ASSIGN(PulseAudioOutputStream);
91 };
92
93 #endif // MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698