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
3 // found in the LICENSE file.
5 #ifndef REMOTING_CLIENT_AUDIO_PLAYER_H_
6 #define REMOTING_CLIENT_AUDIO_PLAYER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/synchronization/lock.h"
12 #include "remoting/proto/audio.pb.h"
18 virtual ~AudioPlayer();
20 void ProcessAudioPacket(scoped_ptr
<AudioPacket
> packet
);
25 // Return the recommended number of samples to include in a frame.
26 virtual uint32
GetSamplesPerFrame() = 0;
28 // Resets the audio player and starts playback.
29 // Returns true on success.
30 virtual bool ResetAudioPlayer(AudioPacket::SamplingRate sampling_rate
) = 0;
32 // Function called by the browser when it needs more audio samples.
33 static void AudioPlayerCallback(void* samples
,
38 friend class AudioPlayerTest
;
40 typedef std::list
<AudioPacket
*> AudioPacketQueue
;
43 void FillWithSamples(void* samples
, uint32 buffer_size
);
45 AudioPacket::SamplingRate sampling_rate_
;
49 // Protects |queued_packets_|, |queued_samples_ and |bytes_consumed_|. This is
50 // necessary to prevent races, because Pepper will call the callback on a
54 AudioPacketQueue queued_packets_
;
57 // The number of bytes from |queued_packets_| that have been consumed.
58 size_t bytes_consumed_
;
60 DISALLOW_COPY_AND_ASSIGN(AudioPlayer
);
63 } // namespace remoting
65 #endif // REMOTING_CLIENT_AUDIO_PLAYER_H_