OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_CRAS_CRAS_INPUT_H_ | 5 #ifndef MEDIA_AUDIO_CRAS_CRAS_INPUT_H_ |
6 #define MEDIA_AUDIO_CRAS_CRAS_INPUT_H_ | 6 #define MEDIA_AUDIO_CRAS_CRAS_INPUT_H_ |
7 | 7 |
8 #include <cras_client.h> | 8 #include <cras_client.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "media/audio/agc_audio_stream.h" | 13 #include "media/audio/agc_audio_stream.h" |
14 #include "media/audio/audio_io.h" | 14 #include "media/audio/audio_io.h" |
15 #include "media/audio/audio_parameters.h" | 15 #include "media/audio/audio_parameters.h" |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 | 18 |
19 class AudioManagerCras; | 19 class AudioManagerCras; |
20 | 20 |
21 // Provides an input stream for audio capture based on CRAS, the ChromeOS Audio | 21 // Provides an input stream for audio capture based on CRAS, the ChromeOS Audio |
22 // Server. This object is not thread safe and all methods should be invoked in | 22 // Server. This object is not thread safe and all methods should be invoked in |
23 // the thread that created the object. | 23 // the thread that created the object. |
24 class CrasInputStream : public AgcAudioStream<AudioInputStream> { | 24 class CrasInputStream : public AgcAudioStream<AudioInputStream> { |
25 public: | 25 public: |
26 // The ctor takes all the usual parameters, plus |manager| which is the | 26 // The ctor takes all the usual parameters, plus |manager| which is the |
27 // audio manager who is creating this object. | 27 // audio manager who is creating this object. |
28 CrasInputStream(const AudioParameters& params, AudioManagerCras* manager, | 28 CrasInputStream(const AudioParameters& params, |
| 29 AudioManagerCras* manager, |
29 const std::string& device_id); | 30 const std::string& device_id); |
30 | 31 |
31 // The dtor is typically called by the AudioManager only and it is usually | 32 // The dtor is typically called by the AudioManager only and it is usually |
32 // triggered by calling AudioOutputStream::Close(). | 33 // triggered by calling AudioOutputStream::Close(). |
33 virtual ~CrasInputStream(); | 34 ~CrasInputStream() override; |
34 | 35 |
35 // Implementation of AudioInputStream. | 36 // Implementation of AudioInputStream. |
36 virtual bool Open() override; | 37 bool Open() override; |
37 virtual void Start(AudioInputCallback* callback) override; | 38 void Start(AudioInputCallback* callback) override; |
38 virtual void Stop() override; | 39 void Stop() override; |
39 virtual void Close() override; | 40 void Close() override; |
40 virtual double GetMaxVolume() override; | 41 double GetMaxVolume() override; |
41 virtual void SetVolume(double volume) override; | 42 void SetVolume(double volume) override; |
42 virtual double GetVolume() override; | 43 double GetVolume() override; |
43 virtual bool IsMuted() override; | 44 bool IsMuted() override; |
44 | 45 |
45 private: | 46 private: |
46 // Handles requests to get samples from the provided buffer. This will be | 47 // Handles requests to get samples from the provided buffer. This will be |
47 // called by the audio server when it has samples ready. | 48 // called by the audio server when it has samples ready. |
48 static int SamplesReady(cras_client* client, | 49 static int SamplesReady(cras_client* client, |
49 cras_stream_id_t stream_id, | 50 cras_stream_id_t stream_id, |
50 uint8* samples, | 51 uint8* samples, |
51 size_t frames, | 52 size_t frames, |
52 const timespec* sample_ts, | 53 const timespec* sample_ts, |
53 void* arg); | 54 void* arg); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 const CRAS_STREAM_DIRECTION stream_direction_; | 101 const CRAS_STREAM_DIRECTION stream_direction_; |
101 | 102 |
102 scoped_ptr<AudioBus> audio_bus_; | 103 scoped_ptr<AudioBus> audio_bus_; |
103 | 104 |
104 DISALLOW_COPY_AND_ASSIGN(CrasInputStream); | 105 DISALLOW_COPY_AND_ASSIGN(CrasInputStream); |
105 }; | 106 }; |
106 | 107 |
107 } // namespace media | 108 } // namespace media |
108 | 109 |
109 #endif // MEDIA_AUDIO_CRAS_CRAS_INPUT_H_ | 110 #endif // MEDIA_AUDIO_CRAS_CRAS_INPUT_H_ |
OLD | NEW |