1 // Copyright 2013 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.
5 #ifndef MEDIA_AUDIO_AUDIO_LOGGING_H_
6 #define MEDIA_AUDIO_AUDIO_LOGGING_H_
10 #include "base/memory/scoped_ptr.h"
13 class AudioParameters
;
15 // AudioLog logs state information about an active audio component. Each method
16 // takes a |component_id| along with method specific information. Its methods
17 // are safe to call from any thread.
20 virtual ~AudioLog() {}
22 // Called when an audio component is created. |params| are the parameters of
23 // the created stream. |device_id| is the id of the audio device opened by
24 // the created stream.
25 virtual void OnCreated(int component_id
,
26 const media::AudioParameters
& params
,
27 const std::string
& device_id
) = 0;
29 // Called when an audio component is started, generally this is synonymous
31 virtual void OnStarted(int component_id
) = 0;
33 // Called when an audio component is stopped, generally this is synonymous
35 virtual void OnStopped(int component_id
) = 0;
37 // Called when an audio component is closed, generally this is synonymous
39 virtual void OnClosed(int component_id
) = 0;
41 // Called when an audio component encounters an error.
42 virtual void OnError(int component_id
) = 0;
44 // Called when an audio component changes volume. |volume| is the new volume.
45 virtual void OnSetVolume(int component_id
, double volume
) = 0;
47 // Called when an audio component switches output device. |device_id| is the
48 // new audio output device.
49 virtual void OnSwitchOutputDevice(int component_id
,
50 const std::string
& device_id
) = 0;
53 // AudioLogFactory dispenses AudioLog instances to owning classes for tracking
54 // AudioComponent behavior. All AudioComponents have the concept of an owning
57 // - AudioInputRendererHost for AudioInputController
58 // - AudioRendererHost for AudioOutputController
59 // - AudioOutputDispatcherImpl for AudioOutputStream
61 // Each of these owning classes may own multiple instances of each component, as
62 // such each AudioLog supports logging for multiple instances.
63 class AudioLogFactory
{
66 // Input controllers have a 1:1 mapping with streams, so there's no need to
67 // track both controllers and streams.
68 AUDIO_INPUT_CONTROLLER
,
69 // Output controllers may or may not be backed by an active stream, so we
70 // need to track both controllers and streams.
71 AUDIO_OUTPUT_CONTROLLER
,
76 // Create a new AudioLog object for tracking the behavior for one or more
77 // instances of the given component. Each instance of an "owning" class must
78 // create its own AudioLog.
79 virtual scoped_ptr
<AudioLog
> CreateAudioLog(AudioComponent component
) = 0;
82 virtual ~AudioLogFactory() {}
87 #endif // MEDIA_AUDIO_AUDIO_LOGGING_H_