OLD | NEW |
---|---|
(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 static void StreamSuccessCallback(pa_stream* s, int error, void* user_data); | |
51 | |
52 // Helper for the ReadCallback. | |
53 void ReadData(); | |
54 | |
55 AudioManagerPulse* audio_manager_; | |
56 AudioInputCallback* callback_; | |
57 std::string device_name_; | |
58 AudioParameters params_; | |
59 int channels_; | |
60 double volume_; | |
61 | |
62 // Flag indicating the code should stop reading from the data source or | |
63 // writing to the PulseAudio server. This is set because the device has | |
64 // entered an unrecoverable error state, or the Stio() has executed. | |
DaleCurtis
2013/02/20 00:17:38
Stio?
no longer working on chromium
2013/02/20 14:43:38
Oh, the comment is not valid any more, removed.
| |
65 bool stream_started_; | |
66 | |
67 // Holds the data from the OS. | |
68 scoped_ptr<media::SeekableBuffer> buffer_; | |
69 | |
70 // Temporary storage for recorded data. It gets a packet of data from | |
71 // |buffer_| and deliver the data to OnData() callback. | |
72 scoped_array<uint8> audio_data_buffer_; | |
73 | |
74 // PulseAudio API structs. | |
75 pa_threaded_mainloop* pa_mainloop_; // Weak. | |
76 pa_context* pa_context_; // Weak. | |
77 pa_stream* handle_; | |
78 | |
79 // Flag indicating the state of the context has been changed. | |
80 bool context_state_changed_; | |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(PulseAudioInputStream); | |
83 }; | |
84 | |
85 } // namespace media | |
86 | |
87 #endif // MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ | |
OLD | NEW |