summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-07 07:48:48 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-07 07:48:48 +0000
commiteed24562b1e6a431fc726195e1114eed01b1694f (patch)
tree2ae570b6f55f7043e62bc25dca335d03ba75bb52 /ppapi/thunk
parente974ad29d8f31b1f86bb551dc99ad4e5e62b002c (diff)
downloadchromium_src-eed24562b1e6a431fc726195e1114eed01b1694f.zip
chromium_src-eed24562b1e6a431fc726195e1114eed01b1694f.tar.gz
chromium_src-eed24562b1e6a431fc726195e1114eed01b1694f.tar.bz2
PPB_AudioInput_Dev: support multiple audio input devices - Part 1.
- This CL implements PPB_AudioInput_Dev v0.2 and extends examples/audio_input. - This CL doesn't actually open devices other than the default one. That will be in a separate CL. BUG=None TEST=examples/audio_input Review URL: http://codereview.chromium.org/9557007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r--ppapi/thunk/interfaces_ppb_public_dev.h2
-rw-r--r--ppapi/thunk/ppb_audio_input_api.h20
-rw-r--r--ppapi/thunk/ppb_audio_input_thunk.cc91
-rw-r--r--ppapi/thunk/ppb_audio_input_trusted_thunk.cc4
-rw-r--r--ppapi/thunk/resource_creation_api.h4
5 files changed, 102 insertions, 19 deletions
diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h
index 5a7ca47..037dce8 100644
--- a/ppapi/thunk/interfaces_ppb_public_dev.h
+++ b/ppapi/thunk/interfaces_ppb_public_dev.h
@@ -24,6 +24,8 @@ UNPROXIED_API(PPB_Widget)
PROXIED_IFACE(PPB_AudioInput, PPB_AUDIO_INPUT_DEV_INTERFACE_0_1,
PPB_AudioInput_Dev_0_1)
+PROXIED_IFACE(PPB_AudioInput, PPB_AUDIO_INPUT_DEV_INTERFACE_0_2,
+ PPB_AudioInput_Dev_0_2)
PROXIED_IFACE(NoAPIName, PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_1,
PPB_IMEInputEvent_Dev_0_1)
PROXIED_IFACE(PPB_Buffer, PPB_BUFFER_DEV_INTERFACE_0_4, PPB_Buffer_Dev_0_4)
diff --git a/ppapi/thunk/ppb_audio_input_api.h b/ppapi/thunk/ppb_audio_input_api.h
index 41cb4ef..68c8b94 100644
--- a/ppapi/thunk/ppb_audio_input_api.h
+++ b/ppapi/thunk/ppb_audio_input_api.h
@@ -1,30 +1,46 @@
-// 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.
#ifndef PPAPI_THUNK_AUDIO_INPUT_API_H_
#define PPAPI_THUNK_AUDIO_INPUT_API_H_
+#include <string>
+#include <vector>
+
#include "ppapi/c/dev/ppb_audio_input_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/thunk/ppapi_thunk_export.h"
namespace ppapi {
+
+struct DeviceRefData;
+
namespace thunk {
class PPAPI_THUNK_EXPORT PPB_AudioInput_API {
public:
virtual ~PPB_AudioInput_API() {}
+ virtual int32_t EnumerateDevices(PP_Resource* devices,
+ PP_CompletionCallback callback) = 0;
+ virtual int32_t Open(const std::string& device_id,
+ PP_Resource config,
+ PPB_AudioInput_Callback audio_input_callback,
+ void* user_data,
+ PP_CompletionCallback callback) = 0;
virtual PP_Resource GetCurrentConfig() = 0;
virtual PP_Bool StartCapture() = 0;
virtual PP_Bool StopCapture() = 0;
+ virtual void Close() = 0;
// Trusted API.
- virtual int32_t OpenTrusted(PP_Resource config_id,
+ virtual int32_t OpenTrusted(const std::string& device_id,
+ PP_Resource config,
PP_CompletionCallback create_callback) = 0;
virtual int32_t GetSyncSocket(int* sync_socket) = 0;
virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) = 0;
+ virtual const std::vector<DeviceRefData>& GetDeviceRefData() const = 0;
};
} // namespace thunk
diff --git a/ppapi/thunk/ppb_audio_input_thunk.cc b/ppapi/thunk/ppb_audio_input_thunk.cc
index f2a65c8..9102dc5 100644
--- a/ppapi/thunk/ppb_audio_input_thunk.cc
+++ b/ppapi/thunk/ppb_audio_input_thunk.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/ppb_device_ref_shared.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_device_ref_api.h"
#include "ppapi/thunk/ppb_audio_input_api.h"
#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
@@ -15,16 +17,24 @@ namespace {
typedef EnterResource<PPB_AudioInput_API> EnterAudioInput;
-PP_Resource Create(PP_Instance instance,
- PP_Resource config_id,
- PPB_AudioInput_Callback callback,
- void* user_data) {
- EnterFunction<ResourceCreationAPI> enter(instance, true);
+PP_Resource Create0_1(PP_Instance instance,
+ PP_Resource config,
+ PPB_AudioInput_Callback audio_input_callback,
+ void* user_data) {
+ EnterResourceCreation enter(instance);
if (enter.failed())
return 0;
- return enter.functions()->CreateAudioInput(instance, config_id,
- callback, user_data);
+ return enter.functions()->CreateAudioInput0_1(
+ instance, config, audio_input_callback, user_data);
+}
+
+PP_Resource Create0_2(PP_Instance instance) {
+ EnterResourceCreation enter(instance);
+ if (enter.failed())
+ return 0;
+
+ return enter.functions()->CreateAudioInput(instance);
}
PP_Bool IsAudioInput(PP_Resource resource) {
@@ -32,8 +42,42 @@ PP_Bool IsAudioInput(PP_Resource resource) {
return PP_FromBool(enter.succeeded());
}
-PP_Resource GetCurrentConfiguration(PP_Resource audio_id) {
- EnterAudioInput enter(audio_id, true);
+int32_t EnumerateDevices(PP_Resource audio_input,
+ PP_Resource* devices,
+ PP_CompletionCallback callback) {
+ EnterAudioInput enter(audio_input, callback, true);
+ if (enter.failed())
+ return enter.retval();
+
+ return enter.SetResult(enter.object()->EnumerateDevices(devices, callback));
+}
+
+int32_t Open(PP_Resource audio_input,
+ PP_Resource device_ref,
+ PP_Resource config,
+ PPB_AudioInput_Callback audio_input_callback,
+ void* user_data,
+ PP_CompletionCallback callback) {
+ EnterAudioInput enter(audio_input, callback, true);
+ if (enter.failed())
+ return enter.retval();
+
+ std::string device_id;
+ // |device_id| remains empty if |device_ref| is 0, which means the default
+ // device.
+ if (device_ref != 0) {
+ EnterResourceNoLock<PPB_DeviceRef_API> enter_device_ref(device_ref, true);
+ if (enter_device_ref.failed())
+ return enter.SetResult(PP_ERROR_BADRESOURCE);
+ device_id = enter_device_ref.object()->GetDeviceRefData().id;
+ }
+
+ return enter.SetResult(enter.object()->Open(
+ device_id, config, audio_input_callback, user_data, callback));
+}
+
+PP_Resource GetCurrentConfig(PP_Resource audio_input) {
+ EnterAudioInput enter(audio_input, true);
if (enter.failed())
return 0;
return enter.object()->GetCurrentConfig();
@@ -55,18 +99,39 @@ PP_Bool StopCapture(PP_Resource audio_input) {
return enter.object()->StopCapture();
}
-const PPB_AudioInput_Dev g_ppb_audioinput_thunk = {
- &Create,
+void Close(PP_Resource audio_input) {
+ EnterAudioInput enter(audio_input, true);
+ if (enter.succeeded())
+ enter.object()->Close();
+}
+
+const PPB_AudioInput_Dev_0_1 g_ppb_audioinput_0_1_thunk = {
+ &Create0_1,
&IsAudioInput,
- &GetCurrentConfiguration,
+ &GetCurrentConfig,
&StartCapture,
&StopCapture
};
+const PPB_AudioInput_Dev_0_2 g_ppb_audioinput_0_2_thunk = {
+ &Create0_2,
+ &IsAudioInput,
+ &EnumerateDevices,
+ &Open,
+ &GetCurrentConfig,
+ &StartCapture,
+ &StopCapture,
+ &Close
+};
+
} // namespace
const PPB_AudioInput_Dev_0_1* GetPPB_AudioInput_Dev_0_1_Thunk() {
- return &g_ppb_audioinput_thunk;
+ return &g_ppb_audioinput_0_1_thunk;
+}
+
+const PPB_AudioInput_Dev_0_2* GetPPB_AudioInput_Dev_0_2_Thunk() {
+ return &g_ppb_audioinput_0_2_thunk;
}
} // namespace thunk
diff --git a/ppapi/thunk/ppb_audio_input_trusted_thunk.cc b/ppapi/thunk/ppb_audio_input_trusted_thunk.cc
index ac9f0bb..b17e1bd 100644
--- a/ppapi/thunk/ppb_audio_input_trusted_thunk.cc
+++ b/ppapi/thunk/ppb_audio_input_trusted_thunk.cc
@@ -20,7 +20,7 @@ PP_Resource Create(PP_Instance instance_id) {
EnterFunction<ResourceCreationAPI> enter(instance_id, true);
if (enter.failed())
return 0;
- return enter.functions()->CreateAudioInputTrusted(instance_id);
+ return enter.functions()->CreateAudioInput(instance_id);
}
int32_t Open(PP_Resource audio_id,
@@ -29,7 +29,7 @@ int32_t Open(PP_Resource audio_id,
EnterAudioInput enter(audio_id, callback, true);
if (enter.failed())
return enter.retval();
- return enter.SetResult(enter.object()->OpenTrusted(config_id, callback));
+ return enter.SetResult(enter.object()->OpenTrusted("", config_id, callback));
}
int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) {
diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h
index 8b9360f5..d78f226 100644
--- a/ppapi/thunk/resource_creation_api.h
+++ b/ppapi/thunk/resource_creation_api.h
@@ -50,12 +50,12 @@ class ResourceCreationAPI {
virtual PP_Resource CreateAudioConfig(PP_Instance instance,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count) = 0;
- virtual PP_Resource CreateAudioInput(
+ virtual PP_Resource CreateAudioInput0_1(
PP_Instance instance,
PP_Resource config_id,
PPB_AudioInput_Callback audio_input_callback,
void* user_data) = 0;
- virtual PP_Resource CreateAudioInputTrusted(PP_Instance instance) = 0;
+ virtual PP_Resource CreateAudioInput(PP_Instance instance) = 0;
virtual PP_Resource CreateBroker(PP_Instance instance) = 0;
virtual PP_Resource CreateBrowserFont(
PP_Instance instance,