summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-04 04:44:48 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-04 04:44:48 +0000
commit9f9fee6343b8e96ab2a345bc66251e4b8f182547 (patch)
treeef37950362454ed5ef74ad4263d08312033df831 /ppapi
parent1e16ac0f958d5bcc0012c68ad3c04908e3a64788 (diff)
downloadchromium_src-9f9fee6343b8e96ab2a345bc66251e4b8f182547.zip
chromium_src-9f9fee6343b8e96ab2a345bc66251e4b8f182547.tar.gz
chromium_src-9f9fee6343b8e96ab2a345bc66251e4b8f182547.tar.bz2
Revert 87905 (broke PPAPITest.Scrollbar on win) - PPAPI: Fix interface functions that take PP_CompletionCallbacks, but don't
return codes from pp_errors.h BUG=none TEST=compile + manually run ppapi_tests::VideoDecoder Review URL: http://codereview.chromium.org/6975053 TBR=polina@google.com Review URL: http://codereview.chromium.org/7058061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/dev/ppb_layer_compositor_dev.h4
-rw-r--r--ppapi/c/dev/ppb_video_decoder_dev.h50
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.cc54
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.h22
-rw-r--r--ppapi/tests/arch_dependent_sizes_32.h2
-rw-r--r--ppapi/tests/arch_dependent_sizes_64.h2
-rw-r--r--ppapi/tests/test_video_decoder.cc19
-rw-r--r--ppapi/tests/test_video_decoder.h2
8 files changed, 62 insertions, 93 deletions
diff --git a/ppapi/c/dev/ppb_layer_compositor_dev.h b/ppapi/c/dev/ppb_layer_compositor_dev.h
index 1ee4594..b07431e21 100644
--- a/ppapi/c/dev/ppb_layer_compositor_dev.h
+++ b/ppapi/c/dev/ppb_layer_compositor_dev.h
@@ -68,8 +68,8 @@ struct PPB_LayerCompositor_Dev {
// Since this is an asynchronous operation, |callback| will be called when
// this operation is done.
//
- // Returns an error code from pp_errors.h.
- int32_t (*SwapBuffers)(PP_Resource compositor,
+ // Returns PP_TRUE if the operation was successful. PP_FALSE otherwise.
+ PP_Bool (*SwapBuffers)(PP_Resource compositor,
struct PP_CompletionCallback callback);
};
diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h
index 4ec65df..12f6d5f 100644
--- a/ppapi/c/dev/ppb_video_decoder_dev.h
+++ b/ppapi/c/dev/ppb_video_decoder_dev.h
@@ -52,7 +52,7 @@
// |###########################|
// | GetConfigs |
// |-------------------------->|
-// | Create + Initialize |
+// | Create |
// |-------------------------->| Decoder will ask for certain number
// | (Decode) | of PictureBuffers. This may happen
// |- - - - - - - - - - - - - >| either directly after constructor or
@@ -121,16 +121,7 @@ struct PPB_VideoDecoder_Dev {
uint32_t matching_configs_size,
uint32_t* num_of_matching_configs);
- // Creates a video decoder. Initialize() must be called afterwards to
- // set its configuration.
- //
- // Parameters:
- // |instance| pointer to the plugin instance.
- //
- // The created decoder is returned as PP_Resource. 0 means failure.
- PP_Resource (*Create)(PP_Instance instance);
-
- // Initializes the video decoder with requested configuration.
+ // Creates a video decoder with requested |decoder_config|.
// |input_format| in |decoder_config| specifies the format of input access
// unit, with PP_VIDEOKEY_CODECID and PP_VIDEOKEY_PAYLOADFORMAT required.
// Plugin has the option to specify codec profile/level and other
@@ -138,13 +129,13 @@ struct PPB_VideoDecoder_Dev {
// the most appropriate decoder.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder resource.
- // |decoder_config| the configuration to use to initialize the decoder.
- // |callback| called after initialization is complete.
+ // |instance| pointer to the plugin instance.
+ // |dec_config| the configuration which to use to initialize the decoder.
+ // |callback| called after initialize is complete.
//
- // Returns an error code from pp_errors.h.
- int32_t (*Initialize)(PP_Resource video_decoder,
- const PP_VideoConfigElement* decoder_config,
+ // The created decoder is returned as PP_Resource. NULL means failure.
+ PP_Resource (*Create)(PP_Instance instance,
+ const PP_VideoConfigElement* dec_config,
struct PP_CompletionCallback callback);
// Tests whether |resource| is a video decoder created through Create
@@ -160,13 +151,14 @@ struct PPB_VideoDecoder_Dev {
// non-blocking function.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder resource.
+ // |video_decoder| is the previously created handle to the decoder instance.
// |bitstream_buffer| is the bitstream buffer that contains the input data.
// |callback| will be called when |bitstream_buffer| has been processed by
// the decoder.
//
- // Returns an error code from pp_errors.h.
- int32_t (*Decode)(PP_Resource video_decoder,
+ // Returns PP_TRUE on decoder successfully accepting buffer, PP_FALSE
+ // otherwise.
+ PP_Bool (*Decode)(PP_Resource video_decoder,
const struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
struct PP_CompletionCallback callback);
@@ -193,7 +185,7 @@ struct PPB_VideoDecoder_Dev {
// PPB API.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder resource.
+ // |video_decoder| is the previously created handle to the decoder instance.
// |no_of_buffers| how many buffers are behind picture buffer pointer.
// |buffers| contains the reference to the picture buffer that was
// allocated.
@@ -218,7 +210,7 @@ struct PPB_VideoDecoder_Dev {
// the GL textures for writing output again.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder resource.
+ // |video_decoder| is the previously created handle to the decoder instance.
// |picture_buffer_id| contains the id of the picture buffer that was
// processed.
void (*ReusePictureBuffer)(PP_Resource video_decoder,
@@ -231,12 +223,13 @@ struct PPB_VideoDecoder_Dev {
// decode will call the |callback|.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder resource.
+ // |video_decoder| is the previously created handle to the decoder instance.
// |callback| is one-time callback that will be called once the flushing
// request has been completed.
//
- // Returns an error code from pp_errors.h.
- int32_t (*Flush)(PP_Resource video_decoder,
+ // Returns PP_TRUE on acceptance of flush request and PP_FALSE if request to
+ // flush is rejected by the decoder.
+ PP_Bool (*Flush)(PP_Resource video_decoder,
struct PP_CompletionCallback callback);
// Dispatches abortion request to the decoder to abort decoding as soon as
@@ -246,12 +239,13 @@ struct PPB_VideoDecoder_Dev {
// to dismiss them.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder resource.
+ // |video_decoder| is the previously created handle to the decoder instance.
// |callback| is one-time callback that will be called once the abortion
// request has been completed.
//
- // Returns an error code from pp_errors.h.
- int32_t (*Abort)(PP_Resource video_decoder,
+ // Returns PP_TRUE on acceptance of abort request and PP_FALSE if request to
+ // abort is rejected by the decoder.
+ PP_Bool (*Abort)(PP_Resource video_decoder,
struct PP_CompletionCallback callback);
};
diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc
index b1ebcfb..a6994b5 100644
--- a/ppapi/cpp/dev/video_decoder_dev.cc
+++ b/ppapi/cpp/dev/video_decoder_dev.cc
@@ -22,24 +22,19 @@ template <> const char* interface_name<PPB_VideoDecoder_Dev>() {
} // namespace
-VideoDecoder::VideoDecoder(const Instance* instance, Client* client)
+VideoDecoder::VideoDecoder(const Instance* instance,
+ const PP_VideoConfigElement* config,
+ CompletionCallback callback,
+ Client* client)
: client_(client) {
if (!has_interface<PPB_VideoDecoder_Dev>())
return;
PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create(
- instance->pp_instance()));
+ instance->pp_instance(), config, callback.pp_completion_callback()));
}
VideoDecoder::~VideoDecoder() {}
-int32_t VideoDecoder::Initialize(const PP_VideoConfigElement* config,
- CompletionCallback callback) {
- if (!has_interface<PPB_VideoDecoder_Dev>())
- return PP_ERROR_NOINTERFACE;
- return get_interface<PPB_VideoDecoder_Dev>()->Initialize(
- pp_resource(), config, callback.pp_completion_callback());
-}
-
bool VideoDecoder::GetConfigs(Instance* instance,
const PP_VideoConfigElement* prototype_config,
PP_VideoConfigElement* matching_configs,
@@ -68,15 +63,12 @@ void VideoDecoder::AssignSysmemBuffers(
pp_resource(), buffers.size(), &buffers[0]);
}
-int32_t VideoDecoder::Decode(
- const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
- CompletionCallback callback) {
- if (!has_interface<PPB_VideoDecoder_Dev>())
- return PP_ERROR_NOINTERFACE;
- if (!pp_resource())
- return PP_ERROR_BADRESOURCE;
- return get_interface<PPB_VideoDecoder_Dev>()->Decode(
- pp_resource(), &bitstream_buffer, callback.pp_completion_callback());
+bool VideoDecoder::Decode(const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
+ CompletionCallback callback) {
+ if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
+ return false;
+ return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Decode(
+ pp_resource(), &bitstream_buffer, callback.pp_completion_callback()));
}
void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) {
@@ -86,22 +78,18 @@ void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) {
pp_resource(), picture_buffer_id);
}
-int32_t VideoDecoder::Flush(CompletionCallback callback) {
- if (!has_interface<PPB_VideoDecoder_Dev>())
- return PP_ERROR_NOINTERFACE;
- if (!pp_resource())
- return PP_ERROR_BADRESOURCE;
- return get_interface<PPB_VideoDecoder_Dev>()->Flush(
- pp_resource(), callback.pp_completion_callback());
+bool VideoDecoder::Flush(CompletionCallback callback) {
+ if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
+ return false;
+ return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Flush(
+ pp_resource(), callback.pp_completion_callback()));
}
-int32_t VideoDecoder::Abort(CompletionCallback callback) {
- if (!has_interface<PPB_VideoDecoder_Dev>())
- return PP_ERROR_NOINTERFACE;
- if (!pp_resource())
- return PP_ERROR_BADRESOURCE;
- return get_interface<PPB_VideoDecoder_Dev>()->Abort(
- pp_resource(), callback.pp_completion_callback());
+bool VideoDecoder::Abort(CompletionCallback callback) {
+ if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
+ return false;
+ return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Abort(
+ pp_resource(), callback.pp_completion_callback()));
}
} // namespace pp
diff --git a/ppapi/cpp/dev/video_decoder_dev.h b/ppapi/cpp/dev/video_decoder_dev.h
index e6558b1..51aa594 100644
--- a/ppapi/cpp/dev/video_decoder_dev.h
+++ b/ppapi/cpp/dev/video_decoder_dev.h
@@ -54,21 +54,15 @@ class VideoDecoder : public Resource {
//
// Parameters:
// |instance| is the pointer to the plug-in instance.
+ // |config| is the configuration on which the decoder should be initialized.
// |callback| will be called when decoder is initialized.
// |client| is the pointer to the client object. Ownership of the object is
// not transferred and it must outlive the lifetime of this class.
- VideoDecoder(const Instance* instance, Client* client);
+ VideoDecoder(const Instance* instance,
+ const PP_VideoConfigElement* config,
+ CompletionCallback callback, Client* client);
~VideoDecoder();
- // Initializates the video decoder with a requested configuration.
- // Calls Init() on PPB_VideoDecoder_Dev interface.
- //
- // Parameters:
- // |config| is the configuration on which the decoder should be initialized.
- // |callback| will be called when decoder is initialized.
- int32_t Initialize(const PP_VideoConfigElement* config,
- CompletionCallback callback);
-
// GetConfigs returns supported configurations that are subsets of given
// |prototype_config|.
bool GetConfigs(Instance* instance,
@@ -85,19 +79,19 @@ class VideoDecoder : public Resource {
// Decodes given bitstream buffer. Once decoder is done with processing
// |bitstream_buffer| is will call |callback| with provided user data.
- int32_t Decode(const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
- CompletionCallback callback);
+ bool Decode(const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
+ CompletionCallback callback);
// Tells the decoder to reuse given picture buffer.
void ReusePictureBuffer(int32_t picture_buffer_id);
// Flushes the decoder. |callback| will be called as soon as Flush has been
// finished.
- int32_t Flush(CompletionCallback callback);
+ bool Flush(CompletionCallback callback);
// Dispatches abortion request to the decoder to abort decoding as soon as
// possible. |callback| will be called as soon as abortion has been finished.
- int32_t Abort(CompletionCallback callback);
+ bool Abort(CompletionCallback callback);
private:
// Pointer to the plugin's video decoder support interface for providing the
diff --git a/ppapi/tests/arch_dependent_sizes_32.h b/ppapi/tests/arch_dependent_sizes_32.h
index f797494..b7661cb 100644
--- a/ppapi/tests/arch_dependent_sizes_32.h
+++ b/ppapi/tests/arch_dependent_sizes_32.h
@@ -19,7 +19,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 8);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 8);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 24);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 12);
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 40);
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 36);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPP_VideoDecoder_Dev, 20);
#endif /* PPAPI_TESTS_ARCH_DEPENDENT_SIZES_32_H_ */
diff --git a/ppapi/tests/arch_dependent_sizes_64.h b/ppapi/tests/arch_dependent_sizes_64.h
index 378c5b3..de68721 100644
--- a/ppapi/tests/arch_dependent_sizes_64.h
+++ b/ppapi/tests/arch_dependent_sizes_64.h
@@ -19,7 +19,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 16);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 16);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 24);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 12);
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 80);
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 72);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPP_VideoDecoder_Dev, 40);
#endif /* PPAPI_TESTS_ARCH_DEPENDENT_SIZES_64_H_ */
diff --git a/ppapi/tests/test_video_decoder.cc b/ppapi/tests/test_video_decoder.cc
index 82f99c7..db0da55 100644
--- a/ppapi/tests/test_video_decoder.cc
+++ b/ppapi/tests/test_video_decoder.cc
@@ -6,7 +6,6 @@
#include "ppapi/c/dev/ppb_video_decoder_dev.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
-#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_var.h"
#include "ppapi/tests/testing_instance.h"
@@ -21,24 +20,18 @@ bool TestVideoDecoder::Init() {
}
void TestVideoDecoder::RunTest() {
- RUN_TEST(CreateAndInitialize);
+ instance_->LogTest("Create", TestCreate());
}
void TestVideoDecoder::QuitMessageLoop() {
testing_interface_->QuitMessageLoop(instance_->pp_instance());
}
-std::string TestVideoDecoder::TestCreateAndInitialize() {
+std::string TestVideoDecoder::TestCreate() {
PP_Resource decoder = video_decoder_interface_->Create(
- instance_->pp_instance());
- if (decoder == 0)
- return "Create: error creating the decoder";
-
- int32_t pp_error = video_decoder_interface_->Initialize(
- decoder, NULL, PP_BlockUntilComplete());
- pp::Module::Get()->core()->ReleaseResource(decoder);
- if (pp_error != PP_ERROR_BADARGUMENT)
- return "Initialize: error detecting null callback";
-
+ instance_->pp_instance(), NULL, PP_MakeCompletionCallback(NULL, NULL));
+ if (decoder == 0) {
+ return "Error creating the decoder";
+ }
PASS();
}
diff --git a/ppapi/tests/test_video_decoder.h b/ppapi/tests/test_video_decoder.h
index dbef66f..15e0b39 100644
--- a/ppapi/tests/test_video_decoder.h
+++ b/ppapi/tests/test_video_decoder.h
@@ -22,7 +22,7 @@ class TestVideoDecoder : public TestCase {
void QuitMessageLoop();
private:
- std::string TestCreateAndInitialize();
+ std::string TestCreate();
// Used by the tests that access the C API directly.
const PPB_VideoDecoder_Dev* video_decoder_interface_;