| 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 // Audio rendering unit utilizing audio output stream provided by browser | 5 // Audio rendering unit utilizing audio output stream provided by browser | 
| 6 // process through IPC. | 6 // process through IPC. | 
| 7 // | 7 // | 
| 8 // Relationship of classes. | 8 // Relationship of classes. | 
| 9 // | 9 // | 
| 10 //  AudioOutputController                AudioOutputDevice | 10 //  AudioOutputController                AudioOutputDevice | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 82       const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 82       const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 
| 83 | 83 | 
| 84   // Initialize the stream using |session_id|, which is used for the browser | 84   // Initialize the stream using |session_id|, which is used for the browser | 
| 85   // to select the correct input device. | 85   // to select the correct input device. | 
| 86   void InitializeWithSessionId(const AudioParameters& params, | 86   void InitializeWithSessionId(const AudioParameters& params, | 
| 87                                RenderCallback* callback, | 87                                RenderCallback* callback, | 
| 88                                int session_id); | 88                                int session_id); | 
| 89 | 89 | 
| 90   // AudioRendererSink implementation. | 90   // AudioRendererSink implementation. | 
| 91   virtual void Initialize(const AudioParameters& params, | 91   virtual void Initialize(const AudioParameters& params, | 
| 92                           RenderCallback* callback) OVERRIDE; | 92                           RenderCallback* callback) override; | 
| 93   virtual void Start() OVERRIDE; | 93   virtual void Start() override; | 
| 94   virtual void Stop() OVERRIDE; | 94   virtual void Stop() override; | 
| 95   virtual void Play() OVERRIDE; | 95   virtual void Play() override; | 
| 96   virtual void Pause() OVERRIDE; | 96   virtual void Pause() override; | 
| 97   virtual bool SetVolume(double volume) OVERRIDE; | 97   virtual bool SetVolume(double volume) override; | 
| 98 | 98 | 
| 99   // Methods called on IO thread ---------------------------------------------- | 99   // Methods called on IO thread ---------------------------------------------- | 
| 100   // AudioOutputIPCDelegate methods. | 100   // AudioOutputIPCDelegate methods. | 
| 101   virtual void OnStateChanged(AudioOutputIPCDelegate::State state) OVERRIDE; | 101   virtual void OnStateChanged(AudioOutputIPCDelegate::State state) override; | 
| 102   virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 102   virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 
| 103                                base::SyncSocket::Handle socket_handle, | 103                                base::SyncSocket::Handle socket_handle, | 
| 104                                int length) OVERRIDE; | 104                                int length) override; | 
| 105   virtual void OnIPCClosed() OVERRIDE; | 105   virtual void OnIPCClosed() override; | 
| 106 | 106 | 
| 107  protected: | 107  protected: | 
| 108   // Magic required by ref_counted.h to avoid any code deleting the object | 108   // Magic required by ref_counted.h to avoid any code deleting the object | 
| 109   // accidentally while there are references to it. | 109   // accidentally while there are references to it. | 
| 110   friend class base::RefCountedThreadSafe<AudioOutputDevice>; | 110   friend class base::RefCountedThreadSafe<AudioOutputDevice>; | 
| 111   virtual ~AudioOutputDevice(); | 111   virtual ~AudioOutputDevice(); | 
| 112 | 112 | 
| 113  private: | 113  private: | 
| 114   // Note: The ordering of members in this enum is critical to correct behavior! | 114   // Note: The ordering of members in this enum is critical to correct behavior! | 
| 115   enum State { | 115   enum State { | 
| 116     IPC_CLOSED,  // No more IPCs can take place. | 116     IPC_CLOSED,  // No more IPCs can take place. | 
| 117     IDLE,  // Not started. | 117     IDLE,  // Not started. | 
| 118     CREATING_STREAM,  // Waiting for OnStreamCreated() to be called back. | 118     CREATING_STREAM,  // Waiting for OnStreamCreated() to be called back. | 
| 119     PAUSED,  // Paused.  OnStreamCreated() has been called.  Can Play()/Stop(). | 119     PAUSED,  // Paused.  OnStreamCreated() has been called.  Can Play()/Stop(). | 
| 120     PLAYING,  // Playing back.  Can Pause()/Stop(). | 120     PLAYING,  // Playing back.  Can Pause()/Stop(). | 
| 121   }; | 121   }; | 
| 122 | 122 | 
| 123   // Methods called on IO thread ---------------------------------------------- | 123   // Methods called on IO thread ---------------------------------------------- | 
| 124   // The following methods are tasks posted on the IO thread that need to | 124   // The following methods are tasks posted on the IO thread that need to | 
| 125   // be executed on that thread.  They use AudioOutputIPC to send IPC messages | 125   // be executed on that thread.  They use AudioOutputIPC to send IPC messages | 
| 126   // upon state changes. | 126   // upon state changes. | 
| 127   void CreateStreamOnIOThread(const AudioParameters& params); | 127   void CreateStreamOnIOThread(const AudioParameters& params); | 
| 128   void PlayOnIOThread(); | 128   void PlayOnIOThread(); | 
| 129   void PauseOnIOThread(); | 129   void PauseOnIOThread(); | 
| 130   void ShutDownOnIOThread(); | 130   void ShutDownOnIOThread(); | 
| 131   void SetVolumeOnIOThread(double volume); | 131   void SetVolumeOnIOThread(double volume); | 
| 132 | 132 | 
| 133   // base::MessageLoop::DestructionObserver implementation for the IO loop. | 133   // base::MessageLoop::DestructionObserver implementation for the IO loop. | 
| 134   // If the IO loop dies before we do, we shut down the audio thread from here. | 134   // If the IO loop dies before we do, we shut down the audio thread from here. | 
| 135   virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 135   virtual void WillDestroyCurrentMessageLoop() override; | 
| 136 | 136 | 
| 137   AudioParameters audio_parameters_; | 137   AudioParameters audio_parameters_; | 
| 138 | 138 | 
| 139   RenderCallback* callback_; | 139   RenderCallback* callback_; | 
| 140 | 140 | 
| 141   // A pointer to the IPC layer that takes care of sending requests over to | 141   // A pointer to the IPC layer that takes care of sending requests over to | 
| 142   // the AudioRendererHost.  Only valid when state_ != IPC_CLOSED and must only | 142   // the AudioRendererHost.  Only valid when state_ != IPC_CLOSED and must only | 
| 143   // be accessed on the IO thread. | 143   // be accessed on the IO thread. | 
| 144   scoped_ptr<AudioOutputIPC> ipc_; | 144   scoped_ptr<AudioOutputIPC> ipc_; | 
| 145 | 145 | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 170   // TODO(scherkus): Replace this by changing AudioRendererSink to either accept | 170   // TODO(scherkus): Replace this by changing AudioRendererSink to either accept | 
| 171   // the callback via Start(). See http://crbug.com/151051 for details. | 171   // the callback via Start(). See http://crbug.com/151051 for details. | 
| 172   bool stopping_hack_; | 172   bool stopping_hack_; | 
| 173 | 173 | 
| 174   DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); | 174   DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); | 
| 175 }; | 175 }; | 
| 176 | 176 | 
| 177 }  // namespace media | 177 }  // namespace media | 
| 178 | 178 | 
| 179 #endif  // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ | 179 #endif  // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ | 
| OLD | NEW | 
|---|