Reland the ULONG -> SIZE_T change from 317177
[chromium-blink-merge.git] / extensions / browser / api / audio / audio_service.h
blob6d985ebd23b1f8f660897a1dfdb0228be9f34aaf
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_
6 #define EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/memory/linked_ptr.h"
14 #include "extensions/common/api/audio.h"
16 namespace extensions {
18 using OutputInfo = std::vector<linked_ptr<core_api::audio::OutputDeviceInfo>>;
19 using InputInfo = std::vector<linked_ptr<core_api::audio::InputDeviceInfo>>;
20 using DeviceIdList = std::vector<std::string>;
22 class AudioService {
23 public:
24 class Observer {
25 public:
26 // Called when anything changes to the audio device configuration.
27 virtual void OnDeviceChanged() = 0;
29 protected:
30 virtual ~Observer() {}
33 // Callback type for completing to get audio device information.
34 typedef base::Callback<void(const OutputInfo&, const InputInfo&, bool)>
35 GetInfoCallback;
37 // Creates a platform-specific AudioService instance.
38 static AudioService* CreateInstance();
40 virtual ~AudioService() {}
42 // Called by listeners to this service to add/remove themselves as observers.
43 virtual void AddObserver(Observer* observer) = 0;
44 virtual void RemoveObserver(Observer* observer) = 0;
46 // Start to query audio device information. Should be called on UI thread.
47 // The |callback| will be invoked once the query is completed.
48 virtual void StartGetInfo(const GetInfoCallback& callback) = 0;
50 // Sets the active nodes to the nodes specified by |device_list|.
51 // It can pass in the "complete" active node list of either input
52 // nodes, or output nodes, or both. If only input nodes are passed in,
53 // it will only change the input nodes' active status, output nodes will NOT
54 // be changed; similarly for the case if only output nodes are passed.
55 // If the nodes specified in |new_active_ids| are already active, they will
56 // remain active. Otherwise, the old active nodes will be de-activated before
57 // we activate the new nodes with the same type(input/output).
58 virtual void SetActiveDevices(const DeviceIdList& device_list) = 0;
60 // Set the muted and volume/gain properties of a device.
61 virtual bool SetDeviceProperties(const std::string& device_id,
62 bool muted,
63 int volume,
64 int gain) = 0;
66 protected:
67 AudioService() {}
69 private:
70 DISALLOW_COPY_AND_ASSIGN(AudioService);
73 } // namespace extensions
75 #endif // EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_