Make UEFI boot-platform build again
[haiku.git] / src / servers / midi / MidiServerApp.h
blobaa2b3d674bca5176b55106be006f16cc799519e6
1 /*
2 * Copyright 2002-2015, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Matthijs Hollemans
7 */
8 #ifndef MIDI_SERVER_APP_H
9 #define MIDI_SERVER_APP_H
12 #include <Server.h>
13 #include <List.h>
15 #include "DeviceWatcher.h"
18 struct app_t;
19 struct endpoint_t;
22 /*! The heart of the midi_server. This BApplication subclass
23 keeps the roster of endpoints and applications, processes
24 incoming messages from libmidi2.so, and notifies the apps
25 when something interesting happens.
27 class MidiServerApp : public BServer {
28 public:
29 MidiServerApp(status_t& error);
30 virtual ~MidiServerApp();
32 virtual void AboutRequested();
33 virtual void MessageReceived(BMessage* msg);
35 private:
36 typedef BServer super;
38 void _OnRegisterApp(BMessage* msg);
39 void _OnCreateEndpoint(BMessage* msg);
40 void _OnDeleteEndpoint(BMessage* msg);
41 void _OnPurgeEndpoint(BMessage* msg);
42 void _OnChangeEndpoint(BMessage* msg);
43 void _OnConnectDisconnect(BMessage* msg);
45 bool _SendAllEndpoints(app_t* app);
46 bool _SendAllConnections(app_t* app);
48 void _AddEndpoint(BMessage* msg, endpoint_t* endp);
49 void _RemoveEndpoint(app_t* app, endpoint_t* endp);
51 void _DisconnectDeadConsumer(endpoint_t* cons);
53 void _MakeCreatedNotification(BMessage* msg,
54 endpoint_t* endp);
55 void _MakeConnectedNotification(BMessage* msg,
56 endpoint_t* prod, endpoint_t* cons,
57 bool mustConnect);
59 app_t* _WhichApp(BMessage* msg);
60 endpoint_t* _WhichEndpoint(BMessage* msg, app_t* app);
61 endpoint_t* _FindEndpoint(int32 id);
63 void _NotifyAll(BMessage* msg, app_t* except);
64 bool _SendNotification(app_t* app, BMessage* msg);
65 bool _SendReply(app_t* app, BMessage* msg,
66 BMessage* reply);
68 void _DeliveryError(app_t* app);
70 int32 _CountApps();
71 app_t* _AppAt(int32 index);
73 int32 _CountEndpoints();
74 endpoint_t* _EndpointAt(int32 index);
76 int32 _CountConnections(endpoint_t* prod);
77 endpoint_t* _ConnectionAt(endpoint_t* prod, int32 index);
79 #ifdef DEBUG
80 void _DumpApps();
81 void _DumpEndpoints();
82 #endif
84 private:
85 //! The registered applications.
86 BList fApps;
88 //! All the endpoints in the system.
89 BList fEndpoints;
91 //! The ID we will assign to the next new endpoint.
92 int32 fNextID;
94 //! Watch endpoints from /dev/midi drivers.
95 DeviceWatcher* fDeviceWatcher;
99 #endif // MIDI_SERVER_APP_H