summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornfullagar@google.com <nfullagar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-18 01:10:19 +0000
committernfullagar@google.com <nfullagar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-18 01:10:19 +0000
commitc59ed589fde8d4c9225b7b1b125286f842a42e56 (patch)
treefdaa00c2a9f51d0030e3b05bb289630ad5f2e211
parent86bd8a2b5e1ce2965551271109be51244d2fcb42 (diff)
downloadchromium_src-c59ed589fde8d4c9225b7b1b125286f842a42e56.zip
chromium_src-c59ed589fde8d4c9225b7b1b125286f842a42e56.tar.gz
chromium_src-c59ed589fde8d4c9225b7b1b125286f842a42e56.tar.bz2
Work on improving PpbAudioConfig:RecommendSampleFrameCount
Add version 1.1 which will query the audio back end for the best available sample frame count. Also add RecommendSampleRate. Switch pepper plugin delegate to use AUDIO_PCM_LOW_LATENCY if client request is compatible. TEST=included BUG=http://code.google.com/p/chromium/issues/detail?id=107572 Review URL: https://chromiumcodereview.appspot.com/9129007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122653 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.cc20
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.h2
-rw-r--r--ppapi/api/ppb_audio_config.idl63
-rw-r--r--ppapi/c/ppb_audio_config.h45
-rw-r--r--ppapi/cpp/audio_config.cc15
-rw-r--r--ppapi/cpp/audio_config.h12
-rw-r--r--ppapi/examples/audio/audio.cc4
-rw-r--r--ppapi/examples/audio_input/audio_input.cc5
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_config_rpc_server.cc89
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc2
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.cc52
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h8
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/ppb_audio_config.srpc22
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc40
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc34
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h12
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h10
-rw-r--r--ppapi/native_client/tests/ppapi_example_audio/audio.cc21
-rw-r--r--ppapi/proxy/ppapi_messages.h8
-rw-r--r--ppapi/proxy/ppb_instance_proxy.cc39
-rw-r--r--ppapi/proxy/ppb_instance_proxy.h8
-rw-r--r--ppapi/shared_impl/ppb_audio_config_shared.cc71
-rw-r--r--ppapi/shared_impl/ppb_audio_config_shared.h6
-rw-r--r--ppapi/tests/test_audio.cc8
-rw-r--r--ppapi/tests/test_audio_config.cc4
-rw-r--r--ppapi/thunk/interfaces_ppb_public_stable.h1
-rw-r--r--ppapi/thunk/ppb_audio_config_thunk.cc52
-rw-r--r--ppapi/thunk/ppb_instance_api.h5
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.cc8
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.h2
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h6
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc11
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h5
33 files changed, 613 insertions, 77 deletions
diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc
index ef046f3..47eda0c 100644
--- a/content/renderer/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper_plugin_delegate_impl.cc
@@ -34,6 +34,7 @@
#include "content/public/common/context_menu_params.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/gamepad_shared_memory_reader.h"
+#include "content/renderer/media/audio_hardware.h"
#include "content/renderer/media/audio_input_message_filter.h"
#include "content/renderer/media/audio_message_filter.h"
#include "content/renderer/media/media_stream_dispatcher.h"
@@ -222,7 +223,6 @@ class PlatformAudioImpl
bool PlatformAudioImpl::Initialize(
uint32_t sample_rate, uint32_t sample_count,
webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client) {
-
DCHECK(client);
// Make sure we don't call init more than once.
DCHECK_EQ(0, stream_id_);
@@ -230,7 +230,15 @@ bool PlatformAudioImpl::Initialize(
client_ = client;
AudioParameters params;
- params.format = AudioParameters::AUDIO_PCM_LINEAR;
+ const uint32_t kMaxSampleCountForLowLatency = 2048;
+ // Use the low latency back end if the client request is compatible, and
+ // the sample count is low enough to justify using AUDIO_PCM_LOW_LATENCY.
+ if (sample_rate == audio_hardware::GetOutputSampleRate() &&
+ sample_count <= kMaxSampleCountForLowLatency &&
+ sample_count % audio_hardware::GetOutputBufferSize() == 0)
+ params.format = AudioParameters::AUDIO_PCM_LOW_LATENCY;
+ else
+ params.format = AudioParameters::AUDIO_PCM_LINEAR;
params.channels = 2;
params.sample_rate = sample_rate;
params.bits_per_sample = 16;
@@ -1358,6 +1366,14 @@ void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier,
identifier, index + 1, WebKit::WebRect());
}
+uint32_t PepperPluginDelegateImpl::GetAudioHardwareOutputSampleRate() {
+ return static_cast<uint32_t>(audio_hardware::GetOutputSampleRate());
+}
+
+uint32_t PepperPluginDelegateImpl::GetAudioHardwareOutputBufferSize() {
+ return static_cast<uint32_t>(audio_hardware::GetOutputBufferSize());
+}
+
webkit::ppapi::PluginDelegate::PlatformAudio*
PepperPluginDelegateImpl::CreateAudio(
uint32_t sample_rate,
diff --git a/content/renderer/pepper_plugin_delegate_impl.h b/content/renderer/pepper_plugin_delegate_impl.h
index dd14161..4e27538 100644
--- a/content/renderer/pepper_plugin_delegate_impl.h
+++ b/content/renderer/pepper_plugin_delegate_impl.h
@@ -216,6 +216,8 @@ class PepperPluginDelegateImpl
virtual void InstanceDeleted(
webkit::ppapi::PluginInstance* instance) OVERRIDE;
virtual SkBitmap* GetSadPluginBitmap() OVERRIDE;
+ virtual uint32_t GetAudioHardwareOutputSampleRate() OVERRIDE;
+ virtual uint32_t GetAudioHardwareOutputBufferSize() OVERRIDE;
virtual PlatformAudio* CreateAudio(
uint32_t sample_rate,
uint32_t sample_count,
diff --git a/ppapi/api/ppb_audio_config.idl b/ppapi/api/ppb_audio_config.idl
index 4c2e3a2..8ba2a28 100644
--- a/ppapi/api/ppb_audio_config.idl
+++ b/ppapi/api/ppb_audio_config.idl
@@ -9,7 +9,8 @@
*/
label Chrome {
- M14 = 1.0
+ M14 = 1.0,
+ M18 = 1.1
};
/**
@@ -51,9 +52,11 @@ enum PP_AudioSampleRate {
interface PPB_AudioConfig {
/**
* CreateStereo16bit() creates a 16 bit audio configuration resource. The
- * <code>sample_frame_count</code> should be the result of calling
- * <code>RecommendSampleFrameCount</code>. If the sample frame count or bit
- * rate isn't supported, this function will fail and return a null resource.
+ * <code>sample_rate</code> should be the result of calling
+ * <code>RecommendSampleRate</code> and <code>sample_frame_count</code> should
+ * be the result of calling <code>RecommendSampleFrameCount</code>. If the
+ * sample frame count or bit rate isn't supported, this function will fail and
+ * return a null resource.
*
* A single sample frame on a stereo device means one value for the left
* channel and one value for the right channel.
@@ -89,6 +92,37 @@ interface PPB_AudioConfig {
[in] uint32_t sample_frame_count);
/**
+ * This comment block applies to version 1.0, which is deprecated in favor of
+ * the same function but with slightly different signature and behavior.
+ *
+ * RecommendSampleFrameCount() returns the supported sample frame count
+ * closest to the requested count. The sample frame count determines the
+ * overall latency of audio. Since one "frame" is always buffered in advance,
+ * smaller frame counts will yield lower latency, but higher CPU utilization.
+ * For best audio performance, use the value returned by RecommendSampleRate
+ * as the input sample rate, then use the RecommendSampleFrameCount return
+ * value when creating the audio configuration resource.
+ *
+ * Sample counts less than
+ * <code>PP_AUDIOMINSAMPLEFRAMECOUNT</code> and greater than
+ * <code>PP_AUDIOMAXSAMPLEFRAMECOUNT</code> are never supported on any
+ * system, but values in between aren't necessarily glitch-free.
+ *
+ * @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either
+ * <code>PP_AUDIOSAMPLERATE_44100</code> or
+ * <code>PP_AUDIOSAMPLERATE_48000.</code>
+ * @param[in] requested_sample_frame_count A <code>uint_32t</code> requested
+ * frame count.
+ *
+ * @return A <code>uint32_t</code> containing the recommended sample frame
+ * count if successful.
+ */
+ [deprecate=1.1]
+ uint32_t RecommendSampleFrameCount(
+ [in] PP_AudioSampleRate sample_rate,
+ [in] uint32_t requested_sample_frame_count);
+
+ /**
* RecommendSampleFrameCount() returns the supported sample frame count
* closest to the requested count. The sample frame count determines the
* overall latency of audio. Since one "frame" is always buffered in advance,
@@ -102,6 +136,9 @@ interface PPB_AudioConfig {
* system, but values in between aren't necessarily valid. This function
* will return a supported count closest to the requested value.
*
+ * RecommendSampleFrameCount() result is intended for audio output devices.
+ *
+ * @param[in] instance
* @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either
* <code>PP_AUDIOSAMPLERATE_44100</code> or
* <code>PP_AUDIOSAMPLERATE_48000.</code>
@@ -111,7 +148,9 @@ interface PPB_AudioConfig {
* @return A <code>uint32_t</code> containing the recommended sample frame
* count if successful.
*/
+ [version=1.1]
uint32_t RecommendSampleFrameCount(
+ [in] PP_Instance instance,
[in] PP_AudioSampleRate sample_rate,
[in] uint32_t requested_sample_frame_count);
@@ -155,5 +194,21 @@ interface PPB_AudioConfig {
*/
uint32_t GetSampleFrameCount(
[in] PP_Resource config);
+
+ /**
+ * RecommendSampleRate() returns the native sample rate that the browser
+ * is using in the backend. Applications that use the recommended sample
+ * rate will have potentially better latency and fidelity. The return value
+ * is indended for audio output devices.
+ *
+ * @param[in] instance
+ *
+ * @return A <code>uint32_t</code> containing the recommended sample frame
+ * count if successful.
+ */
+ [version=1.1]
+ PP_AudioSampleRate RecommendSampleRate(
+ [in] PP_Instance instance);
+
};
diff --git a/ppapi/c/ppb_audio_config.h b/ppapi/c/ppb_audio_config.h
index 2b62c3d..22547ea 100644
--- a/ppapi/c/ppb_audio_config.h
+++ b/ppapi/c/ppb_audio_config.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From ppb_audio_config.idl modified Fri Jan 20 13:12:44 2012. */
+/* From ppb_audio_config.idl modified Thu Feb 16 16:23:46 2012. */
#ifndef PPAPI_C_PPB_AUDIO_CONFIG_H_
#define PPAPI_C_PPB_AUDIO_CONFIG_H_
@@ -15,7 +15,8 @@
#include "ppapi/c/pp_stdint.h"
#define PPB_AUDIO_CONFIG_INTERFACE_1_0 "PPB_AudioConfig;1.0"
-#define PPB_AUDIO_CONFIG_INTERFACE PPB_AUDIO_CONFIG_INTERFACE_1_0
+#define PPB_AUDIO_CONFIG_INTERFACE_1_1 "PPB_AudioConfig;1.1"
+#define PPB_AUDIO_CONFIG_INTERFACE PPB_AUDIO_CONFIG_INTERFACE_1_1
/**
* @file
@@ -68,12 +69,14 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_AudioSampleRate, 4);
* <a href="/chrome/nativeclient/docs/audio.html">Pepper
* Audio API</a> for information on using this interface.
*/
-struct PPB_AudioConfig_1_0 {
+struct PPB_AudioConfig_1_1 {
/**
* CreateStereo16bit() creates a 16 bit audio configuration resource. The
- * <code>sample_frame_count</code> should be the result of calling
- * <code>RecommendSampleFrameCount</code>. If the sample frame count or bit
- * rate isn't supported, this function will fail and return a null resource.
+ * <code>sample_rate</code> should be the result of calling
+ * <code>RecommendSampleRate</code> and <code>sample_frame_count</code> should
+ * be the result of calling <code>RecommendSampleFrameCount</code>. If the
+ * sample frame count or bit rate isn't supported, this function will fail and
+ * return a null resource.
*
* A single sample frame on a stereo device means one value for the left
* channel and one value for the right channel.
@@ -120,6 +123,9 @@ struct PPB_AudioConfig_1_0 {
* system, but values in between aren't necessarily valid. This function
* will return a supported count closest to the requested value.
*
+ * RecommendSampleFrameCount() result is intended for audio output devices.
+ *
+ * @param[in] instance
* @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either
* <code>PP_AUDIOSAMPLERATE_44100</code> or
* <code>PP_AUDIOSAMPLERATE_48000.</code>
@@ -130,6 +136,7 @@ struct PPB_AudioConfig_1_0 {
* count if successful.
*/
uint32_t (*RecommendSampleFrameCount)(
+ PP_Instance instance,
PP_AudioSampleRate sample_rate,
uint32_t requested_sample_frame_count);
/**
@@ -167,9 +174,33 @@ struct PPB_AudioConfig_1_0 {
* RecommendSampleFrameCount() for more on sample frame counts.
*/
uint32_t (*GetSampleFrameCount)(PP_Resource config);
+ /**
+ * RecommendSampleRate() returns the native sample rate that the browser
+ * is using in the backend. Applications that use the recommended sample
+ * rate will have potentially better latency and fidelity. The return value
+ * is indended for audio output devices.
+ *
+ * @param[in] instance
+ *
+ * @return A <code>uint32_t</code> containing the recommended sample frame
+ * count if successful.
+ */
+ PP_AudioSampleRate (*RecommendSampleRate)(PP_Instance instance);
};
-typedef struct PPB_AudioConfig_1_0 PPB_AudioConfig;
+typedef struct PPB_AudioConfig_1_1 PPB_AudioConfig;
+
+struct PPB_AudioConfig_1_0 {
+ PP_Resource (*CreateStereo16Bit)(PP_Instance instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t sample_frame_count);
+ uint32_t (*RecommendSampleFrameCount)(
+ PP_AudioSampleRate sample_rate,
+ uint32_t requested_sample_frame_count);
+ PP_Bool (*IsAudioConfig)(PP_Resource resource);
+ PP_AudioSampleRate (*GetSampleRate)(PP_Resource config);
+ uint32_t (*GetSampleFrameCount)(PP_Resource config);
+};
/**
* @}
*/
diff --git a/ppapi/cpp/audio_config.cc b/ppapi/cpp/audio_config.cc
index b553dad..a49515e 100644
--- a/ppapi/cpp/audio_config.cc
+++ b/ppapi/cpp/audio_config.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -36,13 +36,24 @@ AudioConfig::AudioConfig(Instance* instance,
}
// static
+PP_AudioSampleRate AudioConfig::RecommendSampleRate(Instance* instance) {
+ if (!has_interface<PPB_AudioConfig>())
+ return PP_AUDIOSAMPLERATE_NONE;
+ return get_interface<PPB_AudioConfig>()->
+ RecommendSampleRate(instance->pp_instance());
+}
+
+// static
uint32_t AudioConfig::RecommendSampleFrameCount(
+ Instance* instance,
PP_AudioSampleRate sample_rate,
uint32_t requested_sample_frame_count) {
if (!has_interface<PPB_AudioConfig>())
return 0;
return get_interface<PPB_AudioConfig>()->
- RecommendSampleFrameCount(sample_rate, requested_sample_frame_count);
+ RecommendSampleFrameCount(instance->pp_instance(),
+ sample_rate,
+ requested_sample_frame_count);
}
} // namespace pp
diff --git a/ppapi/cpp/audio_config.h b/ppapi/cpp/audio_config.h
index 2eac4d6..ff1d256 100644
--- a/ppapi/cpp/audio_config.h
+++ b/ppapi/cpp/audio_config.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -75,6 +75,11 @@ class AudioConfig : public Resource {
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count);
+ /// RecommendSampleRate() returns the native sample rate used by the
+ /// audio system. Applications that use the recommended sample rate might
+ /// obtain lower latency and higher fidelity output.
+ static PP_AudioSampleRate RecommendSampleRate(Instance* instance);
+
/// RecommendSampleFrameCount() returns a supported frame count closest to
/// the requested count. The sample frame count determines the overall
/// latency of audio. Smaller frame counts will yield lower latency, but
@@ -87,7 +92,9 @@ class AudioConfig : public Resource {
/// will return a supported count closest to the requested value for use in
/// the constructor.
///
- /// @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either
+ /// @param[in] instance A pointer to an <code>Instance</code> identifying
+ /// one instance of a module.
+ /// @param[in] sample_rate A <code>PP_AudioSampleRate</code> which is either
/// <code>PP_AUDIOSAMPLERATE_44100</code> or
/// <code>PP_AUDIOSAMPLERATE_48000</code>.
/// @param[in] requested_sample_frame_count A uint_32t requested frame count.
@@ -96,6 +103,7 @@ class AudioConfig : public Resource {
/// successful. If the sample frame count or bit rate is not supported,
/// this function will fail and return 0.
static uint32_t RecommendSampleFrameCount(
+ Instance* instance,
PP_AudioSampleRate sample_rate,
uint32_t requested_sample_frame_count);
diff --git a/ppapi/examples/audio/audio.cc b/ppapi/examples/audio/audio.cc
index 2c01faf..e6a0a84 100644
--- a/ppapi/examples/audio/audio.cc
+++ b/ppapi/examples/audio/audio.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -56,7 +56,7 @@ class MyInstance : public pp::Instance {
pp::AudioConfig config;
sample_count_ = pp::AudioConfig::RecommendSampleFrameCount(
- sample_rate_, kDefaultSampleCount);
+ this, sample_rate_, kDefaultSampleCount);
config = pp::AudioConfig(this, sample_rate_, sample_count_);
audio_ = pp::Audio(this, config, SineWaveCallbackTrampoline, this);
return audio_.StartPlayback();
diff --git a/ppapi/examples/audio_input/audio_input.cc b/ppapi/examples/audio_input/audio_input.cc
index 74bc08e..203718e 100644
--- a/ppapi/examples/audio_input/audio_input.cc
+++ b/ppapi/examples/audio_input/audio_input.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -41,7 +41,8 @@ class MyInstance : public pp::Instance {
const uint32_t kSampleCount = 1024;
const uint32_t kChannelCount = 1;
- sample_count_ = pp::AudioConfig::RecommendSampleFrameCount(kSampleFrequency,
+ sample_count_ = pp::AudioConfig::RecommendSampleFrameCount(this,
+ kSampleFrequency,
kSampleCount);
PP_DCHECK(sample_count_ > 0);
channel_count_ = kChannelCount;
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_config_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_config_rpc_server.cc
index 883331e..205cbf9 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_config_rpc_server.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_audio_config_rpc_server.cc
@@ -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 @@ void PpbAudioConfigRpcServer::PPB_AudioConfig_CreateStereo16Bit(
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 @@ void PpbAudioConfigRpcServer::PPB_AudioConfig_IsAudioConfig(
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 @@ void PpbAudioConfigRpcServer::PPB_AudioConfig_GetSampleRate(
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 @@ void PpbAudioConfigRpcServer::PPB_AudioConfig_GetSampleRate(
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 @@ void PpbAudioConfigRpcServer::PPB_AudioConfig_GetSampleFrameCount(
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 @@ void PpbAudioConfigRpcServer::PPB_AudioConfig_GetSampleFrameCount(
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;
+}
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc
index b33400c..c1314a0 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc
@@ -58,6 +58,8 @@ struct InterfaceMapElement {
InterfaceMapElement interface_map[] = {
{ PPB_AUDIO_INTERFACE, PluginAudio::GetInterface(), true },
{ PPB_AUDIO_CONFIG_INTERFACE, PluginAudioConfig::GetInterface(), true },
+ { PPB_AUDIO_CONFIG_INTERFACE_1_0, PluginAudioConfig::GetInterface1_0(),
+ true },
{ PPB_CORE_INTERFACE, PluginCore::GetInterface(), true },
{ PPB_CURSOR_CONTROL_DEV_INTERFACE, PluginCursorControl::GetInterface(),
true },
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.cc
index efd4cf9..5fa5188 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.cc
@@ -51,13 +51,33 @@ uint32_t GetSampleFrameCount(PP_Resource config) {
return 0;
}
-uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate,
+uint32_t RecommendSampleFrameCount_1_0(PP_AudioSampleRate sample_rate,
+ uint32_t request_sample_frame_count) {
+ DebugPrintf("PPB_AudioConfig::RecommendSampleFrameCount_1_0");
+ int32_t out_sample_frame_count;
+ NaClSrpcError srpc_result =
+ PpbAudioConfigRpcClient::PPB_AudioConfig_RecommendSampleFrameCount_1_0(
+ GetMainSrpcChannel(),
+ static_cast<int32_t>(sample_rate),
+ static_cast<int32_t>(request_sample_frame_count),
+ &out_sample_frame_count);
+ DebugPrintf("PPB_AudioConfig::RecommendSampleFrameCount_1_0: %s\n",
+ NaClSrpcErrorString(srpc_result));
+ if (NACL_SRPC_RESULT_OK == srpc_result) {
+ return static_cast<uint32_t>(out_sample_frame_count);
+ }
+ return 0;
+}
+
+uint32_t RecommendSampleFrameCount(PP_Instance instance,
+ PP_AudioSampleRate sample_rate,
uint32_t request_sample_frame_count) {
DebugPrintf("PPB_AudioConfig::RecommendSampleFrameCount");
int32_t out_sample_frame_count;
NaClSrpcError srpc_result =
PpbAudioConfigRpcClient::PPB_AudioConfig_RecommendSampleFrameCount(
GetMainSrpcChannel(),
+ instance,
static_cast<int32_t>(sample_rate),
static_cast<int32_t>(request_sample_frame_count),
&out_sample_frame_count);
@@ -106,6 +126,23 @@ PP_Resource CreateStereo16Bit(PP_Instance instance,
}
return kInvalidResourceId;
}
+
+PP_AudioSampleRate RecommendSampleRate(PP_Instance instance) {
+ DebugPrintf("PPB_AudioConfig::RecommendSampleRate");
+ int32_t out_sample_rate;
+ NaClSrpcError srpc_result =
+ PpbAudioConfigRpcClient::PPB_AudioConfig_RecommendSampleRate(
+ GetMainSrpcChannel(),
+ instance,
+ &out_sample_rate);
+ DebugPrintf("PPB_AudioConfig::RecommendSampleRate: %s\n",
+ NaClSrpcErrorString(srpc_result));
+ if (NACL_SRPC_RESULT_OK == srpc_result) {
+ return static_cast<PP_AudioSampleRate>(out_sample_rate);
+ }
+ return PP_AUDIOSAMPLERATE_NONE;
+}
+
} // namespace
const PPB_AudioConfig* PluginAudioConfig::GetInterface() {
@@ -115,7 +152,20 @@ const PPB_AudioConfig* PluginAudioConfig::GetInterface() {
IsAudioConfig,
GetSampleRate,
GetSampleFrameCount,
+ RecommendSampleRate
};
return &audio_config_interface;
}
+
+const PPB_AudioConfig_1_0* PluginAudioConfig::GetInterface1_0() {
+ static const PPB_AudioConfig_1_0 audio_config_interface = {
+ CreateStereo16Bit,
+ RecommendSampleFrameCount_1_0,
+ IsAudioConfig,
+ GetSampleRate,
+ GetSampleFrameCount
+ };
+ return &audio_config_interface;
+}
+
} // namespace ppapi_proxy
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h
index 15a6579..0943383 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h
@@ -1,6 +1,6 @@
-// Copyright 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can
-// be found in the LICENSE file.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_AUDIO_CONFIG_H_
#define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_AUDIO_CONFIG_H_
@@ -15,6 +15,8 @@ namespace ppapi_proxy {
class PluginAudioConfig : public PluginResource {
public:
static const PPB_AudioConfig* GetInterface();
+ // Returns the 1.0 interface to support backwards-compatibility.
+ static const PPB_AudioConfig_1_0* GetInterface1_0();
private:
NACL_DISALLOW_COPY_AND_ASSIGN(PluginAudioConfig);
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_audio_config.srpc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_audio_config.srpc
index 95a8a99..20d33c0 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_audio_config.srpc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_audio_config.srpc
@@ -1,4 +1,4 @@
-# Copyright (c) 2010 The Native Client Authors. All rights reserved.
+# Copyright (c) 2012 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -24,14 +24,23 @@
'outputs': [['out_bool', 'int32_t']
]
},
- # Implements a call to get recommended sample frame count.
- {'name': 'PPB_AudioConfig_RecommendSampleFrameCount',
+ # Implements a call to get recommended sample frame count (v1.0)
+ {'name': 'PPB_AudioConfig_RecommendSampleFrameCount_1_0',
'inputs': [['request_sample_rate', 'int32_t'],
['request_sample_frame_count', 'int32_t'],
],
'outputs': [['out_sample_frame_count', 'int32_t']
]
},
+ # Implements a call to get recommended sample frame count
+ {'name': 'PPB_AudioConfig_RecommendSampleFrameCount',
+ 'inputs': [['instance', 'PP_Instance'],
+ ['request_sample_rate', 'int32_t'],
+ ['request_sample_frame_count', 'int32_t'],
+ ],
+ 'outputs': [['out_sample_frame_count', 'int32_t']
+ ]
+ },
# Implements a call to get the sample rate.
{'name': 'PPB_AudioConfig_GetSampleRate',
'inputs': [['resource', 'PP_Resource'],
@@ -46,5 +55,12 @@
'outputs': [['sample_frame_count', 'int32_t'],
]
},
+ # Implements a call to get recommended sample rate
+ {'name': 'PPB_AudioConfig_RecommendSampleRate',
+ 'inputs': [['instance', 'PP_Instance'],
+ ],
+ 'outputs': [['sample_rate', 'int32_t']
+ ]
+ },
]
}
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc
index 68c19ab..3b72662 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc
@@ -201,8 +201,28 @@ NaClSrpcError PpbAudioConfigRpcClient::PPB_AudioConfig_IsAudioConfig(
return retval;
}
+NaClSrpcError PpbAudioConfigRpcClient::PPB_AudioConfig_RecommendSampleFrameCount_1_0(
+ NaClSrpcChannel* channel,
+ int32_t request_sample_rate,
+ int32_t request_sample_frame_count,
+ int32_t* out_sample_frame_count) {
+ VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(),
+ ("%s: PPAPI calls are not supported off the main thread\n",
+ __FUNCTION__));
+ NaClSrpcError retval;
+ retval = NaClSrpcInvokeBySignature(
+ channel,
+ "PPB_AudioConfig_RecommendSampleFrameCount_1_0:ii:i",
+ request_sample_rate,
+ request_sample_frame_count,
+ out_sample_frame_count
+ );
+ return retval;
+}
+
NaClSrpcError PpbAudioConfigRpcClient::PPB_AudioConfig_RecommendSampleFrameCount(
NaClSrpcChannel* channel,
+ PP_Instance instance,
int32_t request_sample_rate,
int32_t request_sample_frame_count,
int32_t* out_sample_frame_count) {
@@ -212,7 +232,8 @@ NaClSrpcError PpbAudioConfigRpcClient::PPB_AudioConfig_RecommendSampleFrameCount
NaClSrpcError retval;
retval = NaClSrpcInvokeBySignature(
channel,
- "PPB_AudioConfig_RecommendSampleFrameCount:ii:i",
+ "PPB_AudioConfig_RecommendSampleFrameCount:iii:i",
+ instance,
request_sample_rate,
request_sample_frame_count,
out_sample_frame_count
@@ -254,6 +275,23 @@ NaClSrpcError PpbAudioConfigRpcClient::PPB_AudioConfig_GetSampleFrameCount(
return retval;
}
+NaClSrpcError PpbAudioConfigRpcClient::PPB_AudioConfig_RecommendSampleRate(
+ NaClSrpcChannel* channel,
+ PP_Instance instance,
+ int32_t* sample_rate) {
+ VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(),
+ ("%s: PPAPI calls are not supported off the main thread\n",
+ __FUNCTION__));
+ NaClSrpcError retval;
+ retval = NaClSrpcInvokeBySignature(
+ channel,
+ "PPB_AudioConfig_RecommendSampleRate:i:i",
+ instance,
+ sample_rate
+ );
+ return retval;
+}
+
NaClSrpcError PpbCoreRpcClient::PPB_Core_AddRefResource(
NaClSrpcChannel* channel,
PP_Resource resource) {
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc
index 91fdd0d..3e2a497 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc
@@ -169,6 +169,21 @@ static void PPB_AudioConfig_IsAudioConfigDispatcher(
);
}
+static void PPB_AudioConfig_RecommendSampleFrameCount_1_0Dispatcher(
+ NaClSrpcRpc* rpc,
+ NaClSrpcArg** inputs,
+ NaClSrpcArg** outputs,
+ NaClSrpcClosure* done
+) {
+ PpbAudioConfigRpcServer::PPB_AudioConfig_RecommendSampleFrameCount_1_0(
+ rpc,
+ done,
+ inputs[0]->u.ival,
+ inputs[1]->u.ival,
+ &(outputs[0]->u.ival)
+ );
+}
+
static void PPB_AudioConfig_RecommendSampleFrameCountDispatcher(
NaClSrpcRpc* rpc,
NaClSrpcArg** inputs,
@@ -180,6 +195,7 @@ static void PPB_AudioConfig_RecommendSampleFrameCountDispatcher(
done,
inputs[0]->u.ival,
inputs[1]->u.ival,
+ inputs[2]->u.ival,
&(outputs[0]->u.ival)
);
}
@@ -212,6 +228,20 @@ static void PPB_AudioConfig_GetSampleFrameCountDispatcher(
);
}
+static void PPB_AudioConfig_RecommendSampleRateDispatcher(
+ NaClSrpcRpc* rpc,
+ NaClSrpcArg** inputs,
+ NaClSrpcArg** outputs,
+ NaClSrpcClosure* done
+) {
+ PpbAudioConfigRpcServer::PPB_AudioConfig_RecommendSampleRate(
+ rpc,
+ done,
+ inputs[0]->u.ival,
+ &(outputs[0]->u.ival)
+ );
+}
+
static void PPB_Core_AddRefResourceDispatcher(
NaClSrpcRpc* rpc,
NaClSrpcArg** inputs,
@@ -2922,9 +2952,11 @@ NaClSrpcHandlerDesc PpbRpcs::srpc_methods[] = {
{ "PPB_Audio_StartPlayback:i:i", PPB_Audio_StartPlaybackDispatcher },
{ "PPB_AudioConfig_CreateStereo16Bit:iii:i", PPB_AudioConfig_CreateStereo16BitDispatcher },
{ "PPB_AudioConfig_IsAudioConfig:i:i", PPB_AudioConfig_IsAudioConfigDispatcher },
- { "PPB_AudioConfig_RecommendSampleFrameCount:ii:i", PPB_AudioConfig_RecommendSampleFrameCountDispatcher },
+ { "PPB_AudioConfig_RecommendSampleFrameCount_1_0:ii:i", PPB_AudioConfig_RecommendSampleFrameCount_1_0Dispatcher },
+ { "PPB_AudioConfig_RecommendSampleFrameCount:iii:i", PPB_AudioConfig_RecommendSampleFrameCountDispatcher },
{ "PPB_AudioConfig_GetSampleRate:i:i", PPB_AudioConfig_GetSampleRateDispatcher },
{ "PPB_AudioConfig_GetSampleFrameCount:i:i", PPB_AudioConfig_GetSampleFrameCountDispatcher },
+ { "PPB_AudioConfig_RecommendSampleRate:i:i", PPB_AudioConfig_RecommendSampleRateDispatcher },
{ "PPB_Core_AddRefResource:i:", PPB_Core_AddRefResourceDispatcher },
{ "PPB_Core_ReleaseResource:i:", PPB_Core_ReleaseResourceDispatcher },
{ "ReleaseResourceMultipleTimes:ii:", ReleaseResourceMultipleTimesDispatcher },
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h
index c0e96ee..3d25c00 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h
+++ b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h
@@ -103,9 +103,16 @@ class PpbAudioConfigRpcServer {
NaClSrpcClosure* done,
PP_Resource resource,
int32_t* out_bool);
+ static void PPB_AudioConfig_RecommendSampleFrameCount_1_0(
+ NaClSrpcRpc* rpc,
+ NaClSrpcClosure* done,
+ int32_t request_sample_rate,
+ int32_t request_sample_frame_count,
+ int32_t* out_sample_frame_count);
static void PPB_AudioConfig_RecommendSampleFrameCount(
NaClSrpcRpc* rpc,
NaClSrpcClosure* done,
+ PP_Instance instance,
int32_t request_sample_rate,
int32_t request_sample_frame_count,
int32_t* out_sample_frame_count);
@@ -119,6 +126,11 @@ class PpbAudioConfigRpcServer {
NaClSrpcClosure* done,
PP_Resource resource,
int32_t* sample_frame_count);
+ static void PPB_AudioConfig_RecommendSampleRate(
+ NaClSrpcRpc* rpc,
+ NaClSrpcClosure* done,
+ PP_Instance instance,
+ int32_t* sample_rate);
private:
PpbAudioConfigRpcServer();
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h
index 1f3b993..e61f756 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h
+++ b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h
@@ -93,8 +93,14 @@ class PpbAudioConfigRpcClient {
NaClSrpcChannel* channel,
PP_Resource resource,
int32_t* out_bool);
+ static NaClSrpcError PPB_AudioConfig_RecommendSampleFrameCount_1_0(
+ NaClSrpcChannel* channel,
+ int32_t request_sample_rate,
+ int32_t request_sample_frame_count,
+ int32_t* out_sample_frame_count);
static NaClSrpcError PPB_AudioConfig_RecommendSampleFrameCount(
NaClSrpcChannel* channel,
+ PP_Instance instance,
int32_t request_sample_rate,
int32_t request_sample_frame_count,
int32_t* out_sample_frame_count);
@@ -106,6 +112,10 @@ class PpbAudioConfigRpcClient {
NaClSrpcChannel* channel,
PP_Resource resource,
int32_t* sample_frame_count);
+ static NaClSrpcError PPB_AudioConfig_RecommendSampleRate(
+ NaClSrpcChannel* channel,
+ PP_Instance instance,
+ int32_t* sample_rate);
private:
PpbAudioConfigRpcClient();
diff --git a/ppapi/native_client/tests/ppapi_example_audio/audio.cc b/ppapi/native_client/tests/ppapi_example_audio/audio.cc
index 8b2fe25..ea214ba 100644
--- a/ppapi/native_client/tests/ppapi_example_audio/audio.cc
+++ b/ppapi/native_client/tests/ppapi_example_audio/audio.cc
@@ -35,12 +35,6 @@ const double kDefaultFrequencyLeft = 400.0;
const double kDefaultFrequencyRight = 1000.0;
const uint32_t kDefaultDuration = 10000;
-// This sample frequency is guaranteed to work.
-const PP_AudioSampleRate kSampleFrequency = PP_AUDIOSAMPLERATE_44100;
-// Buffer size in units of sample frames.
-// 4096 is a conservative size that should avoid underruns on most systems.
-const uint32_t kSampleFrameCount = 4096;
-
const double kPi = 3.141592653589;
const double kTwoPi = 2.0 * kPi;
@@ -198,11 +192,13 @@ class MyInstance : public pp::Instance {
}
virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
+ const int32_t kSampleFrameCount = 2048;
ParseArgs(argc, argn, argv);
+ obtained_sample_rate_ = pp::AudioConfig::RecommendSampleRate(this);
obtained_sample_frame_count_ = pp::AudioConfig::RecommendSampleFrameCount(
- kSampleFrequency, kSampleFrameCount);
- config_ = new
- pp::AudioConfig(this, kSampleFrequency, obtained_sample_frame_count_);
+ this, obtained_sample_rate_, kSampleFrameCount);
+ config_ = new pp::AudioConfig(
+ this, obtained_sample_rate_, obtained_sample_frame_count_);
CHECK(NULL != config_);
audio_ = new pp::Audio(this, *config_, SineWaveCallback, this);
CHECK(NULL != audio_);
@@ -214,8 +210,10 @@ class MyInstance : public pp::Instance {
private:
static void SineWaveCallback(void* samples, uint32_t num_bytes, void* thiz) {
MyInstance* instance = reinterpret_cast<MyInstance*>(thiz);
- const double delta_l = kTwoPi * instance->frequency_l_ / kSampleFrequency;
- const double delta_r = kTwoPi * instance->frequency_r_ / kSampleFrequency;
+ const double delta_l = kTwoPi * instance->frequency_l_ /
+ instance->obtained_sample_rate_;
+ const double delta_r = kTwoPi * instance->frequency_r_ /
+ instance->obtained_sample_rate_;
// Verify num_bytes and obtained_sample_frame_count match up.
const int kNumChannelsForStereo = 2;
@@ -277,6 +275,7 @@ class MyInstance : public pp::Instance {
bool stress_tests_;
uint32_t duration_msec_;
+ PP_AudioSampleRate obtained_sample_rate_;
uint32_t obtained_sample_frame_count_;
int callback_count_;
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 1f47a17..7a37f08 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -923,6 +923,14 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBInstance_BindGraphics,
PP_Instance /* instance */,
ppapi::HostResource /* device */,
PP_Bool /* result */)
+IPC_SYNC_MESSAGE_ROUTED1_1(
+ PpapiHostMsg_PPBInstance_GetAudioHardwareOutputSampleRate,
+ PP_Instance /* instance */,
+ uint32_t /* result */)
+IPC_SYNC_MESSAGE_ROUTED1_1(
+ PpapiHostMsg_PPBInstance_GetAudioHardwareOutputBufferSize,
+ PP_Instance /* instance */,
+ uint32_t /* result */)
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_IsFullFrame,
PP_Instance /* instance */,
PP_Bool /* result */)
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index 5bdde43..1f71e87 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -6,6 +6,7 @@
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/pp_var.h"
+#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_instance.h"
#include "ppapi/c/ppb_messaging.h"
#include "ppapi/c/ppb_mouse_lock.h"
@@ -82,6 +83,12 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgBindGraphics)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame,
OnHostMsgIsFullFrame)
+ IPC_MESSAGE_HANDLER(
+ PpapiHostMsg_PPBInstance_GetAudioHardwareOutputSampleRate,
+ OnHostMsgGetAudioHardwareOutputSampleRate)
+ IPC_MESSAGE_HANDLER(
+ PpapiHostMsg_PPBInstance_GetAudioHardwareOutputBufferSize,
+ OnHostMsgGetAudioHardwareOutputBufferSize)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript,
OnHostMsgExecuteScript)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDefaultCharSet,
@@ -185,6 +192,24 @@ PP_Var PPB_Instance_Proxy::ExecuteScript(PP_Instance instance,
return result.Return(dispatcher());
}
+uint32_t PPB_Instance_Proxy::GetAudioHardwareOutputSampleRate(
+ PP_Instance instance) {
+ uint32_t result = PP_AUDIOSAMPLERATE_NONE;
+ dispatcher()->Send(
+ new PpapiHostMsg_PPBInstance_GetAudioHardwareOutputSampleRate(
+ API_ID_PPB_INSTANCE, instance, &result));
+ return result;
+}
+
+uint32_t PPB_Instance_Proxy::GetAudioHardwareOutputBufferSize(
+ PP_Instance instance) {
+ uint32_t result = 0;
+ dispatcher()->Send(
+ new PpapiHostMsg_PPBInstance_GetAudioHardwareOutputBufferSize(
+ API_ID_PPB_INSTANCE, instance, &result));
+ return result;
+}
+
PP_Var PPB_Instance_Proxy::GetDefaultCharSet(PP_Instance instance) {
PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
if (!dispatcher)
@@ -421,6 +446,20 @@ void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance,
}
}
+void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate(
+ PP_Instance instance, uint32_t* result) {
+ EnterInstanceNoLock enter(instance, false);
+ if (enter.succeeded())
+ *result = enter.functions()->GetAudioHardwareOutputSampleRate(instance);
+}
+
+void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputBufferSize(
+ PP_Instance instance, uint32_t* result) {
+ EnterInstanceNoLock enter(instance, false);
+ if (enter.succeeded())
+ *result = enter.functions()->GetAudioHardwareOutputBufferSize(instance);
+}
+
void PPB_Instance_Proxy::OnHostMsgIsFullFrame(PP_Instance instance,
PP_Bool* result) {
EnterInstanceNoLock enter(instance, false);
diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h
index ba6b2ae..80927a3 100644
--- a/ppapi/proxy/ppb_instance_proxy.h
+++ b/ppapi/proxy/ppb_instance_proxy.h
@@ -52,6 +52,10 @@ class PPB_Instance_Proxy : public InterfaceProxy,
virtual PP_Var ExecuteScript(PP_Instance instance,
PP_Var script,
PP_Var* exception) OVERRIDE;
+ virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance)
+ OVERRIDE;
+ virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance)
+ OVERRIDE;
virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE;
virtual void NumberOfFindResultsChanged(PP_Instance instance,
int32_t total,
@@ -113,6 +117,10 @@ class PPB_Instance_Proxy : public InterfaceProxy,
SerializedVarReceiveInput script,
SerializedVarOutParam out_exception,
SerializedVarReturnValue result);
+ void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance,
+ uint32_t *result);
+ void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance,
+ uint32_t *result);
void OnHostMsgGetDefaultCharSet(PP_Instance instance,
SerializedVarReturnValue result);
void OnHostMsgSetFullscreen(PP_Instance instance,
diff --git a/ppapi/shared_impl/ppb_audio_config_shared.cc b/ppapi/shared_impl/ppb_audio_config_shared.cc
index a866d79..a88b851 100644
--- a/ppapi/shared_impl/ppb_audio_config_shared.cc
+++ b/ppapi/shared_impl/ppb_audio_config_shared.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "ppapi/shared_impl/ppb_audio_config_shared.h"
+#include "ppapi/thunk/enter.h"
namespace ppapi {
@@ -28,6 +29,76 @@ PP_Resource PPB_AudioConfig_Shared::Create(
return object->GetReference();
}
+// static
+uint32_t PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_0(
+ PP_AudioSampleRate sample_rate,
+ uint32_t requested_sample_frame_count) {
+ // Version 1.0: Don't actually query to get a value from the
+ // hardware; instead return the input for in-range values.
+ if (requested_sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT)
+ return PP_AUDIOMINSAMPLEFRAMECOUNT;
+ if (requested_sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT)
+ return PP_AUDIOMAXSAMPLEFRAMECOUNT;
+ return requested_sample_frame_count;
+}
+
+// static
+uint32_t PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_1(
+ PP_Instance instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t sample_frame_count) {
+ // Version 1.1: Query the back-end hardware for sample rate and buffer size,
+ // and recommend a best fit based on request.
+ thunk::EnterInstance enter(instance);
+ if (enter.failed())
+ return 0;
+
+ // Get the hardware config.
+ PP_AudioSampleRate hardware_sample_rate = static_cast<PP_AudioSampleRate>(
+ enter.functions()->GetAudioHardwareOutputSampleRate(instance));
+ uint32_t hardware_sample_frame_count =
+ enter.functions()->GetAudioHardwareOutputBufferSize(instance);
+ if (sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT)
+ sample_frame_count = PP_AUDIOMINSAMPLEFRAMECOUNT;
+
+ // If client is using same sample rate as audio hardware, then recommend a
+ // multiple of the audio hardware's sample frame count.
+ if (hardware_sample_rate == sample_rate && hardware_sample_frame_count > 0) {
+ // Round up input sample_frame_count to nearest multiple.
+ uint32_t multiple = (sample_frame_count + hardware_sample_frame_count - 1) /
+ hardware_sample_frame_count;
+ uint32_t recommendation = hardware_sample_frame_count * multiple;
+ if (recommendation > PP_AUDIOMAXSAMPLEFRAMECOUNT)
+ recommendation = PP_AUDIOMAXSAMPLEFRAMECOUNT;
+ return recommendation;
+ }
+
+ // Otherwise, recommend a conservative 30ms buffer based on sample rate.
+ const uint32_t kDefault30msAt44100kHz = 1323;
+ const uint32_t kDefault30msAt48000kHz = 1440;
+ switch (sample_rate) {
+ case PP_AUDIOSAMPLERATE_44100:
+ return kDefault30msAt44100kHz;
+ case PP_AUDIOSAMPLERATE_48000:
+ return kDefault30msAt48000kHz;
+ case PP_AUDIOSAMPLERATE_NONE:
+ return 0;
+ }
+ // Unable to make a recommendation.
+ return 0;
+}
+
+// static
+PP_AudioSampleRate PPB_AudioConfig_Shared::RecommendSampleRate(
+ PP_Instance instance) {
+ thunk::EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_AUDIOSAMPLERATE_NONE;
+ PP_AudioSampleRate hardware_sample_rate = static_cast<PP_AudioSampleRate>(
+ enter.functions()->GetAudioHardwareOutputSampleRate(instance));
+ return hardware_sample_rate;
+}
+
thunk::PPB_AudioConfig_API* PPB_AudioConfig_Shared::AsPPB_AudioConfig_API() {
return this;
}
diff --git a/ppapi/shared_impl/ppb_audio_config_shared.h b/ppapi/shared_impl/ppb_audio_config_shared.h
index 410a32a8b..0174666 100644
--- a/ppapi/shared_impl/ppb_audio_config_shared.h
+++ b/ppapi/shared_impl/ppb_audio_config_shared.h
@@ -22,6 +22,12 @@ class PPAPI_SHARED_EXPORT PPB_AudioConfig_Shared
PP_Instance instance,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count);
+ static uint32_t RecommendSampleFrameCount_1_0(PP_AudioSampleRate sample_rate,
+ uint32_t request_sample_frame_count);
+ static uint32_t RecommendSampleFrameCount_1_1(PP_Instance instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t request_sample_frame_count);
+ static PP_AudioSampleRate RecommendSampleRate(PP_Instance);
// Resource overrides.
virtual thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() OVERRIDE;
diff --git a/ppapi/tests/test_audio.cc b/ppapi/tests/test_audio.cc
index 91c4d6d..b69ef4e 100644
--- a/ppapi/tests/test_audio.cc
+++ b/ppapi/tests/test_audio.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -64,7 +64,7 @@ std::string TestAudio::TestCreation() {
// Make a config, create the audio resource, and release the config.
uint32_t request_frame_count = kRequestFrameCounts[j];
uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount(
- sample_rate, request_frame_count);
+ instance_->pp_instance(), sample_rate, request_frame_count);
PP_Resource ac = audio_config_interface_->CreateStereo16Bit(
instance_->pp_instance(), sample_rate, frame_count);
ASSERT_TRUE(ac);
@@ -106,7 +106,7 @@ std::string TestAudio::TestDestroyNoStop() {
const uint32_t kRequestFrameCount = 2048;
uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount(
- kSampleRate, kRequestFrameCount);
+ instance_->pp_instance(), kSampleRate, kRequestFrameCount);
PP_Resource ac = audio_config_interface_->CreateStereo16Bit(
instance_->pp_instance(), kSampleRate, frame_count);
ASSERT_TRUE(ac);
@@ -133,7 +133,7 @@ std::string TestAudio::TestFailures() {
// We want a valid config for some of our tests of |Create()|.
uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount(
- kSampleRate, kRequestFrameCount);
+ instance_->pp_instance(), kSampleRate, kRequestFrameCount);
PP_Resource ac = audio_config_interface_->CreateStereo16Bit(
instance_->pp_instance(), kSampleRate, frame_count);
ASSERT_TRUE(ac);
diff --git a/ppapi/tests/test_audio_config.cc b/ppapi/tests/test_audio_config.cc
index 79e847ff..902fc61 100644
--- a/ppapi/tests/test_audio_config.cc
+++ b/ppapi/tests/test_audio_config.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -48,7 +48,7 @@ std::string TestAudioConfig::TestValidConfigs() {
ASSERT_TRUE(request_frame_count <= PP_AUDIOMAXSAMPLEFRAMECOUNT);
uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount(
- sample_rate, request_frame_count);
+ instance_->pp_instance(), sample_rate, request_frame_count);
ASSERT_TRUE(frame_count >= PP_AUDIOMINSAMPLEFRAMECOUNT);
ASSERT_TRUE(frame_count <= PP_AUDIOMAXSAMPLEFRAMECOUNT);
diff --git a/ppapi/thunk/interfaces_ppb_public_stable.h b/ppapi/thunk/interfaces_ppb_public_stable.h
index 5bf22de..d8a3f03 100644
--- a/ppapi/thunk/interfaces_ppb_public_stable.h
+++ b/ppapi/thunk/interfaces_ppb_public_stable.h
@@ -49,6 +49,7 @@ PROXIED_API(PPB_URLResponseInfo)
PROXIED_IFACE(PPB_Audio, PPB_AUDIO_INTERFACE_1_0, PPB_Audio_1_0)
// This has no corresponding _Proxy object since it does no IPC.
PROXIED_IFACE(NoAPIName, PPB_AUDIO_CONFIG_INTERFACE_1_0, PPB_AudioConfig_1_0)
+PROXIED_IFACE(NoAPIName, PPB_AUDIO_CONFIG_INTERFACE_1_1, PPB_AudioConfig_1_1)
// Note: Core is special and is registered manually.
PROXIED_IFACE(PPB_FileIO, PPB_FILEIO_INTERFACE_1_0, PPB_FileIO_1_0)
PROXIED_IFACE(PPB_FileRef, PPB_FILEREF_INTERFACE_1_0, PPB_FileRef_1_0)
diff --git a/ppapi/thunk/ppb_audio_config_thunk.cc b/ppapi/thunk/ppb_audio_config_thunk.cc
index 2cc82a3..123d148 100644
--- a/ppapi/thunk/ppb_audio_config_thunk.cc
+++ b/ppapi/thunk/ppb_audio_config_thunk.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ppapi/shared_impl/ppb_audio_config_shared.h"
#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_audio_config_api.h"
@@ -22,17 +23,23 @@ PP_Resource CreateStereo16bit(PP_Instance instance,
sample_frame_count);
}
-uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate,
- uint32_t requested_sample_frame_count) {
- // TODO(brettw) Currently we don't actually query to get a value from the
- // hardware, so we always return the input for in-range values.
- if (requested_sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT)
- return PP_AUDIOMINSAMPLEFRAMECOUNT;
- if (requested_sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT)
- return PP_AUDIOMAXSAMPLEFRAMECOUNT;
- return requested_sample_frame_count;
+uint32_t RecommendSampleFrameCount_1_0(PP_AudioSampleRate sample_rate,
+ uint32_t requested_sample_frame_count) {
+ return PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_0(sample_rate,
+ requested_sample_frame_count);
}
+uint32_t RecommendSampleFrameCount_1_1(PP_Instance instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t requested_sample_frame_count) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return 0;
+ return PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_1(instance,
+ sample_rate, requested_sample_frame_count);
+}
+
+
PP_Bool IsAudioConfig(PP_Resource resource) {
EnterResource<PPB_AudioConfig_API> enter(resource, false);
return PP_FromBool(enter.succeeded());
@@ -52,18 +59,39 @@ uint32_t GetSampleFrameCount(PP_Resource config_id) {
return enter.object()->GetSampleFrameCount();
}
-const PPB_AudioConfig g_ppb_audio_config_thunk = {
+PP_AudioSampleRate RecommendSampleRate(PP_Instance instance) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_AUDIOSAMPLERATE_NONE;
+ return PPB_AudioConfig_Shared::RecommendSampleRate(instance);
+}
+
+const PPB_AudioConfig_1_0 g_ppb_audio_config_thunk_1_0 = {
&CreateStereo16bit,
- &RecommendSampleFrameCount,
+ &RecommendSampleFrameCount_1_0,
&IsAudioConfig,
&GetSampleRate,
&GetSampleFrameCount
};
+const PPB_AudioConfig_1_1 g_ppb_audio_config_thunk_1_1 = {
+ &CreateStereo16bit,
+ &RecommendSampleFrameCount_1_1,
+ &IsAudioConfig,
+ &GetSampleRate,
+ &GetSampleFrameCount,
+ &RecommendSampleRate
+};
+
+
} // namespace
const PPB_AudioConfig_1_0* GetPPB_AudioConfig_1_0_Thunk() {
- return &g_ppb_audio_config_thunk;
+ return &g_ppb_audio_config_thunk_1_0;
+}
+
+const PPB_AudioConfig_1_1* GetPPB_AudioConfig_1_1_Thunk() {
+ return &g_ppb_audio_config_thunk_1_1;
}
} // namespace thunk
diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h
index 741f762..3055d73 100644
--- a/ppapi/thunk/ppb_instance_api.h
+++ b/ppapi/thunk/ppb_instance_api.h
@@ -9,6 +9,7 @@
#include "ppapi/c/dev/ppb_gamepad_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_instance.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_size.h"
@@ -43,6 +44,10 @@ class PPB_Instance_FunctionAPI {
PP_Var script,
PP_Var* exception) = 0;
+ // Audio.
+ virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance) = 0;
+ virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance) = 0;
+
// CharSet.
virtual PP_Var GetDefaultCharSet(PP_Instance instance) = 0;
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc
index 0c3169d..ea6a9f2 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.cc
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc
@@ -71,6 +71,14 @@ MockPluginDelegate::CreateVideoCapture(
return NULL;
}
+uint32_t MockPluginDelegate::GetAudioHardwareOutputSampleRate() {
+ return 0;
+}
+
+uint32_t MockPluginDelegate::GetAudioHardwareOutputBufferSize() {
+ return 0;
+}
+
MockPluginDelegate::PlatformAudio* MockPluginDelegate::CreateAudio(
uint32_t sample_rate,
uint32_t sample_count,
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h
index 074e762..cb40de7 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.h
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.h
@@ -33,6 +33,8 @@ class MockPluginDelegate : public PluginDelegate {
virtual PlatformVideoCapture* CreateVideoCapture(
const std::string& device_id,
PlatformVideoCaptureEventHandler* handler);
+ virtual uint32_t GetAudioHardwareOutputSampleRate();
+ virtual uint32_t GetAudioHardwareOutputBufferSize();
virtual PlatformAudio* CreateAudio(uint32_t sample_rate,
uint32_t sample_count,
PlatformAudioCommonClient* client);
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index b0e9dac..fe7d45d 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -325,6 +325,12 @@ class PluginDelegate {
media::VideoDecodeAccelerator::Client* client,
int32 command_buffer_route_id) = 0;
+ // Get audio hardware output sample rate.
+ virtual uint32_t GetAudioHardwareOutputSampleRate() = 0;
+
+ // Get audio hardware output buffer size.
+ virtual uint32_t GetAudioHardwareOutputBufferSize() = 0;
+
// The caller is responsible for calling Shutdown() on the returned pointer
// to clean up the corresponding resources allocated during this call.
virtual PlatformAudio* CreateAudio(uint32_t sample_rate,
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 5d061b9..cdeb48d 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -19,6 +19,7 @@
#include "ppapi/c/dev/ppp_selection_dev.h"
#include "ppapi/c/dev/ppp_zoom_dev.h"
#include "ppapi/c/pp_rect.h"
+#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_core.h"
#include "ppapi/c/ppp_input_event.h"
#include "ppapi/c/ppp_instance.h"
@@ -1852,6 +1853,16 @@ PP_Var PluginInstance::ExecuteScript(PP_Instance instance,
return ret;
}
+uint32_t PluginInstance::GetAudioHardwareOutputSampleRate(
+ PP_Instance instance) {
+ return delegate()->GetAudioHardwareOutputSampleRate();
+}
+
+uint32_t PluginInstance::GetAudioHardwareOutputBufferSize(
+ PP_Instance instance) {
+ return delegate()->GetAudioHardwareOutputBufferSize();
+}
+
PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) {
std::string encoding = delegate()->GetDefaultEncoding();
return StringVar::StringToPPVar(encoding);
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index c9179b2..8e7ee6b 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -25,6 +25,7 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
+#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_input_event.h"
#include "ppapi/c/ppp_graphics_3d.h"
#include "ppapi/c/ppp_input_event.h"
@@ -330,6 +331,10 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
virtual PP_Var ExecuteScript(PP_Instance instance,
PP_Var script,
PP_Var* exception) OVERRIDE;
+ virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance)
+ OVERRIDE;
+ virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance)
+ OVERRIDE;
virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE;
virtual PP_Var GetFontFamilies(PP_Instance instance) OVERRIDE;
virtual void NumberOfFindResultsChanged(PP_Instance instance,