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

Side by Side Diff: media/gpu/avda_picture_buffer_manager.cc

Issue 2629223003: media: Ensure MediaCodecs are released before attached SurfaceTextures (Closed)
Patch Set: more comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 #include "media/gpu/avda_picture_buffer_manager.h" 5 #include "media/gpu/avda_picture_buffer_manager.h"
6 6
7 #include <EGL/egl.h> 7 #include <EGL/egl.h>
8 #include <EGL/eglext.h> 8 #include <EGL/eglext.h>
9 9
10 #include "base/android/build_info.h" 10 #include "base/android/build_info.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } // namespace 74 } // namespace
75 75
76 AVDAPictureBufferManager::AVDAPictureBufferManager( 76 AVDAPictureBufferManager::AVDAPictureBufferManager(
77 AVDAStateProvider* state_provider) 77 AVDAStateProvider* state_provider)
78 : state_provider_(state_provider), media_codec_(nullptr) {} 78 : state_provider_(state_provider), media_codec_(nullptr) {}
79 79
80 AVDAPictureBufferManager::~AVDAPictureBufferManager() {} 80 AVDAPictureBufferManager::~AVDAPictureBufferManager() {}
81 81
82 gl::ScopedJavaSurface AVDAPictureBufferManager::Initialize(int surface_id) { 82 gl::ScopedJavaSurface AVDAPictureBufferManager::Initialize(int surface_id) {
83 shared_state_ = new AVDASharedState(); 83 shared_state_ = new AVDASharedState();
84 surface_texture_ = nullptr;
84 85
85 // Acquire the SurfaceView surface if given a valid id. 86 // Acquire the SurfaceView surface if given a valid id.
86 if (surface_id != SurfaceManager::kNoSurfaceID) { 87 if (surface_id != SurfaceManager::kNoSurfaceID)
87 if (surface_texture_) {
88 surface_texture_->ReleaseSurfaceTexture();
89 surface_texture_ = nullptr;
90 }
91 return gpu::GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_id); 88 return gpu::GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_id);
92 }
93 89
94 // Otherwise create a SurfaceTexture. 90 // Otherwise create a SurfaceTexture.
95 GLuint service_id; 91 GLuint service_id;
96 surface_texture_ = CreateAttachedSurfaceTexture( 92 surface_texture_ = CreateAttachedSurfaceTexture(
97 state_provider_->GetGlDecoder(), &service_id); 93 state_provider_->GetGlDecoder(), &service_id);
98 shared_state_->SetSurfaceTexture(surface_texture_, service_id); 94 shared_state_->SetSurfaceTexture(surface_texture_, service_id);
99 return gl::ScopedJavaSurface(surface_texture_.get()); 95 return gl::ScopedJavaSurface(surface_texture_.get());
100 } 96 }
101 97
102 void AVDAPictureBufferManager::Destroy(const PictureBufferMap& buffers) { 98 void AVDAPictureBufferManager::Destroy(const PictureBufferMap& buffers) {
103 // Do nothing if Initialize() has not been called. 99 // Do nothing if Initialize() has not been called.
104 if (!shared_state_) 100 if (!shared_state_)
105 return; 101 return;
106 102
107 ReleaseCodecBuffers(buffers); 103 ReleaseCodecBuffers(buffers);
108 CodecChanged(nullptr); 104 CodecChanged(nullptr);
109 105 surface_texture_ = nullptr;
110 // Release the surface texture and any back buffers. This will preserve the
111 // front buffer, if any.
112 if (surface_texture_)
113 surface_texture_->ReleaseSurfaceTexture();
114 } 106 }
115 107
116 void AVDAPictureBufferManager::SetImageForPicture( 108 void AVDAPictureBufferManager::SetImageForPicture(
117 const PictureBuffer& picture_buffer, 109 const PictureBuffer& picture_buffer,
118 gpu::gles2::GLStreamTextureImage* image) { 110 gpu::gles2::GLStreamTextureImage* image) {
119 auto gles_decoder = state_provider_->GetGlDecoder(); 111 auto gles_decoder = state_provider_->GetGlDecoder();
120 RETURN_IF_NULL(gles_decoder); 112 RETURN_IF_NULL(gles_decoder);
121 auto* context_group = gles_decoder->GetContextGroup(); 113 auto* context_group = gles_decoder->GetContextGroup();
122 RETURN_IF_NULL(context_group); 114 RETURN_IF_NULL(context_group);
123 auto* texture_manager = context_group->texture_manager(); 115 auto* texture_manager = context_group->texture_manager();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 284
293 bool AVDAPictureBufferManager::HasUnrenderedPictures() const { 285 bool AVDAPictureBufferManager::HasUnrenderedPictures() const {
294 for (int id : pictures_out_for_display_) { 286 for (int id : pictures_out_for_display_) {
295 if (GetImageForPicture(id)->is_unrendered()) 287 if (GetImageForPicture(id)->is_unrendered())
296 return true; 288 return true;
297 } 289 }
298 return false; 290 return false;
299 } 291 }
300 292
301 } // namespace media 293 } // namespace media
OLDNEW
« media/gpu/avda_codec_allocator.h ('K') | « media/gpu/avda_picture_buffer_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698