OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_ | 5 #ifndef MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_ |
6 #define MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_ | 6 #define MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_ |
7 | 7 |
8 // NullAudioRenderer effectively uses an extra thread to "throw away" the | 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 | 9 // audio data at a rate resembling normal playback speed. It's just like |
10 // decoding to /dev/null! | 10 // decoding to /dev/null! |
(...skipping 19 matching lines...) Expand all Loading... |
30 namespace media { | 30 namespace media { |
31 | 31 |
32 class NullAudioRenderer : public AudioRendererBase, PlatformThread::Delegate { | 32 class NullAudioRenderer : public AudioRendererBase, PlatformThread::Delegate { |
33 public: | 33 public: |
34 // FilterFactory provider. | 34 // FilterFactory provider. |
35 static FilterFactory* CreateFilterFactory() { | 35 static FilterFactory* CreateFilterFactory() { |
36 return new FilterFactoryImpl0<NullAudioRenderer>(); | 36 return new FilterFactoryImpl0<NullAudioRenderer>(); |
37 } | 37 } |
38 | 38 |
39 // Compatible with any audio/x-uncompressed MediaFormat. | 39 // Compatible with any audio/x-uncompressed MediaFormat. |
40 static bool IsMediaFormatSupported(const MediaFormat* media_format); | 40 static bool IsMediaFormatSupported(const MediaFormat& media_format); |
41 | 41 |
42 // MediaFilter implementation. | 42 // MediaFilter implementation. |
43 virtual void SetPlaybackRate(float playback_rate); | 43 virtual void SetPlaybackRate(float playback_rate); |
44 | 44 |
45 // AudioRenderer implementation. | 45 // AudioRenderer implementation. |
46 virtual void SetVolume(float volume); | 46 virtual void SetVolume(float volume); |
47 | 47 |
48 // PlatformThread::Delegate implementation. | 48 // PlatformThread::Delegate implementation. |
49 virtual void ThreadMain(); | 49 virtual void ThreadMain(); |
50 | 50 |
51 protected: | 51 protected: |
52 // Only allow a factory to create this class. | 52 // Only allow a factory to create this class. |
53 friend class FilterFactoryImpl0<NullAudioRenderer>; | 53 friend class FilterFactoryImpl0<NullAudioRenderer>; |
54 NullAudioRenderer(); | 54 NullAudioRenderer(); |
55 virtual ~NullAudioRenderer(); | 55 virtual ~NullAudioRenderer(); |
56 | 56 |
57 // AudioRendererBase implementation. | 57 // AudioRendererBase implementation. |
58 virtual bool OnInitialize(const MediaFormat* media_format); | 58 virtual bool OnInitialize(const MediaFormat& media_format); |
59 virtual void OnStop(); | 59 virtual void OnStop(); |
60 | 60 |
61 private: | 61 private: |
62 // Current playback rate. | 62 // Current playback rate. |
63 float playback_rate_; | 63 float playback_rate_; |
64 | 64 |
65 // A number to convert bytes written in FillBuffer to milliseconds based on | 65 // A number to convert bytes written in FillBuffer to milliseconds based on |
66 // the audio format. Calculated in OnInitialize by looking at the decoder's | 66 // the audio format. Calculated in OnInitialize by looking at the decoder's |
67 // MediaFormat. | 67 // MediaFormat. |
68 size_t bytes_per_millisecond_; | 68 size_t bytes_per_millisecond_; |
69 | 69 |
70 // A buffer passed to FillBuffer to advance playback. | 70 // A buffer passed to FillBuffer to advance playback. |
71 scoped_ptr<uint8> buffer_; | 71 scoped_ptr<uint8> buffer_; |
72 size_t buffer_size_; | 72 size_t buffer_size_; |
73 | 73 |
74 // Separate thread used to throw away data. | 74 // Separate thread used to throw away data. |
75 PlatformThreadHandle thread_; | 75 PlatformThreadHandle thread_; |
76 | 76 |
77 // Shutdown flag. | 77 // Shutdown flag. |
78 bool shutdown_; | 78 bool shutdown_; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(NullAudioRenderer); | 80 DISALLOW_COPY_AND_ASSIGN(NullAudioRenderer); |
81 }; | 81 }; |
82 | 82 |
83 } // namespace media | 83 } // namespace media |
84 | 84 |
85 #endif // MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_ | 85 #endif // MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_ |
OLD | NEW |