summaryrefslogtreecommitdiffstats
path: root/media/filters/audio_renderer_impl.h
blob: 7829f958b2f9e7c8074298951ead4ddf5f920c40 (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
// 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_AUDIO_RENDERER_IMPL_H_
#define MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_

// This is the default implementation of AudioRenderer, which uses the audio
// interfaces to open an audio device.  Although it cannot be used in the
// sandbox, it serves as a reference implementation and can be used in other
// applications such as the test player.
//
// Note: THIS IS NOT THE AUDIO RENDERER USED IN CHROME.
//
// See src/chrome/renderer/media/audio_renderer_impl.h for chrome's
// implementation.

#include <deque>

#include "media/audio/audio_io.h"
#include "media/base/buffers.h"
#include "media/base/filters.h"
#include "media/filters/audio_renderer_base.h"

namespace media {

class AudioRendererImpl : public AudioRendererBase,
                          public AudioOutputStream::AudioSourceCallback {
 public:
  AudioRendererImpl();
  virtual ~AudioRendererImpl();

  // MediaFilter implementation.
  virtual void SetPlaybackRate(float playback_rate);

  // AudioRenderer implementation.
  virtual void SetVolume(float volume);

  // AudioSourceCallback implementation.
  virtual uint32 OnMoreData(AudioOutputStream* stream, uint8* dest,
                            uint32 len, AudioBuffersState buffers_state);
  virtual void OnClose(AudioOutputStream* stream);
  virtual void OnError(AudioOutputStream* stream, int code);

 protected:
  // AudioRendererBase implementation.
  virtual bool OnInitialize(const MediaFormat& media_format);
  virtual void OnStop();

 private:
  // Audio output stream device.
  AudioOutputStream* stream_;
  int bytes_per_second_;

  DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
};

}  // namespace media

#endif  // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_