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

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

Issue 651373003: Add support for real audio output to mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo_ari
Patch Set: Comments. Created 6 years, 1 month 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
« no previous file with comments | « media/audio/BUILD.gn ('k') | media/audio/audio_output_stream_sink.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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_AUDIO_AUDIO_OUTPUT_STREAM_SINK_H_
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_STREAM_SINK_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/synchronization/lock.h"
11 #include "media/audio/audio_io.h"
12 #include "media/base/audio_renderer_sink.h"
13 #include "media/base/media_export.h"
14
15 namespace media {
16
17 // Wrapper which exposes the browser side audio interface (AudioOutputStream) as
18 // if it were a renderer side audio interface (AudioRendererSink). Note: This
19 // will not work for sandboxed renderers.
20 //
21 // TODO(dalecurtis): Delete this class once we have a proper mojo audio service;
22 // tracked by http://crbug.com/425368
23 class MEDIA_EXPORT AudioOutputStreamSink
24 : NON_EXPORTED_BASE(public AudioRendererSink),
25 public AudioOutputStream::AudioSourceCallback {
26 public:
27 AudioOutputStreamSink();
28
29 // AudioRendererSink implementation.
30 void Initialize(const AudioParameters& params,
31 RenderCallback* callback) override;
32 void Start() override;
33 void Stop() override;
34 void Pause() override;
35 void Play() override;
36 bool SetVolume(double volume) override;
37
38 // AudioSourceCallback implementation.
39 int OnMoreData(AudioBus* dest, uint32 total_bytes_delay) override;
40 void OnError(AudioOutputStream* stream) override;
41
42 private:
43 ~AudioOutputStreamSink() override;
44
45 // Helper methods for running AudioManager methods on the audio thread.
46 void DoStart();
47 void DoStop();
48 void DoPause();
49 void DoPlay();
50 void DoSetVolume(double volume);
51
52 // Clears |active_render_callback_| under lock, synchronously stopping render
53 // callbacks from any thread. Must be called before Pause() and Stop()
54 // trampoline to their helper methods on the audio thread.
55 void ClearCallback();
56
57 // Parameters provided by Initialize(), cached for use on other threads.
58 AudioParameters params_;
59
60 // Since Initialize() is only called once for AudioRenderSinks, save the
61 // callback both here and under |active_render_callback_| which will be
62 // cleared during Pause() and Stop() to achieve "synchronous" stoppage.
63 RenderCallback* render_callback_;
64
65 // The task runner for the audio thread.
66 const scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
67
68 // The actual AudioOutputStream, must only be accessed on the audio thread.
69 AudioOutputStream* stream_;
70
71 // Lock and callback for forwarding OnMoreData() calls into Render() calls.
72 base::Lock callback_lock_;
73 RenderCallback* active_render_callback_;
74
75 DISALLOW_COPY_AND_ASSIGN(AudioOutputStreamSink);
76 };
77
78 } // namepace media
79
80 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_STREAM_SINK_H_
OLDNEW
« no previous file with comments | « media/audio/BUILD.gn ('k') | media/audio/audio_output_stream_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698