xref: /haiku/src/servers/media/NotificationManager.h (revision 4da0916c585028906cf298c369cea9ec254c0f11)
11299bfb2Sbeveloper /*
21299bfb2Sbeveloper  * Copyright 2002, Marcus Overhagen. All rights reserved.
31299bfb2Sbeveloper  * Distributed under the terms of the MIT License.
41299bfb2Sbeveloper  */
58734b81dSAxel Dörfler #ifndef NOTIFICATION_MANAGER_H
68734b81dSAxel Dörfler #define NOTIFICATION_MANAGER_H
71d616657Sbeveloper 
8*4da0916cSJérôme Duval 
98734b81dSAxel Dörfler #include <Locker.h>
10e66fda40Sbeveloper #include <MediaNode.h>
118734b81dSAxel Dörfler #include <Messenger.h>
128734b81dSAxel Dörfler 
138734b81dSAxel Dörfler #include "Queue.h"
14e66fda40Sbeveloper #include "TList.h"
15e66fda40Sbeveloper 
161d616657Sbeveloper 
178734b81dSAxel Dörfler struct Notification {
18e66fda40Sbeveloper 	BMessenger	messenger;
19e66fda40Sbeveloper 	media_node	node;
20e66fda40Sbeveloper 	int32		what;
21e66fda40Sbeveloper 	team_id		team;
22e66fda40Sbeveloper };
23e66fda40Sbeveloper 
248734b81dSAxel Dörfler class NotificationManager {
251d616657Sbeveloper public:
261d616657Sbeveloper 								NotificationManager();
271d616657Sbeveloper 								~NotificationManager();
281d616657Sbeveloper 
29ced4130fSbeveloper 			void				Dump();
30ced4130fSbeveloper 
318734b81dSAxel Dörfler 			void				EnqueueMessage(BMessage* message);
321d616657Sbeveloper 
331d616657Sbeveloper 			void				CleanupTeam(team_id team);
341d616657Sbeveloper 
351d616657Sbeveloper private:
368734b81dSAxel Dörfler 			void				RequestNotifications(BMessage* message);
378734b81dSAxel Dörfler 			void				CancelNotifications(BMessage* message);
388734b81dSAxel Dörfler 			void				SendNotifications(BMessage* message);
391d616657Sbeveloper 
401d616657Sbeveloper 			void				WorkerThread();
411d616657Sbeveloper 	static	int32				worker_thread(void* arg);
421d616657Sbeveloper 
431d616657Sbeveloper private:
448734b81dSAxel Dörfler 			Queue				fNotificationQueue;
451d616657Sbeveloper 			thread_id			fNotificationThreadId;
468734b81dSAxel Dörfler 			BLocker				fLocker;
478734b81dSAxel Dörfler 			List<Notification>	fNotificationList;
481d616657Sbeveloper };
498734b81dSAxel Dörfler 
508734b81dSAxel Dörfler #endif	// NOTIFICATION_MANAGER_H
51