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

Unified Diff: media/gpu/avda_codec_allocator.h

Issue 2540393002: media: AVDACodecAllocator now fails if threads don't start (Closed)
Patch Set: blah Created 4 years 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 4553ebf9f8c86d79509bb63242b31b5be959613d..ce05ca7fe6ad2e08b30a5768f3bfa4d23aa5d036 100644
--- a/media/gpu/avda_codec_allocator.h
+++ b/media/gpu/avda_codec_allocator.h
@@ -13,6 +13,7 @@
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/optional.h"
#include "base/synchronization/waitable_event.h"
#include "base/sys_info.h"
#include "base/threading/thread.h"
@@ -32,17 +33,12 @@ namespace media {
// For TaskRunnerFor. These are used as vector indices, so please update
// AVDACodecAllocator's constructor if you add / change them.
-// TODO(watk): Hide this from AVDA now that we manage codec creation.
enum TaskType {
// Task for an autodetected MediaCodec instance.
AUTO_CODEC = 0,
// Task for a software-codec-required MediaCodec.
SW_CODEC = 1,
-
- // Special value to indicate "none". This is not used as an array index. It
- // must, however, be positive to keep the enum unsigned.
- FAILED_CODEC = 99,
};
// Configuration info for MediaCodec.
@@ -121,15 +117,12 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// browser UI thread.
void OnSurfaceDestroyed(int surface_id);
- // Make sure the construction thread is started for |client|.
+ // Make sure the construction threads are started for |client|. Returns true
+ // on success.
bool StartThread(AVDACodecAllocatorClient* client);
void StopThread(AVDACodecAllocatorClient* client);
- // Return the task runner for tasks of type |type|. If that thread failed
- // to start, then fall back to the GPU main thread.
- scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerFor(TaskType task_type);
-
// Returns true if the caller now owns the surface, or false if someone else
// owns the surface. |client| will be notified when the surface is available
// via OnSurfaceAvailable().
@@ -166,9 +159,9 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// Return true if and only if there is any AVDA registered.
bool IsAnyRegisteredAVDA();
- // Return the task type to use for a new codec allocation, or FAILED_CODEC if
- // there is no thread that can support it.
- TaskType TaskTypeForAllocation();
+ // Return the task type to use for a new codec allocation, or nullopt if
+ // both threads are hung.
+ base::Optional<TaskType> TaskTypeForAllocation();
// Return a reference to the thread for unit tests.
base::Thread& GetThreadForTesting(TaskType task_type);
@@ -213,10 +206,14 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
base::WaitableEvent* stop_event = nullptr);
~AVDACodecAllocator();
+ // Return the task runner for tasks of type |type|.
+ scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerFor(TaskType task_type);
+
void OnMediaCodecAndSurfaceReleased(int surface_id);
- // Stop the thread indicated by |index|, then signal |event| if provided.
- void StopThreadTask(size_t index, base::WaitableEvent* event = nullptr);
+ // Stop the thread indicated by |index|. This signals stop_event_for_testing_
+ // after both threads are stopped.
+ void StopThreadTask(size_t index);
// All registered AVDAs.
std::set<AVDACodecAllocatorClient*> clients_;
« 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