Commit b9a59849 authored by nfullagar@google.com's avatar nfullagar@google.com

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
parent 97d2f1d2
/* 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_ */
/* 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_ */
/* 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_ */
// 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
// 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_
// 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
// 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_
......@@ -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,
......
......@@ -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.
......
......@@ -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',
......
......@@ -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);
......
......@@ -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 */)
......
......@@ -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
......
......@@ -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);
};
......
......@@ -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;
......
......@@ -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.
......
......@@ -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 {
......
......@@ -211,11 +211,11 @@ const PPB_Testing_Dev testing_interface = {
const void* GetInterface(const char* name) {
// Please keep alphabetized by interface macro name with "special" stuff at
// the bottom.
if (strcmp(name, PPB_AUDIO_CONFIG_DEV_INTERFACE) == 0)
if (strcmp(name, PPB_AUDIO_CONFIG_INTERFACE) == 0)
return PPB_AudioConfig_Impl::GetInterface();
if (strcmp(name, PPB_AUDIO_DEV_INTERFACE) == 0)
if (strcmp(name, PPB_AUDIO_INTERFACE) == 0)
return PPB_Audio_Impl::GetInterface();
if (strcmp(name, PPB_AUDIO_TRUSTED_DEV_INTERFACE) == 0)
if (strcmp(name, PPB_AUDIO_TRUSTED_INTERFACE) == 0)
return PPB_Audio_Impl::GetTrustedInterface();
if (strcmp(name, PPB_BUFFER_DEV_INTERFACE) == 0)
return PPB_Buffer_Impl::GetInterface();
......
......@@ -5,9 +5,10 @@
#include "webkit/plugins/ppapi/ppb_audio_impl.h"
#include "base/logging.h"
#include "ppapi/c/dev/ppb_audio_dev.h"
#include "ppapi/c/dev/ppb_audio_trusted_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/ppb_audio.h"
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/trusted/ppb_audio_trusted.h"
#include "webkit/plugins/ppapi/common.h"
namespace webkit {
......@@ -17,10 +18,11 @@ namespace {
// PPB_AudioConfig -------------------------------------------------------------
uint32_t RecommendSampleFrameCount(uint32_t requested_sample_frame_count);
uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate,
uint32_t requested_sample_frame_count);
PP_Resource CreateStereo16bit(PP_Instance instance_id,
PP_AudioSampleRate_Dev sample_rate,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
if (!instance)
......@@ -34,7 +36,8 @@ PP_Resource CreateStereo16bit(PP_Instance instance_id,
// TODO(brettw): Currently we don't actually query to get a value from the
// hardware, so just validate the range.
if (RecommendSampleFrameCount(sample_frame_count) != sample_frame_count)
if (RecommendSampleFrameCount(sample_rate, sample_frame_count) !=
sample_frame_count)
return 0;
scoped_refptr<PPB_AudioConfig_Impl> config(
......@@ -43,7 +46,8 @@ PP_Resource CreateStereo16bit(PP_Instance instance_id,
return config->GetReference();
}
uint32_t RecommendSampleFrameCount(uint32_t requested_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)
......@@ -59,7 +63,7 @@ PP_Bool IsAudioConfig(PP_Resource resource) {
return BoolToPPBool(!!config);
}
PP_AudioSampleRate_Dev GetSampleRate(PP_Resource config_id) {
PP_AudioSampleRate GetSampleRate(PP_Resource config_id) {
scoped_refptr<PPB_AudioConfig_Impl> config =
Resource::GetAs<PPB_AudioConfig_Impl>(config_id);
return config ? config->sample_rate() : PP_AUDIOSAMPLERATE_NONE;
......@@ -71,7 +75,7 @@ uint32_t GetSampleFrameCount(PP_Resource config_id) {
return config ? config->sample_frame_count() : 0;
}
const PPB_AudioConfig_Dev ppb_audioconfig = {
const PPB_AudioConfig ppb_audioconfig = {
&CreateStereo16bit,
&RecommendSampleFrameCount,
&IsAudioConfig,
......@@ -120,7 +124,7 @@ PP_Bool StopPlayback(PP_Resource audio_id) {
return audio ? BoolToPPBool(audio->StopPlayback()) : PP_FALSE;
}
const PPB_Audio_Dev ppb_audio = {
const PPB_Audio ppb_audio = {
&Create,
&IsAudio,
&GetCurrentConfig,
......@@ -173,7 +177,7 @@ int32_t GetSharedMemory(PP_Resource audio_id,
return PP_ERROR_BADRESOURCE;
}
const PPB_AudioTrusted_Dev ppb_audiotrusted = {
const PPB_AudioTrusted ppb_audiotrusted = {
&CreateTrusted,
&Open,
&GetSyncSocket,
......@@ -186,14 +190,14 @@ const PPB_AudioTrusted_Dev ppb_audiotrusted = {
PPB_AudioConfig_Impl::PPB_AudioConfig_Impl(
PluginModule* module,
PP_AudioSampleRate_Dev sample_rate,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count)
: Resource(module),
sample_rate_(sample_rate),
sample_frame_count_(sample_frame_count) {
}
const PPB_AudioConfig_Dev* PPB_AudioConfig_Impl::GetInterface() {
const PPB_AudioConfig* PPB_AudioConfig_Impl::GetInterface() {
return &ppb_audioconfig;
}
......@@ -234,11 +238,11 @@ PPB_Audio_Impl::~PPB_Audio_Impl() {
}
}
const PPB_Audio_Dev* PPB_Audio_Impl::GetInterface() {
const PPB_Audio* PPB_Audio_Impl::GetInterface() {
return &ppb_audio;
}
const PPB_AudioTrusted_Dev* PPB_Audio_Impl::GetTrustedInterface() {
const PPB_AudioTrusted* PPB_Audio_Impl::GetTrustedInterface() {
return &ppb_audiotrusted;
}
......
......@@ -9,10 +9,10 @@
#include "base/ref_counted.h"
#include "base/shared_memory.h"
#include "base/sync_socket.h"
#include "ppapi/c/dev/ppb_audio_dev.h"
#include "ppapi/c/dev/ppb_audio_config_dev.h"
#include "ppapi/c/dev/ppb_audio_trusted_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/ppb_audio.h"
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/trusted/ppb_audio_trusted.h"
#include "ppapi/shared_impl/audio_impl.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
......@@ -28,19 +28,19 @@ class PluginModule;
class PPB_AudioConfig_Impl : public Resource {
public:
PPB_AudioConfig_Impl(PluginModule* module,
PP_AudioSampleRate_Dev sample_rate,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count);
size_t BufferSize();
static const PPB_AudioConfig_Dev* GetInterface();
static const PPB_AudioConfig* GetInterface();
PP_AudioSampleRate_Dev sample_rate() { return sample_rate_; }
PP_AudioSampleRate sample_rate() { return sample_rate_; }
uint32_t sample_frame_count() { return sample_frame_count_; }
private:
// Resource override.
virtual PPB_AudioConfig_Impl* AsPPB_AudioConfig_Impl();
PP_AudioSampleRate_Dev sample_rate_;
PP_AudioSampleRate sample_rate_;
uint32_t sample_frame_count_;
};
......@@ -53,8 +53,8 @@ class PPB_Audio_Impl : public Resource,
explicit PPB_Audio_Impl(PluginModule* module, PP_Instance instance_id);
virtual ~PPB_Audio_Impl();
static const PPB_Audio_Dev* GetInterface();
static const PPB_AudioTrusted_Dev* GetTrustedInterface();
static const PPB_Audio* GetInterface();
static const PPB_AudioTrusted* GetTrustedInterface();
PP_Instance pp_instance() {
return pp_instance_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment