Audacity 3.2.0
DeviceChange.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 DeviceChange.h
6
7 Leland Lucius
8
9**********************************************************************/
10
11#ifndef __AUDACITY_DEVICECHANGE_H__
12#define __AUDACITY_DEVICECHANGE_H__
13
14#include "Observer.h"
15
16enum class DeviceChangeMessage : char { Rescan, Change };
18
19#if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
20
21#include <memory>
22
23#if defined(__WXMSW__) || defined(__WXMAC__) || defined(HAVE_LIBUDEV_H)
24#define HAVE_DEVICE_CHANGE
25#endif
26
27#if defined(HAVE_DEVICE_CHANGE)
28
29#include "Observer.h"
30
31class DeviceChangeInterface /* not final */
32{
33public:
34 virtual ~DeviceChangeInterface() {};
35
36 virtual bool SetHandler(DeviceChangeMessagePublisher *handler) = 0;
37 virtual void Enable(bool enable = true) = 0;
38};
39
40class DeviceChangeHandler
41 : public wxEvtHandler // for wxTimerEvent
43{
44public:
45 DeviceChangeHandler();
46 virtual ~DeviceChangeHandler();
47
48 void Enable(bool enable = true);
49
50 virtual void DeviceChangeNotification() = 0;
51
52private:
53 void OnChange(DeviceChangeMessage);
54 void OnTimer(wxTimerEvent & evt);
55
56 std::unique_ptr<DeviceChangeInterface> mListener;
57 wxTimer mTimer;
58
59 Observer::Subscription mSubscription;
60
61 DECLARE_EVENT_TABLE()
62};
63
64#endif
65
66#endif
67
68#endif
DeviceChangeMessage
Definition: DeviceChange.h:16
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70