blob: 038ac25b7d9880706b7697fd97adab2b647de3cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_
#define MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_
// NullAudioRenderer effectively uses an extra thread to "throw away" the
// audio data at a rate resembling normal playback speed. It's just like
// decoding to /dev/null!
//
// NullAudioRenderer can also be used in situations where the client has no
// audio device or we haven't written an audio implementation for a particular
// platform yet.
//
// It supports any type of MediaFormat as long as the mime type has been set to
// audio/x-uncompressed. Playback rate is also supported and NullAudioRenderer
// will slow down and speed up accordingly.
#include <deque>
#include "base/platform_thread.h"
#include "base/scoped_ptr.h"
#include "media/base/buffers.h"
#include "media/base/filters.h"
#include "media/filters/audio_renderer_base.h"
namespace media {
class NullAudioRenderer : public AudioRendererBase, PlatformThread::Delegate {
public:
NullAudioRenderer();
virtual ~NullAudioRenderer();
// AudioRenderer implementation.
virtual void SetVolume(float volume);
// PlatformThread::Delegate implementation.
virtual void ThreadMain();
protected:
// AudioRendererBase implementation.
virtual bool OnInitialize(const MediaFormat& media_format);
virtual void OnStop();
private:
// A number to convert bytes written in FillBuffer to milliseconds based on
// the audio format. Calculated in OnInitialize by looking at the decoder's
// MediaFormat.
size_t bytes_per_millisecond_;
// A buffer passed to FillBuffer to advance playback.
scoped_array<uint8> buffer_;
size_t buffer_size_;
// Separate thread used to throw away data.
PlatformThreadHandle thread_;
// Shutdown flag.
bool shutdown_;
DISALLOW_COPY_AND_ASSIGN(NullAudioRenderer);
};
} // namespace media
#endif // MEDIA_FILTERS_NULL_AUDIO_RENDERER_H_
|