Updating trunk VERSION from 935.0 to 936.0
[chromium-blink-merge.git] / media / filters / null_audio_renderer.h
blob2f9d06291a7e4b2b51d41d7e22c9e24dff98bfd3
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.
5 #ifndef MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_
6 #define MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_
8 // NullAudioRenderer effectively uses an extra thread to "throw away" the
9 // audio data at a rate resembling normal playback speed. It's just like
10 // decoding to /dev/null!
12 // NullAudioRenderer can also be used in situations where the client has no
13 // audio device or we haven't written an audio implementation for a particular
14 // platform yet.
16 #include <deque>
18 #include "base/memory/scoped_ptr.h"
19 #include "base/threading/platform_thread.h"
20 #include "media/base/buffers.h"
21 #include "media/base/filters.h"
22 #include "media/filters/audio_renderer_base.h"
24 namespace media {
26 class MEDIA_EXPORT NullAudioRenderer
27 : public AudioRendererBase,
28 public base::PlatformThread::Delegate {
29 public:
30 NullAudioRenderer();
31 virtual ~NullAudioRenderer();
33 // AudioRenderer implementation.
34 virtual void SetVolume(float volume);
36 // PlatformThread::Delegate implementation.
37 virtual void ThreadMain();
39 protected:
40 // AudioRendererBase implementation.
41 virtual bool OnInitialize(int bits_per_channel,
42 ChannelLayout channel_layout,
43 int sample_rate);
44 virtual void OnStop();
46 private:
47 // A number to convert bytes written in FillBuffer to milliseconds based on
48 // the audio format.
49 size_t bytes_per_millisecond_;
51 // A buffer passed to FillBuffer to advance playback.
52 scoped_array<uint8> buffer_;
53 size_t buffer_size_;
55 // Separate thread used to throw away data.
56 base::PlatformThreadHandle thread_;
58 // Shutdown flag.
59 bool shutdown_;
61 DISALLOW_COPY_AND_ASSIGN(NullAudioRenderer);
64 } // namespace media
66 #endif // MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_