Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Unified Diff: media/gpu/avda_codec_allocator.h

Issue 2629223003: media: Ensure MediaCodecs are released before attached SurfaceTextures (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/gpu/avda_codec_allocator.h
diff --git a/media/gpu/avda_codec_allocator.h b/media/gpu/avda_codec_allocator.h
index 180a91acb1e4fd762c772be808def655420f64e8..37b45564e4565b4f551143722eba4c18c59436d3 100644
--- a/media/gpu/avda_codec_allocator.h
+++ b/media/gpu/avda_codec_allocator.h
@@ -28,6 +28,7 @@
#include "media/gpu/media_gpu_export.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gl/android/scoped_java_surface.h"
+#include "ui/gl/android/surface_texture.h"
namespace media {
@@ -140,12 +141,23 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
void CreateMediaCodecAsync(base::WeakPtr<AVDACodecAllocatorClient> client,
scoped_refptr<CodecConfig> codec_config);
- // Asynchronously release |media_codec| with the attached surface.
+ // Asynchronously release |media_codec| with the attached surface. If a
+ // SurfaceView is attached to the codec, the release is tracked so that
+ // OnSurfaceDestroyed() can wait on it to complete. If a SurfaceTexture
+ // is attached to the codec, the release is tracked so that
+ // ReleaseSurfaceTexture() can arrange for the SurfaceTexture to be released
+ // after the codec.
liberato (no reviews please) 2017/01/13 17:22:04 that it's a raw ptr is a little subtle. might des
// TODO(watk): Bundle the MediaCodec and surface together so you can't get
// this pairing wrong.
void ReleaseMediaCodec(std::unique_ptr<VideoCodecBridge> media_codec,
TaskType task_type,
- int surface_id);
+ int surface_id,
+ gl::SurfaceTexture* surface_texture);
+
+ // Call |surface_texture|->ReleaseSurfaceTexture() after the MediaCodec it's
+ // attached to is released. This should always be called after
+ // ReleaseMediaCodec().
+ void ReleaseSurfaceTexture(scoped_refptr<gl::SurfaceTexture> surface_texture);
// Returns a hint about whether the construction thread has hung for
// |task_type|. Note that if a thread isn't started, then we'll just return
@@ -206,7 +218,8 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// Return the task runner for tasks of type |type|.
scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerFor(TaskType task_type);
- void OnMediaCodecAndSurfaceReleased(int surface_id);
+ void OnMediaCodecReleased(int surface_id,
+ gl::SurfaceTexture* surface_texture);
// Stop the thread indicated by |index|. This signals stop_event_for_testing_
// after both threads are stopped.
@@ -218,9 +231,14 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// Indexed by surface id.
std::map<int32_t, OwnerRecord> surface_owners_;
- // Waitable events for ongoing release tasks indexed by surface id so we can
- // wait on the codec release if the surface attached to it is being destroyed.
- std::map<int32_t, base::WaitableEvent> pending_codec_releases_;
+ // Waitable events for ongoing releases of codecs with attached SurfaceViews,
+ // indexed by surface id. For waiting on the codec release if the surface is
+ // being destroyed.
+ std::map<int32_t, base::WaitableEvent> surface_view_codec_releases_;
+
+ // TaskTypes of ongoing releases of codecs with attached SurfaceTextures, For
+ // deferring SurfaceTexture release until after the codec release.
+ std::map<gl::SurfaceTexture*, TaskType> surface_texture_codec_releases_;
// Threads for each of TaskType. They are started / stopped as avda instances
// show and and request them. The vector indicies must match TaskType.

Powered by Google App Engine
This is Rietveld 408576698