| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_GPU_AVDA_CODEC_ALLOCATOR_H_ | 5 #ifndef MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_ |
| 6 #define MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_ | 6 #define MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 public: | 116 public: |
| 117 static AVDACodecAllocator* GetInstance(); | 117 static AVDACodecAllocator* GetInstance(); |
| 118 | 118 |
| 119 // Make sure the construction threads are started for |client|. Returns true | 119 // Make sure the construction threads are started for |client|. Returns true |
| 120 // on success. | 120 // on success. |
| 121 bool StartThread(AVDACodecAllocatorClient* client); | 121 bool StartThread(AVDACodecAllocatorClient* client); |
| 122 | 122 |
| 123 void StopThread(AVDACodecAllocatorClient* client); | 123 void StopThread(AVDACodecAllocatorClient* client); |
| 124 | 124 |
| 125 // Create and configure a MediaCodec synchronously. | 125 // Create and configure a MediaCodec synchronously. |
| 126 std::unique_ptr<MediaCodecBridge> CreateMediaCodecSync( | 126 virtual std::unique_ptr<MediaCodecBridge> CreateMediaCodecSync( |
| 127 scoped_refptr<CodecConfig> codec_config); | 127 scoped_refptr<CodecConfig> codec_config); |
| 128 | 128 |
| 129 // Create and configure a MediaCodec asynchronously. The result is delivered | 129 // Create and configure a MediaCodec asynchronously. The result is delivered |
| 130 // via OnCodecConfigured(). | 130 // via OnCodecConfigured(). |
| 131 virtual void CreateMediaCodecAsync( | 131 virtual void CreateMediaCodecAsync( |
| 132 base::WeakPtr<AVDACodecAllocatorClient> client, | 132 base::WeakPtr<AVDACodecAllocatorClient> client, |
| 133 scoped_refptr<CodecConfig> codec_config); | 133 scoped_refptr<CodecConfig> codec_config); |
| 134 | 134 |
| 135 // Asynchronously release |media_codec| with the attached surface. We will | 135 // Asynchronously release |media_codec| with the attached surface. We will |
| 136 // drop our reference to |surface_bundle| on the main thread after the codec | 136 // drop our reference to |surface_bundle| on the main thread after the codec |
| 137 // is deallocated, since the codec isn't using it anymore. We will not take | 137 // is deallocated, since the codec isn't using it anymore. We will not take |
| 138 // other action on it (e.g., calling ReleaseSurfaceTexture if it has one), | 138 // other action on it (e.g., calling ReleaseSurfaceTexture if it has one), |
| 139 // since some other codec might be going to use it. We just want to be sure | 139 // since some other codec might be going to use it. We just want to be sure |
| 140 // that it outlives |media_codec|. | 140 // that it outlives |media_codec|. |
| 141 // TODO(watk): Bundle the MediaCodec and surface together so you can't get | 141 // TODO(watk): Bundle the MediaCodec and surface together so you can't get |
| 142 // this pairing wrong. | 142 // this pairing wrong. |
| 143 void ReleaseMediaCodec( | 143 virtual void ReleaseMediaCodec( |
| 144 std::unique_ptr<MediaCodecBridge> media_codec, | 144 std::unique_ptr<MediaCodecBridge> media_codec, |
| 145 TaskType task_type, | 145 TaskType task_type, |
| 146 const scoped_refptr<AVDASurfaceBundle>& surface_bundle); | 146 const scoped_refptr<AVDASurfaceBundle>& surface_bundle); |
| 147 | 147 |
| 148 // Returns a hint about whether the construction thread has hung for | 148 // Returns a hint about whether the construction thread has hung for |
| 149 // |task_type|. Note that if a thread isn't started, then we'll just return | 149 // |task_type|. Note that if a thread isn't started, then we'll just return |
| 150 // "not hung", since it'll run on the current thread anyway. The hang | 150 // "not hung", since it'll run on the current thread anyway. The hang |
| 151 // detector will see no pending jobs in that case, so it's automatic. | 151 // detector will see no pending jobs in that case, so it's automatic. |
| 152 bool IsThreadLikelyHung(TaskType task_type); | 152 bool IsThreadLikelyHung(TaskType task_type); |
| 153 | 153 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 // For canceling pending StopThreadTask()s. | 245 // For canceling pending StopThreadTask()s. |
| 246 base::WeakPtrFactory<AVDACodecAllocator> weak_this_factory_; | 246 base::WeakPtrFactory<AVDACodecAllocator> weak_this_factory_; |
| 247 | 247 |
| 248 DISALLOW_COPY_AND_ASSIGN(AVDACodecAllocator); | 248 DISALLOW_COPY_AND_ASSIGN(AVDACodecAllocator); |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 } // namespace media | 251 } // namespace media |
| 252 | 252 |
| 253 #endif // MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_ | 253 #endif // MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_ |
| OLD | NEW |