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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
media / mojo / mojom / audio_output_stream.mojom [blame]
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module media.mojom;
import "media/mojo/mojom/audio_data_pipe.mojom";
import "media/mojo/mojom/audio_parameters.mojom";
import "media/mojo/mojom/media_types.mojom";
// An interface for controlling an audio output stream.
// To close the stream, just close the message pipe.
// The AudioOutputStream may expire due to other reasons than actual errors,
// such as user-initiated actions to close the stream. In this case, the
// connection is closed without calling OnError.
interface AudioOutputStream {
// Starts rendering audio.
Play();
// Stops rendering audio and sends a signal on the AudioDataPipe indicating
// this.
Pause();
// Flushes buffered audio. This should not be called when playing.
Flush();
// Sets volume. Volume must be in the range [0, 1].
SetVolume(double volume);
};
// An AudioOutputStreamObserver gets notifications about events related to an
// AudioOutputStream. DidStartPlaying() is invoked when the stream starts
// playing and it is eventually followed by a DidStopPlaying() call. A stream
// may start playing again after being stopped.
//
// Note: It is possible that DidStopPlaying() is not called in shutdown
// situations.
interface AudioOutputStreamObserver {
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum DisconnectReason {
// The Disconnect reason wasn't given explicitly. This probably means that
// the audio service crashed.
kDefault = 0,
// This code is used as disconnect reason when stream ended or failed to
// start due to an unrecoverable platform error, e.g. the hardware device is
// busy or disconnected.
kPlatformError = 1,
kTerminatedByClient = 2,
kStreamCreationFailed = 3,
kDocumentDestroyed = 4,
};
// This notification indicates that the stream started playing. The stream
// should be considered non-audible until a DidChangeAudibleState() call says
// otherwise.
DidStartPlaying();
// This notification indicates that the stream stopped playing. The stream
// should be considered no longer audible at this time; no further
// audible-state change notifications will be issued.
DidStopPlaying();
// This notification carries the latest value of the audible state of the
// stream. Multiple instances of this notification may occur after
// DidStartPlaying() and before DidStopPlaying().
DidChangeAudibleState(bool is_audible);
};
interface AudioOutputStreamProvider {
// Creates a new AudioOutputStream using |params|. |client| is notified when
// the stream is ready. The stream lifetime is bound by the lifetime of
// |client|. |processing_id|, if provided, identifies the group of input and
// output streams that are related during audio processing.
// This method fails if it is called more than once.
Acquire(AudioParameters params,
pending_remote<AudioOutputStreamProviderClient> client);
};
interface AudioOutputStreamProviderClient {
// |stream| is used to pass commands to the stream, and |data_pipe| is used
// to transfer the audio data.
// TODO(crbug.com/40551225): Currently, this will be called at most
// once. In the future, it may be called several times.
Created(pending_remote<AudioOutputStream> stream,
ReadWriteAudioDataPipe data_pipe);
};
// An interface for updating AudioOutputStream output device.
interface DeviceSwitchInterface {
// Update the device id for given output streaming.
SwitchAudioOutputDeviceId(string output_device_id);
};