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

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

Issue 10952024: Adding pulseaudio input support to chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased and addressed Dale's final comments. Created 7 years, 10 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
« no previous file with comments | « media/audio/pulse/pulse.sigs ('k') | media/audio/pulse/pulse_input.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_AUDIO_PULSE_PULSE_INPUT_H_
6 #define MEDIA_AUDIO_PULSE_PULSE_INPUT_H_
7
8 #include <string>
9
10 #include "media/audio/audio_device_name.h"
11 #include "media/audio/audio_input_stream_impl.h"
12 #include "media/audio/audio_io.h"
13 #include "media/audio/audio_parameters.h"
14
15 struct pa_context;
16 struct pa_source_info;
17 struct pa_stream;
18 struct pa_threaded_mainloop;
19
20 namespace media {
21
22 class AudioManagerPulse;
23 class SeekableBuffer;
24
25 class PulseAudioInputStream : public AudioInputStreamImpl {
26 public:
27 PulseAudioInputStream(AudioManagerPulse* audio_manager,
28 const std::string& device_name,
29 const AudioParameters& params,
30 pa_threaded_mainloop* mainloop,
31 pa_context* context);
32
33 virtual ~PulseAudioInputStream();
34
35 // Implementation of AudioInputStream.
36 virtual bool Open() OVERRIDE;
37 virtual void Start(AudioInputCallback* callback) OVERRIDE;
38 virtual void Stop() OVERRIDE;
39 virtual void Close() OVERRIDE;
40 virtual double GetMaxVolume() OVERRIDE;
41 virtual void SetVolume(double volume) OVERRIDE;
42 virtual double GetVolume() OVERRIDE;
43
44 private:
45 // PulseAudio Callbacks.
46 static void ReadCallback(pa_stream* handle, size_t length, void* user_data);
47 static void StreamNotifyCallback(pa_stream* stream, void* user_data);
48 static void VolumeCallback(pa_context* context, const pa_source_info* info,
49 int error, void* user_data);
50
51 // Helper for the ReadCallback.
52 void ReadData();
53
54 AudioManagerPulse* audio_manager_;
55 AudioInputCallback* callback_;
56 std::string device_name_;
57 AudioParameters params_;
58 int channels_;
59 double volume_;
60 bool stream_started_;
61
62 // Holds the data from the OS.
63 scoped_ptr<media::SeekableBuffer> buffer_;
64
65 // Temporary storage for recorded data. It gets a packet of data from
66 // |buffer_| and deliver the data to OnData() callback.
67 scoped_array<uint8> audio_data_buffer_;
68
69 // PulseAudio API structs.
70 pa_threaded_mainloop* pa_mainloop_; // Weak.
71 pa_context* pa_context_; // Weak.
72 pa_stream* handle_;
73
74 // Flag indicating the state of the context has been changed.
75 bool context_state_changed_;
76
77 DISALLOW_COPY_AND_ASSIGN(PulseAudioInputStream);
78 };
79
80 } // namespace media
81
82 #endif // MEDIA_AUDIO_PULSE_PULSE_INPUT_H_
OLDNEW
« no previous file with comments | « media/audio/pulse/pulse.sigs ('k') | media/audio/pulse/pulse_input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698