| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_AUDIO_MANAGER_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_H_ | 
| 6 #define MEDIA_AUDIO_AUDIO_MANAGER_H_ | 6 #define MEDIA_AUDIO_AUDIO_MANAGER_H_ | 
| 7 | 7 | 
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" | 
| 9 #include "media/audio/audio_parameters.h" | 9 #include "media/audio/audio_parameters.h" | 
| 10 | 10 | 
| 11 class AudioInputStream; | 11 class AudioInputStream; | 
| 12 class AudioOutputStream; | 12 class AudioOutputStream; | 
| 13 class MessageLoop; | 13 class MessageLoop; | 
| 14 | 14 | 
|  | 15 // TODO(sergeyu): In this interface and some other places AudioParameters struct | 
|  | 16 // is passed by value. It is better to change it to const reference. | 
|  | 17 | 
| 15 // Manages all audio resources. In particular it owns the AudioOutputStream | 18 // Manages all audio resources. In particular it owns the AudioOutputStream | 
| 16 // objects. Provides some convenience functions that avoid the need to provide | 19 // objects. Provides some convenience functions that avoid the need to provide | 
| 17 // iterators over the existing streams. | 20 // iterators over the existing streams. | 
| 18 class AudioManager { | 21 class AudioManager { | 
| 19  public: | 22  public: | 
| 20   // Returns true if the OS reports existence of audio devices. This does not | 23   // Returns true if the OS reports existence of audio devices. This does not | 
| 21   // guarantee that the existing devices support all formats and sample rates. | 24   // guarantee that the existing devices support all formats and sample rates. | 
| 22   virtual bool HasAudioOutputDevices() = 0; | 25   virtual bool HasAudioOutputDevices() = 0; | 
| 23 | 26 | 
| 24   // Returns true if the OS reports existence of audio recording devices. This | 27   // Returns true if the OS reports existence of audio recording devices. This | 
| 25   // does not guarantee that the existing devices support all formats and | 28   // does not guarantee that the existing devices support all formats and | 
| 26   // sample rates. | 29   // sample rates. | 
| 27   virtual bool HasAudioInputDevices() = 0; | 30   virtual bool HasAudioInputDevices() = 0; | 
| 28 | 31 | 
| 29   // Factory for all the supported stream formats. The |channels| can be 1 to 5. | 32   // Factory for all the supported stream formats. |params| defines parameters | 
| 30   // The |sample_rate| is in hertz and can be any value supported by the | 33   // of the audio stream to be created. | 
| 31   // platform. For some future formats the |sample_rate| and |bits_per_sample| | 34   // | 
| 32   // can take special values. | 35   // |params.sample_per_packet| is the requested buffer allocation which the | 
|  | 36   // audio source thinks it can usually fill without blocking. Internally two | 
|  | 37   // or three buffers are created, one will be locked for playback and one will | 
|  | 38   // be ready to be filled in the call to AudioSourceCallback::OnMoreData(). | 
|  | 39   // | 
| 33   // Returns NULL if the combination of the parameters is not supported, or if | 40   // Returns NULL if the combination of the parameters is not supported, or if | 
| 34   // we have reached some other platform specific limit. | 41   // we have reached some other platform specific limit. | 
| 35   // | 42   // | 
| 36   // AUDIO_PCM_LOW_LATENCY can be passed to this method and it has two effects: | 43   // |params.format| can be set to AUDIO_PCM_LOW_LATENCY and that has two | 
|  | 44   // effects: | 
| 37   // 1- Instead of triple buffered the audio will be double buffered. | 45   // 1- Instead of triple buffered the audio will be double buffered. | 
| 38   // 2- A low latency driver or alternative audio subsystem will be used when | 46   // 2- A low latency driver or alternative audio subsystem will be used when | 
| 39   //    available. | 47   //    available. | 
| 40   // | 48   // | 
| 41   // Do not free the returned AudioOutputStream. It is owned by AudioManager. | 49   // Do not free the returned AudioOutputStream. It is owned by AudioManager. | 
| 42   virtual AudioOutputStream* MakeAudioOutputStream(AudioParameters params) = 0; | 50   virtual AudioOutputStream* MakeAudioOutputStream(AudioParameters params) = 0; | 
| 43 | 51 | 
| 44   // Factory to create audio recording streams. | 52   // Factory to create audio recording streams. | 
| 45   // |channels| can be 1 or 2. | 53   // |channels| can be 1 or 2. | 
| 46   // |sample_rate| is in hertz and can be any value supported by the platform. | 54   // |sample_rate| is in hertz and can be any value supported by the platform. | 
| 47   // |bits_per_sample| can be any value supported by the platform. | 55   // |bits_per_sample| can be any value supported by the platform. | 
| 48   // |samples_per_packet| is in hertz as well and can be 0 to |sample_rate|, | 56   // |samples_per_packet| is in hertz as well and can be 0 to |sample_rate|, | 
| 49   // with 0 suggesting that the implementation use a default value for that | 57   // with 0 suggesting that the implementation use a default value for that | 
| 50   // platform. | 58   // platform. | 
| 51   // Returns NULL if the combination of the parameters is not supported, or if | 59   // Returns NULL if the combination of the parameters is not supported, or if | 
| 52   // we have reached some other platform specific limit. | 60   // we have reached some other platform specific limit. | 
| 53   // | 61   // | 
| 54   // Do not free the returned AudioInputStream. It is owned by AudioManager. | 62   // Do not free the returned AudioInputStream. It is owned by AudioManager. | 
| 55   // When you are done with it, call |Stop()| and |Close()| to release it. | 63   // When you are done with it, call |Stop()| and |Close()| to release it. | 
| 56   virtual AudioInputStream* MakeAudioInputStream(AudioParameters params, | 64   virtual AudioInputStream* MakeAudioInputStream(AudioParameters params) = 0; | 
| 57                                                  int samples_per_packet) = 0; |  | 
| 58 | 65 | 
| 59   // Muting continues playback but effectively the volume is set to zero. | 66   // Muting continues playback but effectively the volume is set to zero. | 
| 60   // Un-muting returns the volume to the previous level. | 67   // Un-muting returns the volume to the previous level. | 
| 61   virtual void MuteAll() = 0; | 68   virtual void MuteAll() = 0; | 
| 62   virtual void UnMuteAll() = 0; | 69   virtual void UnMuteAll() = 0; | 
| 63 | 70 | 
| 64   // Returns message loop used for audio IO. | 71   // Returns message loop used for audio IO. | 
| 65   virtual MessageLoop* GetMessageLoop() = 0; | 72   virtual MessageLoop* GetMessageLoop() = 0; | 
| 66 | 73 | 
| 67   // Get AudioManager singleton. | 74   // Get AudioManager singleton. | 
| 68   // TODO(cpu): Define threading requirements for interacting with AudioManager. | 75   // TODO(cpu): Define threading requirements for interacting with AudioManager. | 
| 69   static AudioManager* GetAudioManager(); | 76   static AudioManager* GetAudioManager(); | 
| 70 | 77 | 
| 71  protected: | 78  protected: | 
| 72   virtual ~AudioManager() {} | 79   virtual ~AudioManager() {} | 
| 73 | 80 | 
| 74   // Called from GetAudioManager() to initialiaze the instance. | 81   // Called from GetAudioManager() to initialiaze the instance. | 
| 75   virtual void Init() = 0; | 82   virtual void Init() = 0; | 
| 76 | 83 | 
| 77  private: | 84  private: | 
| 78   static void Destroy(void*); | 85   static void Destroy(void*); | 
| 79 | 86 | 
| 80   // Called by GetAudioManager() to create platform-specific audio manager. | 87   // Called by GetAudioManager() to create platform-specific audio manager. | 
| 81   static AudioManager* CreateAudioManager(); | 88   static AudioManager* CreateAudioManager(); | 
| 82 }; | 89 }; | 
| 83 | 90 | 
| 84 #endif  // MEDIA_AUDIO_AUDIO_MANAGER_H_ | 91 #endif  // MEDIA_AUDIO_AUDIO_MANAGER_H_ | 
| OLD | NEW | 
|---|