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

Side by Side Diff: remoting/client/plugin/pepper_audio_player.h

Issue 10795066: Support for both 44.1 kHz and 48 kHz on the client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small cleanup Created 8 years, 5 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) 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 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_AUDIO_PLAYER_H_ 5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_AUDIO_PLAYER_H_
6 #define REMOTING_CLIENT_PLUGIN_PEPPER_AUDIO_PLAYER_H_ 6 #define REMOTING_CLIENT_PLUGIN_PEPPER_AUDIO_PLAYER_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "ppapi/cpp/audio.h" 15 #include "ppapi/cpp/audio.h"
16 #include "ppapi/cpp/instance.h" 16 #include "ppapi/cpp/instance.h"
17 #include "remoting/client/audio_player.h" 17 #include "remoting/client/audio_player.h"
18 #include "remoting/proto/audio.pb.h"
18 19
19 namespace remoting { 20 namespace remoting {
20 21
21 class AudioPacket;
22
23 class PepperAudioPlayer : public AudioPlayer { 22 class PepperAudioPlayer : public AudioPlayer {
24 public: 23 public:
25 explicit PepperAudioPlayer(pp::Instance* instance); 24 explicit PepperAudioPlayer(pp::Instance* instance);
26 virtual ~PepperAudioPlayer(); 25 virtual ~PepperAudioPlayer();
27 26
28 // Returns true if successful, false otherwise.
29 virtual bool Start() OVERRIDE;
30
31 virtual void ProcessAudioPacket(scoped_ptr<AudioPacket> packet) OVERRIDE; 27 virtual void ProcessAudioPacket(scoped_ptr<AudioPacket> packet) OVERRIDE;
32 28
33 virtual bool IsRunning() const OVERRIDE;
34
35 private: 29 private:
36 typedef std::list<AudioPacket*> AudioPacketQueue; 30 typedef std::list<AudioPacket*> AudioPacketQueue;
37 31
32 // Resets the audio player and starts the playback.
33 // Returns true on success.
34 bool ResetAudioPlayer(AudioPacket::SamplingRate sampling_rate);
35
38 // Function called by the browser when it needs more audio samples. 36 // Function called by the browser when it needs more audio samples.
39 static void PepperAudioPlayerCallback(void* samples, 37 static void PepperAudioPlayerCallback(void* samples,
40 uint32_t buffer_size, 38 uint32_t buffer_size,
41 void* data); 39 void* data);
42 40
43 void FillWithSamples(void* samples, uint32_t buffer_size); 41 void FillWithSamples(void* samples, uint32_t buffer_size);
44 42
43 pp::Instance* instance_;
45 pp::Audio audio_; 44 pp::Audio audio_;
46 45
46 AudioPacket::SamplingRate sampling_rate_;
47
47 // The count of sample frames per channel in an audio buffer. 48 // The count of sample frames per channel in an audio buffer.
48 uint32_t samples_per_frame_; 49 uint32_t samples_per_frame_;
49 50
50 // Protects |queued_packets_| and |bytes_consumed_|. 51 // Protects |queued_packets_| and |bytes_consumed_|.
51 // This is necessary to prevent races, 52 // This is necessary to prevent races,
52 // because Pepper will callback on a separate thread. 53 // because Pepper will callback on a separate thread.
53 base::Lock lock_; 54 base::Lock lock_;
54 55
55 AudioPacketQueue queued_packets_; 56 AudioPacketQueue queued_packets_;
56 57
57 // The number of bytes from |queued_packets_| that have been consumed. 58 // The number of bytes from |queued_packets_| that have been consumed.
58 size_t bytes_consumed_; 59 size_t bytes_consumed_;
59 60
60 bool running_; 61 bool start_failed_;
61 62
62 DISALLOW_COPY_AND_ASSIGN(PepperAudioPlayer); 63 DISALLOW_COPY_AND_ASSIGN(PepperAudioPlayer);
63 }; 64 };
64 65
65 } // namespace remoting 66 } // namespace remoting
66 67
67 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_AUDIO_PLAYER_H_ 68 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_AUDIO_PLAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698