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

Unified Diff: media/gpu/avda_codec_allocator.h

Issue 2707703002: Group AVDA output surface into AVDASurfaceBundle. (Closed)
Patch Set: rebased Created 3 years, 9 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
« no previous file with comments | « media/gpu/android_video_decode_accelerator.cc ('k') | media/gpu/avda_codec_allocator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/avda_codec_allocator.h
diff --git a/media/gpu/avda_codec_allocator.h b/media/gpu/avda_codec_allocator.h
index d8428de7fed5fde20a86961023467e894539be62..197d015d76284e10198b72ad4ea4e33c2eb035c8 100644
--- a/media/gpu/avda_codec_allocator.h
+++ b/media/gpu/avda_codec_allocator.h
@@ -24,6 +24,7 @@
#include "media/base/media.h"
#include "media/base/surface_manager.h"
#include "media/base/video_codecs.h"
+#include "media/gpu/avda_surface_bundle.h"
#include "media/gpu/media_gpu_export.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gl/android/scoped_java_surface.h"
@@ -50,12 +51,7 @@ class CodecConfig : public base::RefCountedThreadSafe<CodecConfig> {
VideoCodec codec = kUnknownVideoCodec;
// The surface that MediaCodec is configured to output to.
- gl::ScopedJavaSurface surface;
- int surface_id = SurfaceManager::kNoSurfaceID;
-
- // The SurfaceTexture attached to |surface|, or nullptr if |surface| is
- // SurfaceView backed.
- scoped_refptr<gl::SurfaceTexture> surface_texture;
+ scoped_refptr<AVDASurfaceBundle> surface_bundle;
// The MediaCrypto that MediaCodec is configured with for an encrypted stream.
MediaDrmBridgeCdmContext::JavaObjectPtr media_crypto;
@@ -144,12 +140,18 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
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. We will
+ // drop our reference to |surface_bundle| on the main thread after the codec
+ // is deallocated, since the codec isn't using it anymore. We will not take
+ // other action on it (e.g., calling ReleaseSurfaceTexture if it has one),
+ // since some other codec might be going to use it. We just want to be sure
+ // that it outlives |media_codec|.
// TODO(watk): Bundle the MediaCodec and surface together so you can't get
// this pairing wrong.
- void ReleaseMediaCodec(std::unique_ptr<MediaCodecBridge> media_codec,
- TaskType task_type,
- int surface_id);
+ void ReleaseMediaCodec(
+ std::unique_ptr<MediaCodecBridge> media_codec,
+ TaskType task_type,
+ const scoped_refptr<AVDASurfaceBundle>& surface_bundle);
// 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
@@ -176,6 +178,14 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
base::WaitableEvent* stop_event = nullptr);
virtual ~AVDACodecAllocator();
+ // Forward |media_codec|, which is configured to output to |surface_bundle|,
+ // to |client| if |client| is still around. Otherwise, release the codec and
+ // then drop our ref to |surface_bundle|.
+ void ForwardOrDropCodec(base::WeakPtr<AVDACodecAllocatorClient> client,
+ TaskType task_type,
+ scoped_refptr<AVDASurfaceBundle> surface_bundle,
+ std::unique_ptr<MediaCodecBridge> media_codec);
+
private:
friend class AVDACodecAllocatorTest;
@@ -210,7 +220,9 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
HangDetector hang_detector;
};
- void OnMediaCodecAndSurfaceReleased(int surface_id);
+ // Called on the gpu main thread when a codec is freed on a codec thread.
+ // |surface_bundle| is the surface bundle that the codec was using.
+ void OnMediaCodecReleased(scoped_refptr<AVDASurfaceBundle> surface_bundle);
// Stop the thread indicated by |index|. This signals stop_event_for_testing_
// after both threads are stopped.
« no previous file with comments | « media/gpu/android_video_decode_accelerator.cc ('k') | media/gpu/avda_codec_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698