OLD | NEW |
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 "remoting/client/plugin/pepper_audio_player.h" | 5 #include "remoting/client/plugin/pepper_audio_player.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 | 11 |
12 // The frame size we will request from the browser. | 12 // The frame size we will request from the browser. |
13 const int kFrameSizeMs = 40; | 13 const int kFrameSizeMs = 40; |
14 | 14 |
15 namespace remoting { | 15 namespace remoting { |
16 | 16 |
17 PepperAudioPlayer::PepperAudioPlayer(pp::Instance* instance) | 17 PepperAudioPlayer::PepperAudioPlayer(pp::Instance* instance) |
18 : instance_(instance), | 18 : instance_(instance), samples_per_frame_(0), weak_factory_(this) {} |
19 samples_per_frame_(0) { | |
20 } | |
21 | 19 |
22 PepperAudioPlayer::~PepperAudioPlayer() { | 20 PepperAudioPlayer::~PepperAudioPlayer() { |
23 } | 21 } |
24 | 22 |
25 uint32_t PepperAudioPlayer::GetSamplesPerFrame() { | 23 uint32_t PepperAudioPlayer::GetSamplesPerFrame() { |
26 return samples_per_frame_; | 24 return samples_per_frame_; |
27 } | 25 } |
28 | 26 |
| 27 base::WeakPtr<PepperAudioPlayer> PepperAudioPlayer::GetWeakPtr() { |
| 28 return weak_factory_.GetWeakPtr(); |
| 29 } |
| 30 |
29 bool PepperAudioPlayer::ResetAudioPlayer( | 31 bool PepperAudioPlayer::ResetAudioPlayer( |
30 AudioPacket::SamplingRate sampling_rate) { | 32 AudioPacket::SamplingRate sampling_rate) { |
31 PP_AudioSampleRate pp_sampling_rate = PP_AUDIOSAMPLERATE_NONE; | 33 PP_AudioSampleRate pp_sampling_rate = PP_AUDIOSAMPLERATE_NONE; |
32 switch (sampling_rate) { | 34 switch (sampling_rate) { |
33 case AudioPacket::SAMPLING_RATE_44100: | 35 case AudioPacket::SAMPLING_RATE_44100: |
34 pp_sampling_rate = PP_AUDIOSAMPLERATE_44100; | 36 pp_sampling_rate = PP_AUDIOSAMPLERATE_44100; |
35 break; | 37 break; |
36 case AudioPacket::SAMPLING_RATE_48000: | 38 case AudioPacket::SAMPLING_RATE_48000: |
37 pp_sampling_rate = PP_AUDIOSAMPLERATE_48000; | 39 pp_sampling_rate = PP_AUDIOSAMPLERATE_48000; |
38 break; | 40 break; |
(...skipping 15 matching lines...) Expand all Loading... |
54 audio_ = pp::Audio(instance_, audio_config, AudioPlayerCallback, this); | 56 audio_ = pp::Audio(instance_, audio_config, AudioPlayerCallback, this); |
55 | 57 |
56 // Immediately start the player. | 58 // Immediately start the player. |
57 bool success = audio_.StartPlayback(); | 59 bool success = audio_.StartPlayback(); |
58 if (!success) | 60 if (!success) |
59 LOG(ERROR) << "Failed to start Pepper audio player"; | 61 LOG(ERROR) << "Failed to start Pepper audio player"; |
60 return success; | 62 return success; |
61 } | 63 } |
62 | 64 |
63 } // namespace remoting | 65 } // namespace remoting |
OLD | NEW |