summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/dev/audio_config_dev.cc
blob: c8f8f3a311a41b2fc3c4397283a460b32170e44b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2010 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.

#include "ppapi/cpp/dev/audio_config_dev.h"

#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"

namespace pp {

namespace {

template <> const char* interface_name<PPB_AudioConfig_Dev>() {
  return PPB_AUDIO_CONFIG_DEV_INTERFACE;
}

}  // namespace

AudioConfig_Dev::AudioConfig_Dev()
    : sample_rate_(PP_AUDIOSAMPLERATE_NONE),
      sample_frame_count_(0) {
}

AudioConfig_Dev::AudioConfig_Dev(PP_AudioSampleRate_Dev sample_rate,
                                 uint32_t sample_frame_count)
    : sample_rate_(sample_rate),
      sample_frame_count_(sample_frame_count) {
  if (has_interface<PPB_AudioConfig_Dev>()) {
    PassRefFromConstructor(
        get_interface<PPB_AudioConfig_Dev>()->CreateStereo16Bit(
        Module::Get()->pp_module(), sample_rate, sample_frame_count));
  }
}

// static
uint32_t AudioConfig_Dev::RecommendSampleFrameCount(
    uint32_t requested_sample_frame_count) {
  if (!has_interface<PPB_AudioConfig_Dev>())
    return 0;
  return get_interface<PPB_AudioConfig_Dev>()->
      RecommendSampleFrameCount(requested_sample_frame_count);
}

}  // namespace pp