xref: /haiku/src/kits/media/BufferCache.h (revision fe08f0b3d0489bded18325689900a99dbad40694)
19dec2310SAxel Dörfler /*
2*fe08f0b3SRyan Leavengood  * Copyright 2019, Ryan Leavengood.
39dec2310SAxel Dörfler  * Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
49dec2310SAxel Dörfler  * Copyright 2002, Marcus Overhagen. All Rights Reserved.
59dec2310SAxel Dörfler  * Distributed under the terms of the MIT License.
69dec2310SAxel Dörfler  */
79dec2310SAxel Dörfler #ifndef _BUFFER_CACHE_H_
89dec2310SAxel Dörfler #define _BUFFER_CACHE_H_
99dec2310SAxel Dörfler 
109dec2310SAxel Dörfler 
11*fe08f0b3SRyan Leavengood #include <HashMap.h>
129dec2310SAxel Dörfler #include <MediaDefs.h>
139dec2310SAxel Dörfler 
149dec2310SAxel Dörfler 
159dec2310SAxel Dörfler class BBuffer;
169dec2310SAxel Dörfler 
179dec2310SAxel Dörfler 
189dec2310SAxel Dörfler namespace BPrivate {
199dec2310SAxel Dörfler 
209dec2310SAxel Dörfler 
21*fe08f0b3SRyan Leavengood struct buffer_cache_entry {
22*fe08f0b3SRyan Leavengood 	BBuffer*	buffer;
23*fe08f0b3SRyan Leavengood 	port_id		port;
24*fe08f0b3SRyan Leavengood };
25*fe08f0b3SRyan Leavengood 
26*fe08f0b3SRyan Leavengood 
279dec2310SAxel Dörfler class BufferCache {
289dec2310SAxel Dörfler public:
299dec2310SAxel Dörfler 								BufferCache();
309dec2310SAxel Dörfler 								~BufferCache();
319dec2310SAxel Dörfler 
32*fe08f0b3SRyan Leavengood 			BBuffer*			GetBuffer(media_buffer_id id, port_id port);
33*fe08f0b3SRyan Leavengood 
34*fe08f0b3SRyan Leavengood 			void				FlushCacheForPort(port_id port);
359dec2310SAxel Dörfler 
369dec2310SAxel Dörfler private:
37*fe08f0b3SRyan Leavengood 	typedef HashMap<HashKey32<media_buffer_id>, buffer_cache_entry> BufferMap;
389dec2310SAxel Dörfler 
399dec2310SAxel Dörfler 			BufferMap			fMap;
409dec2310SAxel Dörfler };
419dec2310SAxel Dörfler 
429dec2310SAxel Dörfler 
439dec2310SAxel Dörfler }	// namespace BPrivate
449dec2310SAxel Dörfler 
459dec2310SAxel Dörfler 
469dec2310SAxel Dörfler #endif	// _BUFFER_CACHE_H_
47