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

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

Issue 8790004: Rename the shared impl files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged Created 9 years 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/shared_impl/audio_config_impl.h ('k') | ppapi/shared_impl/audio_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ppapi/shared_impl/audio_config_impl.h"
6
7 namespace ppapi {
8
9 AudioConfigImpl::AudioConfigImpl(PP_Instance instance)
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),
18 sample_frame_count_(0) {
19 }
20
21 AudioConfigImpl::~AudioConfigImpl() {
22 }
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
57 bool AudioConfigImpl::Init(PP_AudioSampleRate sample_rate,
58 uint32_t sample_frame_count) {
59 // TODO(brettw): Currently we don't actually check what the hardware
60 // supports, so just allow sample rates of the "guaranteed working" ones.
61 if (sample_rate != PP_AUDIOSAMPLERATE_44100 &&
62 sample_rate != PP_AUDIOSAMPLERATE_48000)
63 return false;
64
65 // TODO(brettw): Currently we don't actually query to get a value from the
66 // hardware, so just validate the range.
67 if (sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT ||
68 sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT)
69 return false;
70
71 sample_rate_ = sample_rate;
72 sample_frame_count_ = sample_frame_count;
73 return true;
74 }
75
76 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/audio_config_impl.h ('k') | ppapi/shared_impl/audio_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698