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

Side by Side Diff: extensions/browser/api/audio/audio_service.h

Issue 2605983002: Simplify logic behind chrome.audio.setActiveDevices (Closed)
Patch Set: . Created 3 years, 11 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_ 5 #ifndef EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_
6 #define EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_ 6 #define EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "extensions/common/api/audio.h" 14 #include "extensions/common/api/audio.h"
14 15
15 namespace extensions { 16 namespace extensions {
16 17
17 using OutputInfo = std::vector<api::audio::OutputDeviceInfo>; 18 using OutputInfo = std::vector<api::audio::OutputDeviceInfo>;
(...skipping 30 matching lines...) Expand all
48 // Called by listeners to this service to add/remove themselves as observers. 49 // Called by listeners to this service to add/remove themselves as observers.
49 virtual void AddObserver(Observer* observer) = 0; 50 virtual void AddObserver(Observer* observer) = 0;
50 virtual void RemoveObserver(Observer* observer) = 0; 51 virtual void RemoveObserver(Observer* observer) = 0;
51 52
52 // Start to query audio device information. Should be called on UI thread. 53 // Start to query audio device information. Should be called on UI thread.
53 // Populates |output_info_out| and |input_info_out| with the results. 54 // Populates |output_info_out| and |input_info_out| with the results.
54 // Returns true on success. 55 // Returns true on success.
55 virtual bool GetInfo(OutputInfo* output_info_out, 56 virtual bool GetInfo(OutputInfo* output_info_out,
56 InputInfo* input_info_out) = 0; 57 InputInfo* input_info_out) = 0;
57 58
59 // Sets set of active inputs to devices defined by IDs in |input_devices|,
60 // and set of active outputs to devices defined by IDs in |output_devices|.
61 // If either of |input_devices| or |output_devices| is not set, associated
62 // set of active devices will remain unchanged.
63 // If either list is empty, all active devices of associated type will be
64 // deactivated.
65 // Returns whether the operation succeeded - on failure there will be no
66 // changes to active devices.
67 // Note that device ID lists should contain only existing device ID of
68 // appropriate type in order for the method to succeed.
69 virtual bool SetActiveDeviceLists(
70 const std::unique_ptr<DeviceIdList>& input_devices,
71 const std::unique_ptr<DeviceIdList>& output_devives) = 0;
72
58 // Sets the active devices to the devices specified by |device_list|. 73 // Sets the active devices to the devices specified by |device_list|.
59 // It can pass in the "complete" active device list of either input 74 // It can pass in the "complete" active device list of either input
60 // devices, or output devices, or both. If only input devices are passed in, 75 // devices, or output devices, or both. If only input devices are passed in,
61 // it will only change the input devices' active status, output devices will 76 // it will only change the input devices' active status, output devices will
62 // NOT be changed; similarly for the case if only output devices are passed. 77 // NOT be changed; similarly for the case if only output devices are passed.
63 // If the devices specified in |new_active_ids| are already active, they will 78 // If the devices specified in |new_active_ids| are already active, they will
64 // remain active. Otherwise, the old active devices will be de-activated 79 // remain active. Otherwise, the old active devices will be de-activated
65 // before we activate the new devices with the same type(input/output). 80 // before we activate the new devices with the same type(input/output).
66 virtual void SetActiveDevices(const DeviceIdList& device_list) = 0; 81 virtual void SetActiveDevices(const DeviceIdList& device_list) = 0;
67 82
68 // Set the muted and volume/gain properties of a device. 83 // Set the muted and volume/gain properties of a device.
69 virtual bool SetDeviceProperties(const std::string& device_id, 84 virtual bool SetDeviceProperties(const std::string& device_id,
70 bool muted, 85 bool muted,
71 int volume, 86 int volume,
72 int gain) = 0; 87 int gain) = 0;
73 88
74 protected: 89 protected:
75 AudioService() {} 90 AudioService() {}
76 91
77 private: 92 private:
78 DISALLOW_COPY_AND_ASSIGN(AudioService); 93 DISALLOW_COPY_AND_ASSIGN(AudioService);
79 }; 94 };
80 95
81 } // namespace extensions 96 } // namespace extensions
82 97
83 #endif // EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_ 98 #endif // EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/audio/audio_api.cc ('k') | extensions/browser/api/audio/audio_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698