2 * Copyright 2002-2015, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
8 #ifndef MIDI_SERVER_APP_H
9 #define MIDI_SERVER_APP_H
15 #include "DeviceWatcher.h"
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
{
29 MidiServerApp(status_t
& error
);
30 virtual ~MidiServerApp();
32 virtual void AboutRequested();
33 virtual void MessageReceived(BMessage
* msg
);
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
,
55 void _MakeConnectedNotification(BMessage
* msg
,
56 endpoint_t
* prod
, endpoint_t
* cons
,
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
,
68 void _DeliveryError(app_t
* app
);
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
);
81 void _DumpEndpoints();
85 //! The registered applications.
88 //! All the endpoints in the system.
91 //! The ID we will assign to the next new endpoint.
94 //! Watch endpoints from /dev/midi drivers.
95 DeviceWatcher
* fDeviceWatcher
;
99 #endif // MIDI_SERVER_APP_H