summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authornfullagar@google.com <nfullagar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-15 01:04:00 +0000
committernfullagar@google.com <nfullagar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-15 01:04:00 +0000
commitb9a598494478fe8c04b6b7ba1f982ab91be6a521 (patch)
tree9b76d2753d28ace9a7efa5957342e8ad5cdadf45 /ppapi
parent97d2f1d24de99d6c19bf053fa7d3e61ede99e9c5 (diff)
downloadchromium_src-b9a598494478fe8c04b6b7ba1f982ab91be6a521.zip
chromium_src-b9a598494478fe8c04b6b7ba1f982ab91be6a521.tar.gz
chromium_src-b9a598494478fe8c04b6b7ba1f982ab91be6a521.tar.bz2
Move ppapi audio interface out of dev, but
for this CL, also keep the old dev interface around temporarily, to avoid tree breakage. Add sample_rate to RecommendSampleFrameCount() to the non-dev audio interface. Currently ignored, but useful information to use when we need to refine RecommendSampleFrameCount() Review URL: http://codereview.chromium.org/6279003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71527 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/ppb_audio.h73
-rw-r--r--ppapi/c/ppb_audio_config.h98
-rw-r--r--ppapi/c/trusted/ppb_audio_trusted.h50
-rw-r--r--ppapi/cpp/audio.cc41
-rw-r--r--ppapi/cpp/audio.h37
-rw-r--r--ppapi/cpp/audio_config.cc49
-rw-r--r--ppapi/cpp/audio_config.h61
-rw-r--r--ppapi/cpp/dev/audio_config_dev.h2
-rw-r--r--ppapi/examples/audio/audio.cc20
-rw-r--r--ppapi/ppapi.gyp7
-rw-r--r--ppapi/proxy/dispatcher.cc8
-rw-r--r--ppapi/proxy/ppapi_messages_internal.h3
-rw-r--r--ppapi/proxy/ppb_audio_config_proxy.cc30
-rw-r--r--ppapi/proxy/ppb_audio_config_proxy.h10
-rw-r--r--ppapi/proxy/ppb_audio_proxy.cc18
-rw-r--r--ppapi/proxy/ppb_audio_proxy.h6
-rw-r--r--ppapi/shared_impl/audio_impl.h2
17 files changed, 470 insertions, 45 deletions
diff --git a/ppapi/c/ppb_audio.h b/ppapi/c/ppb_audio.h
new file mode 100644
index 0000000..5c14a0e
--- /dev/null
+++ b/ppapi/c/ppb_audio.h
@@ -0,0 +1,73 @@
+/* Copyright (c) 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.
+ */
+#ifndef PPAPI_C_PPB_AUDIO_H_
+#define PPAPI_C_PPB_AUDIO_H_
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/pp_stdint.h"
+
+#define PPB_AUDIO_INTERFACE "PPB_Audio;1.0"
+
+// Callback function type for SetCallback.
+typedef void (*PPB_Audio_Callback)(void* sample_buffer,
+ size_t buffer_size_in_bytes,
+ void* user_data);
+
+// Callback-based audio interface. User of audio must set the callback that will
+// be called each time that the buffer needs to be filled.
+//
+// A C++ example:
+//
+// void audio_callback(void* sample_buffer,
+// size_t buffer_size_in_bytes,
+// void* user_data) {
+// ... fill in the buffer with samples ...
+// }
+//
+// uint32_t obtained;
+// AudioConfig config(PP_AUDIOSAMPLERATE_44100, 4096, &obtained);
+// Audio audio(config, audio_callback, NULL);
+// audio.StartPlayback();
+//
+struct PPB_Audio {
+ // Creates a paused audio interface. No sound will be heard until
+ // StartPlayback() is called. The callback is called with the buffer address
+ // and given user data whenever the buffer needs to be filled. From within the
+ // callback, you should not call PPB_Audio functions. The callback will be
+ // called on a different thread than the one which created the interface. For
+ // performance-critical applications (i.e. low-latency audio), the callback
+ // should avoid blocking or calling functions that can obtain locks, such as
+ // malloc. The layout and the size of the buffer passed to the audio callback
+ // will be determined by the device configuration and is specified in the
+ // AudioConfig documentation. If the configuration cannot be honored, or the
+ // callback is null, the function returns 0.
+ PP_Resource (*Create)(PP_Instance instance, PP_Resource config,
+ PPB_Audio_Callback audio_callback, void* user_data);
+
+ /**
+ * Returns PP_TRUE if the given resource is an Audio resource, PP_FALSE
+ * otherwise.
+ */
+ PP_Bool (*IsAudio)(PP_Resource resource);
+
+ // Get the current configuration.
+ PP_Resource (*GetCurrentConfig)(PP_Resource audio);
+
+ // Start the playback. Begin periodically calling the callback. If called
+ // while playback is already in progress, will return PP_TRUE and be a no-op.
+ // On error, return PP_FALSE.
+ PP_Bool (*StartPlayback)(PP_Resource audio);
+
+ // Stop the playback. If playback is already stopped, this is a no-op and
+ // returns PP_TRUE. On error, returns PP_FALSE. If a callback is in progress,
+ // StopPlayback will block until callback completes.
+ PP_Bool (*StopPlayback)(PP_Resource audio);
+};
+
+#endif /* PPAPI_C_PPB_DEVICE_CONTEXT_AUDIO_H_ */
+
diff --git a/ppapi/c/ppb_audio_config.h b/ppapi/c/ppb_audio_config.h
new file mode 100644
index 0000000..1e836a0
--- /dev/null
+++ b/ppapi/c/ppb_audio_config.h
@@ -0,0 +1,98 @@
+/* Copyright (c) 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.
+ */
+#ifndef PPAPI_C_PPB_AUDIO_CONFIG_H_
+#define PPAPI_C_PPB_AUDIO_CONFIG_H_
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_macros.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/pp_stdint.h"
+
+#define PPB_AUDIO_CONFIG_INTERFACE "PPB_AudioConfig;1.0"
+
+enum {
+ PP_AUDIOMINSAMPLEFRAMECOUNT = 64,
+ PP_AUDIOMAXSAMPLEFRAMECOUNT = 32768
+};
+
+typedef enum {
+ PP_AUDIOSAMPLERATE_NONE = 0,
+ PP_AUDIOSAMPLERATE_44100 = 44100,
+ PP_AUDIOSAMPLERATE_48000 = 48000
+} PP_AudioSampleRate;
+PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_AudioSampleRate, 4);
+
+/**
+ * Audio configuration. This base configuration interface supports only stereo
+ * 16bit output. This class is not mutable, therefore it is okay to access
+ * instances from different threads.
+ */
+struct PPB_AudioConfig {
+ /**
+ * Create a 16 bit stereo config with the given sample rate. We guarantee
+ * that PP_AUDIOSAMPLERATE_44100 and PP_AUDIOSAMPLERATE_48000 sample rates
+ * are supported. The |sample_frame_count| should be the result of calling
+ * RecommendSampleFrameCount. If the sample frame count or bit rate aren'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.
+ *
+ * Buffer layout for a stereo int16 configuration:
+ * int16_t *buffer16;
+ * buffer16[0] is the first left channel sample
+ * buffer16[1] is the first right channel sample
+ * buffer16[2] is the second left channel sample
+ * buffer16[3] is the second right channel sample
+ * ...
+ * buffer16[2 * (sample_frame_count - 1)] is the last left channel sample
+ * buffer16[2 * (sample_frame_count - 1) + 1] is the last right channel sample
+ * Data will always be in the native endian format of the platform.
+ */
+ PP_Resource (*CreateStereo16Bit)(PP_Instance instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t sample_frame_count);
+
+ /*
+ * Returns a supported sample frame count closest to the given 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.
+ *
+ * Supported sample frame counts will vary by hardware and system (consider
+ * that the local system might be anywhere from a cell phone or a high-end
+ * audio workstation). Sample counts less than PP_AUDIOMINSAMPLEFRAMECOUNT
+ * and greater than PP_AUDIOMAXSAMPLEFRAMECOUNT are never supported on any
+ * system, but values in between aren't necessarily valid. This function
+ * will return a supported count closest to the requested value.
+ *
+ * If you pass 0 as the requested sample count, the recommended sample for
+ * the local system is returned.
+ */
+ uint32_t (*RecommendSampleFrameCount)(PP_AudioSampleRate sample_rate,
+ uint32_t requested_sample_frame_count);
+
+ /**
+ * Returns true if the given resource is an AudioConfig object.
+ */
+ PP_Bool (*IsAudioConfig)(PP_Resource resource);
+
+ /**
+ * Returns the sample rate for the given AudioConfig resource. If the
+ * resource is invalid, this will return PP_AUDIOSAMPLERATE_NONE.
+ */
+ PP_AudioSampleRate (*GetSampleRate)(PP_Resource config);
+
+ /**
+ * Returns the sample frame count for the given AudioConfig resource. If the
+ * resource is invalid, this will return 0. See RecommendSampleFrameCount for
+ * more on sample frame counts.
+ */
+ uint32_t (*GetSampleFrameCount)(PP_Resource config);
+};
+
+#endif /* PPAPI_C_PPB_AUDIO_CONFIG_H_ */
+
diff --git a/ppapi/c/trusted/ppb_audio_trusted.h b/ppapi/c/trusted/ppb_audio_trusted.h
new file mode 100644
index 0000000..36b2f80
--- /dev/null
+++ b/ppapi/c/trusted/ppb_audio_trusted.h
@@ -0,0 +1,50 @@
+/* Copyright (c) 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.
+ */
+#ifndef PPAPI_C_PPB_AUDIO_TRUSTED_H_
+#define PPAPI_C_PPB_AUDIO_TRUSTED_H_
+
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_resource.h"
+
+#define PPB_AUDIO_TRUSTED_INTERFACE "PPB_AudioTrusted;1.0"
+
+/**
+ * This interface is to be used by proxy implementations. All
+ * functions should be called from the main thread only. The
+ * resource returned is an Audio resource; most of the PPB_Audio
+ * interface is also usable on this resource.
+ */
+struct PPB_AudioTrusted {
+ /** Returns an audio resource. */
+ PP_Resource (*CreateTrusted)(PP_Instance instance);
+
+ /**
+ * Opens a paused audio interface, used by trusted side of proxy.
+ * Returns PP_ERROR_WOULD_BLOCK on success, and invokes
+ * the |create_callback| asynchronously to complete.
+ * As this function should always be invoked from the main thread,
+ * do not use the blocking variant of PP_CompletionCallback.
+ */
+ int32_t (*Open)(PP_Resource audio, PP_Resource config,
+ struct PP_CompletionCallback create_callback);
+
+ /**
+ * Get the sync socket. Use once Open has completed.
+ * Returns PP_OK on success.
+ */
+ int32_t (*GetSyncSocket)(PP_Resource audio, int* sync_socket);
+
+ /**
+ * Get the shared memory interface. Use once Open has completed.
+ * Returns PP_OK on success.
+ */
+ int32_t (*GetSharedMemory)(PP_Resource audio,
+ int* shm_handle,
+ uint32_t* shm_size);
+};
+
+#endif /* PPAPI_C_PPB_AUDIO_TRUSTED_H_ */
+
diff --git a/ppapi/cpp/audio.cc b/ppapi/cpp/audio.cc
new file mode 100644
index 0000000..00478c5
--- /dev/null
+++ b/ppapi/cpp/audio.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 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.
+
+#include "ppapi/cpp/audio.h"
+
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Audio>() {
+ return PPB_AUDIO_INTERFACE;
+}
+
+} // namespace
+
+Audio::Audio(Instance* instance,
+ const AudioConfig& config,
+ PPB_Audio_Callback callback,
+ void* user_data)
+ : config_(config) {
+ if (has_interface<PPB_Audio>()) {
+ PassRefFromConstructor(get_interface<PPB_Audio>()->Create(
+ instance->pp_instance(), config.pp_resource(), callback, user_data));
+ }
+}
+
+bool Audio::StartPlayback() {
+ return has_interface<PPB_Audio>() &&
+ get_interface<PPB_Audio>()->StartPlayback(pp_resource());
+}
+
+bool Audio::StopPlayback() {
+ return has_interface<PPB_Audio>() &&
+ get_interface<PPB_Audio>()->StopPlayback(pp_resource());
+}
+
+} // namespace pp
+
diff --git a/ppapi/cpp/audio.h b/ppapi/cpp/audio.h
new file mode 100644
index 0000000..6c75d42
--- /dev/null
+++ b/ppapi/cpp/audio.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2010 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 PPAPI_CPP_AUDIO_H_
+#define PPAPI_CPP_AUDIO_H_
+
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/c/ppb_audio.h"
+#include "ppapi/cpp/audio_config.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/resource.h"
+
+namespace pp {
+
+class Audio : public Resource {
+ public:
+ Audio() {}
+ Audio(Instance* instance,
+ const AudioConfig& config,
+ PPB_Audio_Callback callback,
+ void* user_data);
+
+ AudioConfig& config() { return config_; }
+ const AudioConfig& config() const { return config_; }
+
+ bool StartPlayback();
+ bool StopPlayback();
+
+ private:
+ AudioConfig config_;
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_AUDIO_H_
+
diff --git a/ppapi/cpp/audio_config.cc b/ppapi/cpp/audio_config.cc
new file mode 100644
index 0000000..b553dad
--- /dev/null
+++ b/ppapi/cpp/audio_config.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 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.
+
+#include "ppapi/cpp/audio_config.h"
+
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_AudioConfig>() {
+ return PPB_AUDIO_CONFIG_INTERFACE;
+}
+
+} // namespace
+
+AudioConfig::AudioConfig()
+ : sample_rate_(PP_AUDIOSAMPLERATE_NONE),
+ sample_frame_count_(0) {
+}
+
+AudioConfig::AudioConfig(Instance* instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t sample_frame_count)
+ : sample_rate_(sample_rate),
+ sample_frame_count_(sample_frame_count) {
+ if (has_interface<PPB_AudioConfig>()) {
+ PassRefFromConstructor(
+ get_interface<PPB_AudioConfig>()->CreateStereo16Bit(
+ instance->pp_instance(), sample_rate, sample_frame_count));
+ }
+}
+
+// static
+uint32_t AudioConfig::RecommendSampleFrameCount(
+ 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);
+}
+
+} // namespace pp
+
diff --git a/ppapi/cpp/audio_config.h b/ppapi/cpp/audio_config.h
new file mode 100644
index 0000000..82d8b97
--- /dev/null
+++ b/ppapi/cpp/audio_config.h
@@ -0,0 +1,61 @@
+// Copyright (c) 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.
+
+#ifndef PPAPI_CPP_AUDIO_CONFIG_H_
+#define PPAPI_CPP_AUDIO_CONFIG_H_
+
+#include "ppapi/c/ppb_audio_config.h"
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/cpp/resource.h"
+
+namespace pp {
+
+class Instance;
+
+// Typical usage:
+//
+// // Create an audio config with a supported frame count.
+// uint32_t sample_frame_count = AudioConfig::RecommendSampleFrameCount(
+// PP_AUDIOSAMPLERATE_44100, 4096);
+// AudioConfig config(PP_AUDIOSAMPLERATE_44100, sample_frame_count);
+// if (config.is_null())
+// return false; // Couldn't configure audio.
+//
+// // Then use the config to create your audio resource.
+// Audio audio(..., config, ...);
+// if (audio.is_null())
+// return false; // Couldn't create audio.
+class AudioConfig : public Resource {
+ public:
+ AudioConfig();
+
+ // Creates an audio config based on the given sample rate and frame count.
+ // If the rate and frame count aren't supported, the resulting resource
+ // will be is_null(). Pass the result of RecommendSampleFrameCount as the
+ // sample frame count.
+ //
+ // See PPB_AudioConfig.CreateStereo16Bit for more.
+ AudioConfig(Instance* instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t sample_frame_count);
+
+ // Returns a supported frame count for use in the constructor.
+ //
+ // See PPB_AudioConfig.RecommendSampleFrameCount.
+ static uint32_t RecommendSampleFrameCount(
+ PP_AudioSampleRate sample_rate,
+ uint32_t requested_sample_frame_count);
+
+ PP_AudioSampleRate sample_rate() const { return sample_rate_; }
+ uint32_t sample_frame_count() { return sample_frame_count_; }
+
+ private:
+ PP_AudioSampleRate sample_rate_;
+ uint32_t sample_frame_count_;
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_AUDIO_CONFIG_H_
+
diff --git a/ppapi/cpp/dev/audio_config_dev.h b/ppapi/cpp/dev/audio_config_dev.h
index 6b0f1f2..64079f0 100644
--- a/ppapi/cpp/dev/audio_config_dev.h
+++ b/ppapi/cpp/dev/audio_config_dev.h
@@ -33,7 +33,7 @@ class AudioConfig_Dev : public Resource {
// Creates an audio config based on the given sample rate and frame count.
// If the rate and frame count aren't supported, the resulting resource
// will be is_null(). Pass the result of RecommendSampleFrameCount as the
- // semple frame count.
+ // sample frame count.
//
// See PPB_AudioConfigDev.CreateStereo16Bit for more.
AudioConfig_Dev(Instance* instance,
diff --git a/ppapi/examples/audio/audio.cc b/ppapi/examples/audio/audio.cc
index a0ba067..3e0fedd 100644
--- a/ppapi/examples/audio/audio.cc
+++ b/ppapi/examples/audio/audio.cc
@@ -5,8 +5,10 @@
#include <cmath>
#include <limits>
-#include "ppapi/cpp/dev/audio_dev.h"
-#include "ppapi/cpp/dev/audio_config_dev.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/audio.h"
+#include "ppapi/cpp/audio_config.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
@@ -16,7 +18,7 @@ const double frequency_l = 400;
const double frequency_r = 1000;
// This sample frequency is guaranteed to work.
-const PP_AudioSampleRate_Dev sample_frequency = PP_AUDIOSAMPLERATE_44100;
+const PP_AudioSampleRate sample_frequency = PP_AUDIOSAMPLERATE_44100;
const uint32_t sample_count = 4096;
uint32_t obtained_sample_count = 0;
@@ -32,11 +34,11 @@ class MyInstance : public pp::Instance {
}
virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
- pp::AudioConfig_Dev config;
- obtained_sample_count = pp::AudioConfig_Dev::RecommendSampleFrameCount(
- sample_count);
- config = pp::AudioConfig_Dev(this, sample_frequency, obtained_sample_count);
- audio_ = pp::Audio_Dev(this, config, SineWaveCallback, this);
+ pp::AudioConfig config;
+ obtained_sample_count = pp::AudioConfig::RecommendSampleFrameCount(
+ sample_frequency, sample_count);
+ config = pp::AudioConfig(this, sample_frequency, obtained_sample_count);
+ audio_ = pp::Audio(this, config, SineWaveCallback, this);
return audio_.StartPlayback();
}
@@ -67,7 +69,7 @@ class MyInstance : public pp::Instance {
}
// Audio resource. Allocated in Init(), freed on destruction.
- pp::Audio_Dev audio_;
+ pp::Audio audio_;
// Current audio wave position, used to prevent sine wave skips
// on buffer boundaries.
diff --git a/ppapi/ppapi.gyp b/ppapi/ppapi.gyp
index 2debb57..d2e9d70 100644
--- a/ppapi/ppapi.gyp
+++ b/ppapi/ppapi.gyp
@@ -51,6 +51,8 @@
'c/pp_time.h',
'c/pp_var.h',
'c/ppb.h',
+ 'c/ppb_audio.h',
+ 'c/ppb_audio_config.h',
'c/ppb_core.h',
'c/ppb_class.h',
'c/ppb_graphics_2d.h',
@@ -114,6 +116,7 @@
'c/dev/ppp_class_deprecated.h',
# Trusted interfaces.
+ 'c/trusted/ppb_audio_trusted.h',
'c/trusted/ppb_image_data_trusted.h',
'c/trusted/ppb_url_loader_trusted.h',
],
@@ -128,6 +131,10 @@
'..',
],
'sources': [
+ 'cpp/audio.cc',
+ 'cpp/audio.h',
+ 'cpp/audio_config.cc',
+ 'cpp/audio_config.h',
'cpp/common.h',
'cpp/completion_callback.h',
'cpp/core.cc',
diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc
index d984222..0ae8e2e 100644
--- a/ppapi/proxy/dispatcher.cc
+++ b/ppapi/proxy/dispatcher.cc
@@ -12,8 +12,6 @@
#include "base/logging.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_sync_channel.h"
-#include "ppapi/c/dev/ppb_audio_config_dev.h"
-#include "ppapi/c/dev/ppb_audio_dev.h"
#include "ppapi/c/dev/ppb_buffer_dev.h"
#include "ppapi/c/dev/ppb_char_set_dev.h"
#include "ppapi/c/dev/ppb_cursor_control_dev.h"
@@ -24,6 +22,8 @@
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_audio.h"
+#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_core.h"
#include "ppapi/c/ppb_graphics_2d.h"
#include "ppapi/c/ppb_image_data.h"
@@ -229,9 +229,9 @@ void Dispatcher::OnMsgDeclareInterfaces(
InterfaceProxy* Dispatcher::CreateProxyForInterface(
const std::string& interface_name,
const void* interface_functions) {
- if (interface_name == PPB_AUDIO_CONFIG_DEV_INTERFACE)
+ if (interface_name == PPB_AUDIO_CONFIG_INTERFACE)
return new PPB_AudioConfig_Proxy(this, interface_functions);
- if (interface_name == PPB_AUDIO_DEV_INTERFACE)
+ if (interface_name == PPB_AUDIO_INTERFACE)
return new PPB_Audio_Proxy(this, interface_functions);
if (interface_name == PPB_BUFFER_DEV_INTERFACE)
return new PPB_Buffer_Proxy(this, interface_functions);
diff --git a/ppapi/proxy/ppapi_messages_internal.h b/ppapi/proxy/ppapi_messages_internal.h
index f593aea..ca34ecf 100644
--- a/ppapi/proxy/ppapi_messages_internal.h
+++ b/ppapi/proxy/ppapi_messages_internal.h
@@ -171,8 +171,9 @@ IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBAudioConfig_Create,
int32_t /* sample_rate */,
uint32_t /* sample_frame_count */,
PP_Resource /* result */)
-IPC_SYNC_MESSAGE_ROUTED1_1(
+IPC_SYNC_MESSAGE_ROUTED2_1(
PpapiHostMsg_PPBAudioConfig_RecommendSampleFrameCount,
+ int32_t /* sample_rate */,
uint32_t /* requested */,
uint32_t /* result */)
diff --git a/ppapi/proxy/ppb_audio_config_proxy.cc b/ppapi/proxy/ppb_audio_config_proxy.cc
index 40abd4f..1675217 100644
--- a/ppapi/proxy/ppb_audio_config_proxy.cc
+++ b/ppapi/proxy/ppb_audio_config_proxy.cc
@@ -4,7 +4,7 @@
#include "ppapi/proxy/ppb_audio_config_proxy.h"
-#include "ppapi/c/dev/ppb_audio_config_dev.h"
+#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/proxy/ppapi_messages.h"
@@ -14,7 +14,7 @@ namespace proxy {
class AudioConfig : public PluginResource {
public:
- AudioConfig(PP_AudioSampleRate_Dev sample_rate, uint32_t sample_frame_count)
+ AudioConfig(PP_AudioSampleRate sample_rate, uint32_t sample_frame_count)
: sample_rate_(sample_rate),
sample_frame_count_(sample_frame_count) {
}
@@ -23,11 +23,11 @@ class AudioConfig : public PluginResource {
// Resource overrides.
virtual AudioConfig* AsAudioConfig() { return this; }
- PP_AudioSampleRate_Dev sample_rate() const { return sample_rate_; }
+ PP_AudioSampleRate sample_rate() const { return sample_rate_; }
uint32_t sample_frame_count() const { return sample_frame_count_; }
private:
- PP_AudioSampleRate_Dev sample_rate_;
+ PP_AudioSampleRate sample_rate_;
uint32_t sample_frame_count_;
DISALLOW_COPY_AND_ASSIGN(AudioConfig);
@@ -36,7 +36,7 @@ class AudioConfig : public PluginResource {
namespace {
PP_Resource CreateStereo16bit(PP_Module module_id,
- PP_AudioSampleRate_Dev sample_rate,
+ PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count) {
PP_Resource result = 0;
PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBAudioConfig_Create(
@@ -53,12 +53,13 @@ PP_Resource CreateStereo16bit(PP_Module module_id,
return result;
}
-uint32_t RecommendSampleFrameCount(uint32_t requested_sample_frame_count) {
+uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate,
+ uint32_t requested_sample_frame_count) {
uint32_t result = 0;
PluginDispatcher::Get()->Send(
new PpapiHostMsg_PPBAudioConfig_RecommendSampleFrameCount(
- INTERFACE_ID_PPB_AUDIO_CONFIG, requested_sample_frame_count,
- &result));
+ INTERFACE_ID_PPB_AUDIO_CONFIG, static_cast<int32_t>(sample_rate),
+ requested_sample_frame_count, &result));
return result;
}
@@ -67,7 +68,7 @@ PP_Bool IsAudioConfig(PP_Resource resource) {
return BoolToPPBool(!!object);
}
-PP_AudioSampleRate_Dev GetSampleRate(PP_Resource config_id) {
+PP_AudioSampleRate GetSampleRate(PP_Resource config_id) {
AudioConfig* object = PluginResource::GetAs<AudioConfig>(config_id);
if (!object)
return PP_AUDIOSAMPLERATE_NONE;
@@ -81,7 +82,7 @@ uint32_t GetSampleFrameCount(PP_Resource config_id) {
return object->sample_frame_count();
}
-const PPB_AudioConfig_Dev audio_config_interface = {
+const PPB_AudioConfig audio_config_interface = {
&CreateStereo16bit,
&RecommendSampleFrameCount,
&IsAudioConfig,
@@ -124,14 +125,17 @@ void PPB_AudioConfig_Proxy::OnMsgCreateStereo16Bit(PP_Module module,
uint32_t sample_frame_count,
PP_Resource* result) {
*result = ppb_audio_config_target()->CreateStereo16Bit(
- module, static_cast<PP_AudioSampleRate_Dev>(sample_rate),
+ module, static_cast<PP_AudioSampleRate>(sample_rate),
sample_frame_count);
}
void PPB_AudioConfig_Proxy::OnMsgRecommendSampleFrameCount(
- uint32_t requested,
+ int32_t sample_rate,
+ uint32_t requested_sample_frame_count,
uint32_t* result) {
- *result = ppb_audio_config_target()->RecommendSampleFrameCount(requested);
+ *result = ppb_audio_config_target()->RecommendSampleFrameCount(
+ static_cast<PP_AudioSampleRate>(sample_rate),
+ requested_sample_frame_count);
}
} // namespace proxy
diff --git a/ppapi/proxy/ppb_audio_config_proxy.h b/ppapi/proxy/ppb_audio_config_proxy.h
index 0236216..459d791 100644
--- a/ppapi/proxy/ppb_audio_config_proxy.h
+++ b/ppapi/proxy/ppb_audio_config_proxy.h
@@ -10,7 +10,7 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/proxy/interface_proxy.h"
-struct PPB_AudioConfig_Dev;
+struct PPB_AudioConfig;
namespace pp {
namespace proxy {
@@ -20,8 +20,8 @@ class PPB_AudioConfig_Proxy : public InterfaceProxy {
PPB_AudioConfig_Proxy(Dispatcher* dispatcher, const void* target_interface);
virtual ~PPB_AudioConfig_Proxy();
- const PPB_AudioConfig_Dev* ppb_audio_config_target() const {
- return static_cast<const PPB_AudioConfig_Dev*>(target_interface());
+ const PPB_AudioConfig* ppb_audio_config_target() const {
+ return static_cast<const PPB_AudioConfig*>(target_interface());
}
// InterfaceProxy implementation.
@@ -35,7 +35,9 @@ class PPB_AudioConfig_Proxy : public InterfaceProxy {
int32_t sample_rate,
uint32_t sample_frame_count,
PP_Resource* result);
- void OnMsgRecommendSampleFrameCount(uint32_t requested, uint32_t* result);
+ void OnMsgRecommendSampleFrameCount(int32_t sample_rate,
+ uint32_t requested,
+ uint32_t* result);
DISALLOW_COPY_AND_ASSIGN(PPB_AudioConfig_Proxy);
};
diff --git a/ppapi/proxy/ppb_audio_proxy.cc b/ppapi/proxy/ppb_audio_proxy.cc
index e23ac4e..aa8ab92 100644
--- a/ppapi/proxy/ppb_audio_proxy.cc
+++ b/ppapi/proxy/ppb_audio_proxy.cc
@@ -5,9 +5,9 @@
#include "ppapi/proxy/ppb_audio_proxy.h"
#include "base/threading/simple_thread.h"
-#include "ppapi/c/dev/ppb_audio_dev.h"
-#include "ppapi/c/dev/ppb_audio_trusted_dev.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_audio.h"
+#include "ppapi/c/trusted/ppb_audio_trusted.h"
#include "ppapi/proxy/interface_id.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_resource.h"
@@ -105,7 +105,7 @@ PP_Bool StopPlayback(PP_Resource audio_id) {
return PP_TRUE;
}
-const PPB_Audio_Dev audio_interface = {
+const PPB_Audio audio_interface = {
&Create,
&IsAudio,
&GetCurrentConfiguration,
@@ -148,9 +148,9 @@ bool PPB_Audio_Proxy::OnMessageReceived(const IPC::Message& msg) {
void PPB_Audio_Proxy::OnMsgCreate(PP_Instance instance_id,
PP_Resource config_id,
PP_Resource* result) {
- const PPB_AudioTrusted_Dev* audio_trusted =
- reinterpret_cast<const PPB_AudioTrusted_Dev*>(
- dispatcher()->GetLocalInterface(PPB_AUDIO_TRUSTED_DEV_INTERFACE));
+ const PPB_AudioTrusted* audio_trusted =
+ reinterpret_cast<const PPB_AudioTrusted*>(
+ dispatcher()->GetLocalInterface(PPB_AUDIO_TRUSTED_INTERFACE));
if (!audio_trusted) {
*result = 0;
return;
@@ -231,9 +231,9 @@ int32_t PPB_Audio_Proxy::GetAudioConnectedHandles(
base::SharedMemoryHandle* foreign_shared_memory_handle,
uint32_t* shared_memory_length) {
// Get the trusted audio interface which will give us the handles.
- const PPB_AudioTrusted_Dev* audio_trusted =
- reinterpret_cast<const PPB_AudioTrusted_Dev*>(
- dispatcher()->GetLocalInterface(PPB_AUDIO_TRUSTED_DEV_INTERFACE));
+ const PPB_AudioTrusted* audio_trusted =
+ reinterpret_cast<const PPB_AudioTrusted*>(
+ dispatcher()->GetLocalInterface(PPB_AUDIO_TRUSTED_INTERFACE));
if (!audio_trusted)
return PP_ERROR_NOINTERFACE;
diff --git a/ppapi/proxy/ppb_audio_proxy.h b/ppapi/proxy/ppb_audio_proxy.h
index a8dc748..c77e3d6 100644
--- a/ppapi/proxy/ppb_audio_proxy.h
+++ b/ppapi/proxy/ppb_audio_proxy.h
@@ -16,7 +16,7 @@
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
-struct PPB_Audio_Dev;
+struct PPB_Audio;
namespace pp {
namespace proxy {
@@ -26,8 +26,8 @@ class PPB_Audio_Proxy : public InterfaceProxy {
PPB_Audio_Proxy(Dispatcher* dispatcher, const void* target_interface);
virtual ~PPB_Audio_Proxy();
- const PPB_Audio_Dev* ppb_audio_target() const {
- return static_cast<const PPB_Audio_Dev*>(target_interface());
+ const PPB_Audio* ppb_audio_target() const {
+ return static_cast<const PPB_Audio*>(target_interface());
}
// InterfaceProxy implementation.
diff --git a/ppapi/shared_impl/audio_impl.h b/ppapi/shared_impl/audio_impl.h
index f4d5681..0b68c08b 100644
--- a/ppapi/shared_impl/audio_impl.h
+++ b/ppapi/shared_impl/audio_impl.h
@@ -9,7 +9,7 @@
#include "base/shared_memory.h"
#include "base/sync_socket.h"
#include "base/threading/simple_thread.h"
-#include "ppapi/c/dev/ppb_audio_dev.h"
+#include "ppapi/c/ppb_audio.h"
namespace pp {
namespace shared_impl {