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;
48 // AudioLogFactory dispenses AudioLog instances to owning classes for tracking
49 // AudioComponent behavior. All AudioComponents have the concept of an owning
52 // - AudioInputRendererHost for AudioInputController
53 // - AudioRendererHost for AudioOutputController
54 // - AudioOutputDispatcherImpl for AudioOutputStream
56 // Each of these owning classes may own multiple instances of each component, as
57 // such each AudioLog supports logging for multiple instances.
58 class AudioLogFactory
{
61 // Input controllers have a 1:1 mapping with streams, so there's no need to
62 // track both controllers and streams.
63 AUDIO_INPUT_CONTROLLER
,
64 // Output controllers may or may not be backed by an active stream, so we
65 // need to track both controllers and streams.
66 AUDIO_OUTPUT_CONTROLLER
,
71 // Create a new AudioLog object for tracking the behavior for one or more
72 // instances of the given component. Each instance of an "owning" class must
73 // create its own AudioLog.
74 virtual scoped_ptr
<AudioLog
> CreateAudioLog(AudioComponent component
) = 0;
77 virtual ~AudioLogFactory() {}
82 #endif // MEDIA_AUDIO_AUDIO_LOGGING_H_