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

Unified Diff: ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_config_rpc_server.cc

Issue 9129007: Work on improving PpbAudioConfig:RecommendSampleFrameCount (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_config_rpc_server.cc
===================================================================
--- ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_config_rpc_server.cc (revision 122585)
+++ ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_config_rpc_server.cc (working copy)
@@ -13,11 +13,18 @@
using ppapi_proxy::DebugPrintf;
+static const PPB_AudioConfig_1_0* GetAudioConfigInterface_1_0() {
+ static const PPB_AudioConfig_1_0* audio_config =
+ static_cast<const PPB_AudioConfig_1_0*>
+ (ppapi_proxy::GetBrowserInterface(PPB_AUDIO_CONFIG_INTERFACE_1_0));
+ return audio_config;
+}
+
static const PPB_AudioConfig* GetAudioConfigInterface() {
- static const PPB_AudioConfig* audioConfig =
+ static const PPB_AudioConfig* audio_config =
static_cast<const PPB_AudioConfig*>
(ppapi_proxy::GetBrowserInterface(PPB_AUDIO_CONFIG_INTERFACE));
- return audioConfig;
+ return audio_config;
}
void PpbAudioConfigRpcServer::PPB_AudioConfig_CreateStereo16Bit(
@@ -28,35 +35,64 @@
int32_t sample_frame_count,
PP_Resource* resource) {
NaClSrpcClosureRunner runner(done);
- const PPB_AudioConfig* audio = GetAudioConfigInterface();
+ const PPB_AudioConfig* audio_config = GetAudioConfigInterface();
rpc->result = NACL_SRPC_RESULT_APP_ERROR;
- if (NULL == audio) {
+ if (NULL == audio_config) {
return;
}
if (NULL == resource) {
return;
}
- *resource = audio->CreateStereo16Bit(
+ *resource = audio_config->CreateStereo16Bit(
instance, static_cast<PP_AudioSampleRate>(sample_rate),
sample_frame_count);
DebugPrintf("PPB_AudioConfig::CreateStereo16Bit: resource=%"NACL_PRId32"\n",
- *resource);
+ *resource);
+ DebugPrintf(
+ "PPB_AudioConfig::CreateStereo16Bit: sample_rate=%"NACL_PRIu32"\n",
+ sample_rate);
+ DebugPrintf(
+ "PPB_AudioConfig::CreateStereo16Bit: frame_count=%"NACL_PRIu32"\n",
+ sample_frame_count);
rpc->result = NACL_SRPC_RESULT_OK;
}
+// Preserve old behavior for applications that request 1.0 interface.
+void PpbAudioConfigRpcServer::PPB_AudioConfig_RecommendSampleFrameCount_1_0(
+ NaClSrpcRpc* rpc,
+ NaClSrpcClosure* done,
+ int32_t sample_rate,
+ int32_t request_sample_frame_count,
+ int32_t* sample_frame_count) {
+ NaClSrpcClosureRunner runner(done);
+ const PPB_AudioConfig_1_0* audio_config = GetAudioConfigInterface_1_0();
+ rpc->result = NACL_SRPC_RESULT_APP_ERROR;
+ if (NULL == audio_config) {
+ return;
+ }
+ *sample_frame_count = audio_config->RecommendSampleFrameCount(
+ static_cast<PP_AudioSampleRate>(sample_rate),
+ request_sample_frame_count);
+ DebugPrintf("PPB_AudioConfig::RecommendSampleFrameCount_1_0: "
+ "sample_frame_count=%"NACL_PRId32"\n", *sample_frame_count);
+ rpc->result = NACL_SRPC_RESULT_OK;
+}
+
void PpbAudioConfigRpcServer::PPB_AudioConfig_RecommendSampleFrameCount(
NaClSrpcRpc* rpc,
NaClSrpcClosure* done,
+ PP_Instance instance,
int32_t sample_rate,
int32_t request_sample_frame_count,
int32_t* sample_frame_count) {
NaClSrpcClosureRunner runner(done);
- const PPB_AudioConfig* audio = GetAudioConfigInterface();
+ const PPB_AudioConfig* audio_config = GetAudioConfigInterface();
rpc->result = NACL_SRPC_RESULT_APP_ERROR;
- if (NULL == audio) {
+ if (NULL == audio_config) {
return;
}
- *sample_frame_count = audio->RecommendSampleFrameCount(
+ *sample_frame_count = audio_config->RecommendSampleFrameCount(
+ instance,
static_cast<PP_AudioSampleRate>(sample_rate),
request_sample_frame_count);
DebugPrintf("PPB_AudioConfig::RecommendSampleFrameCount: "
@@ -70,12 +106,12 @@
PP_Resource resource,
int32_t* success) {
NaClSrpcClosureRunner runner(done);
- const PPB_AudioConfig* audio = GetAudioConfigInterface();
+ const PPB_AudioConfig* audio_config = GetAudioConfigInterface();
rpc->result = NACL_SRPC_RESULT_APP_ERROR;
- if (NULL == audio) {
+ if (NULL == audio_config) {
return;
}
- PP_Bool pp_success = audio->IsAudioConfig(resource);
+ PP_Bool pp_success = audio_config->IsAudioConfig(resource);
*success = PP_ToBool(pp_success);
DebugPrintf("PPB_AudioConfig::IsAudioConfig: success=%d\n", *success);
rpc->result = NACL_SRPC_RESULT_OK;
@@ -87,9 +123,9 @@
PP_Resource resource,
int32_t* sample_rate) {
NaClSrpcClosureRunner runner(done);
- const PPB_AudioConfig* audio = GetAudioConfigInterface();
+ const PPB_AudioConfig* audio_config = GetAudioConfigInterface();
rpc->result = NACL_SRPC_RESULT_APP_ERROR;
- if (NULL == audio) {
+ if (NULL == audio_config) {
return;
}
if (ppapi_proxy::kInvalidResourceId == resource) {
@@ -98,7 +134,7 @@
if (NULL == sample_rate) {
return;
}
- *sample_rate = audio->GetSampleRate(resource);
+ *sample_rate = audio_config->GetSampleRate(resource);
DebugPrintf("PPB_AudioConfig::GetSampleRate: pp_success=%"NACL_PRId32"\n",
*sample_rate);
rpc->result = NACL_SRPC_RESULT_OK;
@@ -110,9 +146,9 @@
PP_Resource resource,
int32_t* sample_frame_count) {
NaClSrpcClosureRunner runner(done);
- const PPB_AudioConfig* audio = GetAudioConfigInterface();
+ const PPB_AudioConfig* audio_config = GetAudioConfigInterface();
rpc->result = NACL_SRPC_RESULT_APP_ERROR;
- if (NULL == audio) {
+ if (NULL == audio_config) {
return;
}
if (ppapi_proxy::kInvalidResourceId == resource) {
@@ -121,8 +157,25 @@
if (NULL == sample_frame_count) {
return;
}
- *sample_frame_count = audio->GetSampleFrameCount(resource);
+ *sample_frame_count = audio_config->GetSampleFrameCount(resource);
DebugPrintf("PPB_AudioConfig::GetSampleFrameCount: "
"sample_frame_count=%"NACL_PRId32"\n", *sample_frame_count);
rpc->result = NACL_SRPC_RESULT_OK;
}
+
+void PpbAudioConfigRpcServer::PPB_AudioConfig_RecommendSampleRate(
+ NaClSrpcRpc* rpc,
+ NaClSrpcClosure* done,
+ PP_Instance instance,
+ int32_t* sample_rate) {
+ NaClSrpcClosureRunner runner(done);
+ const PPB_AudioConfig* audio_config = GetAudioConfigInterface();
+ rpc->result = NACL_SRPC_RESULT_APP_ERROR;
+ if (NULL == audio_config) {
+ return;
+ }
+ *sample_rate = audio_config->RecommendSampleRate(instance);
+ DebugPrintf("PPB_AudioConfig::RecommendSampleRate: "
+ "sample_rate=%"NACL_PRIu32"\n", *sample_rate);
+ rpc->result = NACL_SRPC_RESULT_OK;
+}

Powered by Google App Engine
This is Rietveld 408576698