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

Side by Side Diff: ppapi/shared_impl/audio_config_impl.cc

Issue 7621070: Merge the plugin and impl side of the audio config and input event resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compile issues Created 9 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) 2011 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/shared_impl/audio_config_impl.h" 5 #include "ppapi/shared_impl/audio_config_impl.h"
6 6
7 namespace ppapi { 7 namespace ppapi {
8 8
9 AudioConfigImpl::AudioConfigImpl() 9 AudioConfigImpl::AudioConfigImpl(PP_Instance instance)
10 : sample_rate_(PP_AUDIOSAMPLERATE_NONE), 10 : Resource(instance),
11 sample_rate_(PP_AUDIOSAMPLERATE_NONE),
12 sample_frame_count_(0) {
13 }
14
15 AudioConfigImpl::AudioConfigImpl(const HostResource& host_resource)
16 : Resource(host_resource),
17 sample_rate_(PP_AUDIOSAMPLERATE_NONE),
11 sample_frame_count_(0) { 18 sample_frame_count_(0) {
12 } 19 }
13 20
14 AudioConfigImpl::~AudioConfigImpl() { 21 AudioConfigImpl::~AudioConfigImpl() {
15 } 22 }
16 23
24 // static
25 PP_Resource AudioConfigImpl::CreateAsImpl(PP_Instance instance,
26 PP_AudioSampleRate sample_rate,
27 uint32_t sample_frame_count) {
28 scoped_refptr<AudioConfigImpl> object(new AudioConfigImpl(instance));
29 if (!object->Init(sample_rate, sample_frame_count))
30 return 0;
31 return object->GetReference();
32 }
33
34 // static
35 PP_Resource AudioConfigImpl::CreateAsProxy(PP_Instance instance,
36 PP_AudioSampleRate sample_rate,
37 uint32_t sample_frame_count) {
38 scoped_refptr<AudioConfigImpl> object(new AudioConfigImpl(
39 HostResource::MakeInstanceOnly(instance)));
40 if (!object->Init(sample_rate, sample_frame_count))
41 return 0;
42 return object->GetReference();
43 }
44
45 thunk::PPB_AudioConfig_API* AudioConfigImpl::AsPPB_AudioConfig_API() {
46 return this;
47 }
48
49 PP_AudioSampleRate AudioConfigImpl::GetSampleRate() {
50 return sample_rate_;
51 }
52
53 uint32_t AudioConfigImpl::GetSampleFrameCount() {
54 return sample_frame_count_;
55 }
56
17 bool AudioConfigImpl::Init(PP_AudioSampleRate sample_rate, 57 bool AudioConfigImpl::Init(PP_AudioSampleRate sample_rate,
18 uint32_t sample_frame_count) { 58 uint32_t sample_frame_count) {
19 // TODO(brettw): Currently we don't actually check what the hardware 59 // TODO(brettw): Currently we don't actually check what the hardware
20 // supports, so just allow sample rates of the "guaranteed working" ones. 60 // supports, so just allow sample rates of the "guaranteed working" ones.
21 if (sample_rate != PP_AUDIOSAMPLERATE_44100 && 61 if (sample_rate != PP_AUDIOSAMPLERATE_44100 &&
22 sample_rate != PP_AUDIOSAMPLERATE_48000) 62 sample_rate != PP_AUDIOSAMPLERATE_48000)
23 return false; 63 return false;
24 64
25 // TODO(brettw): Currently we don't actually query to get a value from the 65 // TODO(brettw): Currently we don't actually query to get a value from the
26 // hardware, so just validate the range. 66 // hardware, so just validate the range.
27 if (sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT || 67 if (sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT ||
28 sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT) 68 sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT)
29 return false; 69 return false;
30 70
31 sample_rate_ = sample_rate; 71 sample_rate_ = sample_rate;
32 sample_frame_count_ = sample_frame_count; 72 sample_frame_count_ = sample_frame_count;
33 return true; 73 return true;
34 } 74 }
35 75
36 PP_AudioSampleRate AudioConfigImpl::GetSampleRate() {
37 return sample_rate_;
38 }
39
40 uint32_t AudioConfigImpl::GetSampleFrameCount() {
41 return sample_frame_count_;
42 }
43
44 } // namespace ppapi 76 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698