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

Side by Side Diff: media/base/output_device.h

Issue 1809093003: Moving SwitchOutputDevice out of OutputDevice interface, eliminating OutputDevice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Getting rid of OutputDevice interface Created 4 years, 9 months 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
OLDNEW
(Empty)
1 // Copyright (c) 2015 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_BASE_OUTPUT_DEVICE_H_
6 #define MEDIA_BASE_OUTPUT_DEVICE_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "media/audio/audio_parameters.h"
12 #include "media/base/media_export.h"
13 #include "url/origin.h"
14
15 namespace media {
16
17 // Result of an audio output device switch operation
18 enum OutputDeviceStatus {
19 OUTPUT_DEVICE_STATUS_OK = 0,
20 OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND,
21 OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED,
22 OUTPUT_DEVICE_STATUS_ERROR_INTERNAL,
23 OUTPUT_DEVICE_STATUS_LAST = OUTPUT_DEVICE_STATUS_ERROR_INTERNAL,
24 };
25
26 typedef base::Callback<void(OutputDeviceStatus)> SwitchOutputDeviceCB;
27
28 // OutputDevice is an interface that allows performing operations related
29 // audio output devices.
30
31 class OutputDevice {
32 public:
33 // Attempts to switch the audio output device.
34 // Once the attempt is finished, |callback| is invoked with the
35 // result of the operation passed as a parameter. The result is a value from
36 // the media::SwitchOutputDeviceResult enum.
37 // There is no guarantee about the thread where |callback| will
38 // be invoked, so users are advised to use media::BindToCurrentLoop() to
39 // ensure that |callback| runs on the correct thread.
40 // Note also that copy constructors and destructors for arguments bound to
41 // |callback| may run on arbitrary threads as |callback| is moved across
42 // threads. It is advisable to bind arguments such that they are released by
43 // |callback| when it runs in order to avoid surprises.
44 virtual void SwitchOutputDevice(const std::string& device_id,
45 const url::Origin& security_origin,
46 const SwitchOutputDeviceCB& callback) = 0;
47
48 // Returns the device's audio output parameters.
49 // The return value is undefined if the device status (as returned by
50 // GetDeviceStatus()) is different from OUTPUT_DEVICE_STATUS_OK.
51 // If the parameters are not available, this method may block until they
52 // become available.
53 // This method must never be called on the IO thread.
54 virtual AudioParameters GetOutputParameters() = 0;
55
56 // Returns the status of output device.
57 // If the status is not available, this method may block until it becomes
58 // available. Must never be called on the IO thread.
59 virtual OutputDeviceStatus GetDeviceStatus() = 0;
60
61 protected:
62 virtual ~OutputDevice() {}
63 };
64
65 } // namespace media
66
67 #endif // MEDIA_BASE_OUTPUT_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698