| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/common/gpu/media/avda_shared_state.h" | |
| 6 | |
| 7 #include "base/time/time.h" | |
| 8 #include "ui/gl/gl_bindings.h" | |
| 9 #include "ui/gl/scoped_make_current.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 AVDASharedState::AVDASharedState() | |
| 14 : surface_texture_service_id_(0), | |
| 15 frame_available_event_(false, false), | |
| 16 surface_texture_is_attached_(false) {} | |
| 17 | |
| 18 AVDASharedState::~AVDASharedState() {} | |
| 19 | |
| 20 void AVDASharedState::SignalFrameAvailable() { | |
| 21 frame_available_event_.Signal(); | |
| 22 } | |
| 23 | |
| 24 void AVDASharedState::WaitForFrameAvailable() { | |
| 25 // 10msec covers >99.9% of cases, so just wait for up to that much before | |
| 26 // giving up. If an error occurs, we might not ever get a notification. | |
| 27 const base::TimeDelta max_wait_time(base::TimeDelta::FromMilliseconds(10)); | |
| 28 frame_available_event_.TimedWait(max_wait_time); | |
| 29 } | |
| 30 | |
| 31 void AVDASharedState::DidAttachSurfaceTexture() { | |
| 32 context_ = gfx::GLContext::GetCurrent(); | |
| 33 surface_ = gfx::GLSurface::GetCurrent(); | |
| 34 DCHECK(context_); | |
| 35 DCHECK(surface_); | |
| 36 | |
| 37 surface_texture_is_attached_ = true; | |
| 38 } | |
| 39 | |
| 40 void AVDASharedState::DidDetachSurfaceTexture() { | |
| 41 context_ = nullptr; | |
| 42 surface_ = nullptr; | |
| 43 surface_texture_is_attached_ = false; | |
| 44 } | |
| 45 | |
| 46 } // namespace content | |
| OLD | NEW |