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

Side by Side Diff: media/audio/null_audio_sink.h

Issue 9826023: Merge AudioRendererImpl and AudioRendererBase; add NullAudioSink (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 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
(Empty)
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.
4
5 #ifndef MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_
6 #define MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_
7
8 // NullAudioSink 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!
11 //
12 // NullAudioSink 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.
15
16 #include <vector>
17
18 #include "base/threading/thread.h"
19 #include "media/base/audio_renderer_sink.h"
20
21 namespace media {
22
23 class MEDIA_EXPORT NullAudioSink : public AudioRendererSink {
24 public:
25 NullAudioSink();
26 virtual ~NullAudioSink();
27
28 // AudioRendererSink implementation.
29 virtual void Initialize(const AudioParameters& params,
30 RenderCallback* callback) OVERRIDE;
31 virtual void Start() OVERRIDE;
32 virtual void Stop() OVERRIDE;
33 virtual void Pause(bool flush) OVERRIDE;
34 virtual void Play() OVERRIDE;
35 virtual void SetPlaybackRate(float rate) OVERRIDE;
36 virtual bool SetVolume(double volume) OVERRIDE;
37 virtual void GetVolume(double* volume) OVERRIDE;
38
39 private:
40 // Audio thread task that periodically calls FillBuffer() to consume
41 // audio data.
42 void FillBufferTask();
43
44 void SetPlaying(bool is_playing);
45
46 // A buffer passed to FillBuffer to advance playback.
47 std::vector<float*> audio_data_;
48
49 AudioParameters params_;
50 bool initialized_;
51 float playback_rate_;
52 bool playing_;
53 RenderCallback* callback_;
54
55 // Separate thread used to throw away data.
56 base::Thread thread_;
57 base::Lock lock_;
58
59 DISALLOW_COPY_AND_ASSIGN(NullAudioSink);
60 };
61
62 } // namespace media
63
64 #endif // MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698