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

Side by Side Diff: ppapi/proxy/ppb_audio_config_proxy.cc

Issue 6334016: Refactor PPAPI proxy resource handling to maintain which host they came from,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « ppapi/proxy/ppb_audio_config_proxy.h ('k') | ppapi/proxy/ppb_audio_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/proxy/ppb_audio_config_proxy.h" 5 #include "ppapi/proxy/ppb_audio_config_proxy.h"
6 6
7 #include "ppapi/c/ppb_audio_config.h" 7 #include "ppapi/c/ppb_audio_config.h"
8 #include "ppapi/proxy/plugin_dispatcher.h" 8 #include "ppapi/proxy/plugin_dispatcher.h"
9 #include "ppapi/proxy/plugin_resource.h" 9 #include "ppapi/proxy/plugin_resource.h"
10 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
11 11
12 namespace pp { 12 namespace pp {
13 namespace proxy { 13 namespace proxy {
14 14
15 class AudioConfig : public PluginResource { 15 class AudioConfig : public PluginResource {
16 public: 16 public:
17 AudioConfig(PP_Instance instance, 17 AudioConfig(const HostResource& resource,
18 PP_AudioSampleRate sample_rate, 18 PP_AudioSampleRate sample_rate,
19 uint32_t sample_frame_count) 19 uint32_t sample_frame_count)
20 : PluginResource(instance), 20 : PluginResource(resource),
21 sample_rate_(sample_rate), 21 sample_rate_(sample_rate),
22 sample_frame_count_(sample_frame_count) { 22 sample_frame_count_(sample_frame_count) {
23 } 23 }
24 virtual ~AudioConfig() {} 24 virtual ~AudioConfig() {}
25 25
26 // Resource overrides. 26 // Resource overrides.
27 virtual AudioConfig* AsAudioConfig() { return this; } 27 virtual AudioConfig* AsAudioConfig() { return this; }
28 28
29 PP_AudioSampleRate sample_rate() const { return sample_rate_; } 29 PP_AudioSampleRate sample_rate() const { return sample_rate_; }
30 uint32_t sample_frame_count() const { return sample_frame_count_; } 30 uint32_t sample_frame_count() const { return sample_frame_count_; }
31 31
32 private: 32 private:
33 PP_AudioSampleRate sample_rate_; 33 PP_AudioSampleRate sample_rate_;
34 uint32_t sample_frame_count_; 34 uint32_t sample_frame_count_;
35 35
36 DISALLOW_COPY_AND_ASSIGN(AudioConfig); 36 DISALLOW_COPY_AND_ASSIGN(AudioConfig);
37 }; 37 };
38 38
39 namespace { 39 namespace {
40 40
41 PP_Resource CreateStereo16bit(PP_Instance instance, 41 PP_Resource CreateStereo16bit(PP_Instance instance,
42 PP_AudioSampleRate sample_rate, 42 PP_AudioSampleRate sample_rate,
43 uint32_t sample_frame_count) { 43 uint32_t sample_frame_count) {
44 PP_Resource result = 0; 44 HostResource resource;
45 PluginDispatcher::GetForInstance(instance)->Send( 45 PluginDispatcher::GetForInstance(instance)->Send(
46 new PpapiHostMsg_PPBAudioConfig_Create( 46 new PpapiHostMsg_PPBAudioConfig_Create(
47 INTERFACE_ID_PPB_AUDIO_CONFIG, instance, 47 INTERFACE_ID_PPB_AUDIO_CONFIG, instance,
48 static_cast<int32_t>(sample_rate), sample_frame_count, 48 static_cast<int32_t>(sample_rate), sample_frame_count,
49 &result)); 49 &resource));
50 if (!result) 50 if (!resource.is_null())
51 return 0; 51 return 0;
52 52
53 linked_ptr<AudioConfig> object( 53 linked_ptr<AudioConfig> object(
54 new AudioConfig(instance, sample_rate, sample_frame_count)); 54 new AudioConfig(resource, sample_rate, sample_frame_count));
55 PluginResourceTracker::GetInstance()->AddResource(result, object); 55 return PluginResourceTracker::GetInstance()->AddResource(object);
56 return result;
57 } 56 }
58 57
59 uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate, 58 uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate,
60 uint32_t requested_sample_frame_count) { 59 uint32_t requested_sample_frame_count) {
61 // TODO(brettw) Currently we don't actually query to get a value from the 60 // TODO(brettw) Currently we don't actually query to get a value from the
62 // hardware, so we always return the input for in-range values. 61 // hardware, so we always return the input for in-range values.
63 // 62 //
64 // Danger: this code is duplicated in the audio config implementation. 63 // Danger: this code is duplicated in the audio config implementation.
65 if (requested_sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT) 64 if (requested_sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT)
66 return PP_AUDIOMINSAMPLEFRAMECOUNT; 65 return PP_AUDIOMINSAMPLEFRAMECOUNT;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioConfig_RecommendSampleFrameCount, 121 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudioConfig_RecommendSampleFrameCount,
123 OnMsgRecommendSampleFrameCount) 122 OnMsgRecommendSampleFrameCount)
124 IPC_MESSAGE_UNHANDLED(handled = false) 123 IPC_MESSAGE_UNHANDLED(handled = false)
125 IPC_END_MESSAGE_MAP() 124 IPC_END_MESSAGE_MAP()
126 return handled; 125 return handled;
127 } 126 }
128 127
129 void PPB_AudioConfig_Proxy::OnMsgCreateStereo16Bit(PP_Instance instance, 128 void PPB_AudioConfig_Proxy::OnMsgCreateStereo16Bit(PP_Instance instance,
130 int32_t sample_rate, 129 int32_t sample_rate,
131 uint32_t sample_frame_count, 130 uint32_t sample_frame_count,
132 PP_Resource* result) { 131 HostResource* result) {
133 *result = ppb_audio_config_target()->CreateStereo16Bit( 132 result->SetHostResource(instance,
134 instance, static_cast<PP_AudioSampleRate>(sample_rate), 133 ppb_audio_config_target()->CreateStereo16Bit(
135 sample_frame_count); 134 instance, static_cast<PP_AudioSampleRate>(sample_rate),
135 sample_frame_count));
136 } 136 }
137 137
138 void PPB_AudioConfig_Proxy::OnMsgRecommendSampleFrameCount( 138 void PPB_AudioConfig_Proxy::OnMsgRecommendSampleFrameCount(
139 int32_t sample_rate, 139 int32_t sample_rate,
140 uint32_t requested_sample_frame_count, 140 uint32_t requested_sample_frame_count,
141 uint32_t* result) { 141 uint32_t* result) {
142 *result = ppb_audio_config_target()->RecommendSampleFrameCount( 142 *result = ppb_audio_config_target()->RecommendSampleFrameCount(
143 static_cast<PP_AudioSampleRate>(sample_rate), 143 static_cast<PP_AudioSampleRate>(sample_rate),
144 requested_sample_frame_count); 144 requested_sample_frame_count);
145 } 145 }
146 146
147 } // namespace proxy 147 } // namespace proxy
148 } // namespace pp 148 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_audio_config_proxy.h ('k') | ppapi/proxy/ppb_audio_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698