OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MEDIA_AUDIO_PULSE_PULSE_UNIFIED_H_ | 5 #ifndef MEDIA_AUDIO_PULSE_PULSE_UNIFIED_H_ |
6 #define MEDIA_AUDIO_PULSE_PULSE_UNIFIED_H_ | 6 #define MEDIA_AUDIO_PULSE_PULSE_UNIFIED_H_ |
7 | 7 |
8 #include <pulse/pulseaudio.h> | 8 #include <pulse/pulseaudio.h> |
| 9 #include <string> |
9 | 10 |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "media/audio/audio_io.h" | 12 #include "media/audio/audio_io.h" |
12 #include "media/audio/audio_parameters.h" | 13 #include "media/audio/audio_parameters.h" |
13 #include "media/base/audio_fifo.h" | 14 #include "media/base/audio_fifo.h" |
14 | 15 |
15 namespace media { | 16 namespace media { |
16 | 17 |
17 class AudioManagerBase; | 18 class AudioManagerBase; |
18 class SeekableBuffer; | 19 class SeekableBuffer; |
19 | 20 |
20 class PulseAudioUnifiedStream : public AudioOutputStream { | 21 class PulseAudioUnifiedStream : public AudioOutputStream { |
21 public: | 22 public: |
22 PulseAudioUnifiedStream(const AudioParameters& params, | 23 PulseAudioUnifiedStream(const AudioParameters& params, |
| 24 const std::string& input_device_id, |
23 AudioManagerBase* manager); | 25 AudioManagerBase* manager); |
24 | 26 |
25 virtual ~PulseAudioUnifiedStream(); | 27 virtual ~PulseAudioUnifiedStream(); |
26 | 28 |
27 // Implementation of PulseAudioUnifiedStream. | 29 // Implementation of PulseAudioUnifiedStream. |
28 virtual bool Open() OVERRIDE; | 30 virtual bool Open() OVERRIDE; |
29 virtual void Close() OVERRIDE; | 31 virtual void Close() OVERRIDE; |
30 virtual void Start(AudioSourceCallback* callback) OVERRIDE; | 32 virtual void Start(AudioSourceCallback* callback) OVERRIDE; |
31 virtual void Stop() OVERRIDE; | 33 virtual void Stop() OVERRIDE; |
32 virtual void SetVolume(double volume) OVERRIDE; | 34 virtual void SetVolume(double volume) OVERRIDE; |
(...skipping 11 matching lines...) Expand all Loading... |
44 // Helpers for ReadCallback() to read and write data. | 46 // Helpers for ReadCallback() to read and write data. |
45 void WriteData(size_t requested_bytes); | 47 void WriteData(size_t requested_bytes); |
46 void ReadData(); | 48 void ReadData(); |
47 | 49 |
48 // Close() helper function to free internal structs. | 50 // Close() helper function to free internal structs. |
49 void Reset(); | 51 void Reset(); |
50 | 52 |
51 // AudioParameters from the constructor. | 53 // AudioParameters from the constructor. |
52 const AudioParameters params_; | 54 const AudioParameters params_; |
53 | 55 |
| 56 // Device unique ID of the input device. |
| 57 const std::string input_device_id_; |
| 58 |
54 // Audio manager that created us. Used to report that we've closed. | 59 // Audio manager that created us. Used to report that we've closed. |
55 AudioManagerBase* manager_; | 60 AudioManagerBase* manager_; |
56 | 61 |
57 // PulseAudio API structs. | 62 // PulseAudio API structs. |
58 pa_context* pa_context_; | 63 pa_context* pa_context_; |
59 pa_threaded_mainloop* pa_mainloop_; | 64 pa_threaded_mainloop* pa_mainloop_; |
60 pa_stream* input_stream_; | 65 pa_stream* input_stream_; |
61 pa_stream* output_stream_; | 66 pa_stream* output_stream_; |
62 | 67 |
63 // Float representation of volume from 0.0 to 1.0. | 68 // Float representation of volume from 0.0 to 1.0. |
(...skipping 12 matching lines...) Expand all Loading... |
76 // Temporary storage for recorded data. It gets a packet of data from | 81 // Temporary storage for recorded data. It gets a packet of data from |
77 // |fifo_| and deliver the data to OnMoreIOData() callback. | 82 // |fifo_| and deliver the data to OnMoreIOData() callback. |
78 scoped_ptr<uint8[]> input_data_buffer_; | 83 scoped_ptr<uint8[]> input_data_buffer_; |
79 | 84 |
80 DISALLOW_COPY_AND_ASSIGN(PulseAudioUnifiedStream); | 85 DISALLOW_COPY_AND_ASSIGN(PulseAudioUnifiedStream); |
81 }; | 86 }; |
82 | 87 |
83 } // namespace media | 88 } // namespace media |
84 | 89 |
85 #endif // MEDIA_AUDIO_PULSE_PULSE_UNIFIED_H_ | 90 #endif // MEDIA_AUDIO_PULSE_PULSE_UNIFIED_H_ |
OLD | NEW |