make it possible to configure no sound handler
[gnash.git] / libvaapi / VaapiSubpicture.cpp
blob900950bf4ebd22f18e748c23823bce7778a5ff4c
1 // VaapiSubpicture.cpp: VA subpicture abstraction
2 //
3 // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <boost/format.hpp>
22 #include "log.h"
23 #include "VaapiSubpicture.h"
24 #include "VaapiGlobalContext.h"
25 #include "VaapiException.h"
26 #include "VaapiImage.h"
27 #include "vaapi_utils.h"
29 namespace gnash {
31 VaapiSubpicture::VaapiSubpicture(boost::shared_ptr<VaapiImage> image)
32 : _image(image)
33 , _subpicture(VA_INVALID_ID)
35 log_debug("VaapiSubpicture::VaapiSubpicture(): format '%s'\n", string_of_FOURCC(image->format()));
37 if (!create()) {
38 boost::format msg;
39 msg = boost::format("Could not create %s subpicture")
40 % string_of_FOURCC(image->format());
41 throw VaapiException(msg.str());
45 VaapiSubpicture::~VaapiSubpicture()
47 GNASH_REPORT_FUNCTION;
49 destroy();
52 bool VaapiSubpicture::create()
54 GNASH_REPORT_FUNCTION;
56 if (!_image.get()) {
57 return false;
60 VaapiGlobalContext * const gvactx = VaapiGlobalContext::get();
61 if (!gvactx) {
62 return false;
65 VASubpictureID subpicture;
66 VAStatus status = vaCreateSubpicture(gvactx->display(), _image->get(), &subpicture);
67 if (!vaapi_check_status(status, "vaCreateSubpicture()")) {
68 return false;
71 _subpicture = subpicture;
72 return true;
75 void VaapiSubpicture::destroy()
77 VaapiGlobalContext * const gvactx = VaapiGlobalContext::get();
78 if (!gvactx) {
79 return;
82 if (_subpicture != VA_INVALID_ID) {
83 VAStatus status = vaDestroySubpicture(gvactx->display(), _subpicture);
84 if (!vaapi_check_status(status, "vaDestroySubpicture()"))
85 return;
86 _subpicture = VA_INVALID_ID;
90 } // end of gnash namespace
92 // local Variables:
93 // mode: C++
94 // indent-tabs-mode: nil
95 // End: