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

Side by Side Diff: ppapi/cpp/audio.cc

Issue 22320004: Add a new parameter |latency| to PPB_Audio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/audio.h" 5 #include "ppapi/cpp/audio.h"
6 6
7 #include "ppapi/cpp/instance_handle.h" 7 #include "ppapi/cpp/instance_handle.h"
8 #include "ppapi/cpp/module_impl.h" 8 #include "ppapi/cpp/module_impl.h"
9 9
10 namespace pp { 10 namespace pp {
11 11
12 namespace { 12 namespace {
13 13
14 template <> const char* interface_name<PPB_Audio_1_0>() { 14 template <> const char* interface_name<PPB_Audio_1_0>() {
15 return PPB_AUDIO_INTERFACE_1_0; 15 return PPB_AUDIO_INTERFACE_1_0;
16 } 16 }
17 17
18 template <> const char* interface_name<PPB_Audio_1_1>() {
19 return PPB_AUDIO_INTERFACE_1_1;
20 }
21
18 } // namespace 22 } // namespace
19 23
20 Audio::Audio(const InstanceHandle& instance, 24 Audio::Audio(const InstanceHandle& instance,
21 const AudioConfig& config, 25 const AudioConfig& config,
22 PPB_Audio_Callback callback, 26 PPB_Audio_Callback callback,
23 void* user_data) 27 void* user_data)
24 : config_(config) { 28 : config_(config) {
29 if (has_interface<PPB_Audio_1_1>()) {
30 PassRefFromConstructor(get_interface<PPB_Audio_1_1>()->Create(
31 instance.pp_instance(), config.pp_resource(), callback, user_data));
32 }
33 }
34
35 Audio::Audio(const InstanceHandle& instance,
36 const AudioConfig& config,
37 PPB_Audio_Callback_1_0 callback,
38 void* user_data)
39 : config_(config) {
25 if (has_interface<PPB_Audio_1_0>()) { 40 if (has_interface<PPB_Audio_1_0>()) {
26 PassRefFromConstructor(get_interface<PPB_Audio_1_0>()->Create( 41 PassRefFromConstructor(get_interface<PPB_Audio_1_0>()->Create(
27 instance.pp_instance(), config.pp_resource(), callback, user_data)); 42 instance.pp_instance(), config.pp_resource(), callback, user_data));
28 } 43 }
dmichael (off chromium) 2013/08/06 19:43:25 nit? : For older code that runs on newer Chrome, t
yzshen1 2013/08/07 20:51:06 Good point. Thanks for catching this! I added a f
dmichael (off chromium) 2013/08/07 21:11:38 No, the way you have it seems fine to me.
29 } 44 }
30 45
31 bool Audio::StartPlayback() { 46 bool Audio::StartPlayback() {
32 return has_interface<PPB_Audio_1_0>() && 47 if (has_interface<PPB_Audio_1_1>()) {
33 get_interface<PPB_Audio_1_0>()->StartPlayback(pp_resource()); 48 return PP_ToBool(get_interface<PPB_Audio_1_1>()->StartPlayback(
49 pp_resource()));
50 }
51 if (has_interface<PPB_Audio_1_0>()) {
52 return PP_ToBool(get_interface<PPB_Audio_1_0>()->StartPlayback(
53 pp_resource()));
54 }
55 return false;
34 } 56 }
35 57
36 bool Audio::StopPlayback() { 58 bool Audio::StopPlayback() {
37 return has_interface<PPB_Audio_1_0>() && 59 if (has_interface<PPB_Audio_1_1>()) {
38 get_interface<PPB_Audio_1_0>()->StopPlayback(pp_resource()); 60 return PP_ToBool(get_interface<PPB_Audio_1_1>()->StopPlayback(
61 pp_resource()));
62 }
63 if (has_interface<PPB_Audio_1_0>()) {
64 return PP_ToBool(get_interface<PPB_Audio_1_0>()->StopPlayback(
65 pp_resource()));
66 }
67 return false;
39 } 68 }
40 69
41 } // namespace pp 70 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698