xref: /haiku/src/servers/media/NotificationManager.h (revision 2222d0559df303a9846a2fad53741f8b20b14d7c)
1 /*
2  * Copyright 2002, Marcus Overhagen. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef NOTIFICATION_MANAGER_H
6 #define NOTIFICATION_MANAGER_H
7 
8 #include <Locker.h>
9 #include <MediaNode.h>
10 #include <Messenger.h>
11 
12 #include "Queue.h"
13 #include "TList.h"
14 
15 
16 struct Notification {
17 	BMessenger	messenger;
18 	media_node	node;
19 	int32		what;
20 	team_id		team;
21 };
22 
23 class NotificationManager {
24 public:
25 								NotificationManager();
26 								~NotificationManager();
27 
28 			void				Dump();
29 
30 			void				EnqueueMessage(BMessage* message);
31 
32 			void				CleanupTeam(team_id team);
33 
34 private:
35 			void				RequestNotifications(BMessage* message);
36 			void				CancelNotifications(BMessage* message);
37 			void				SendNotifications(BMessage* message);
38 
39 			void				WorkerThread();
40 	static	int32				worker_thread(void* arg);
41 
42 private:
43 			Queue				fNotificationQueue;
44 			thread_id			fNotificationThreadId;
45 			BLocker				fLocker;
46 			List<Notification>	fNotificationList;
47 };
48 
49 #endif	// NOTIFICATION_MANAGER_H
50