haiku/headers/private/media/SharedBufferList.h

68 lines
1.6 KiB
C
Raw Normal View History

Sorry for this large commit in advance; it's not really possible to divide this into smaller parts: media_addon_server: * Removed (broken) use of (broken and inefficient) home-brewn Map, and List classes. This also fixes a crash on shutdown when used with the malloc_debug implementation. It's using stl::vector, and stl::map now instead. _shared_buffer_list: * Renamed _shared_buffer_list to SharedBufferList, and put it into the BPrivate namespace. Also, made a class out of it. * Separated shared buffer list creation from cloning. * Enlarged maximum number of buffers to something that is not that evil, but actually uses the space it has (ie. is a useful multiple of shared_buffer_info that fills a multiple of B_PAGE_SIZE as much as possible). * No longer drops into the debugger if the * The list that is currently used is very inefficient for the features it provides though (no change there). _buffer_id_cache: * Renamed to BufferCache, and put it into the private namespace * It now deletes its buffers on deletion; since the BBufferConsumer will be gone, too, at this point, there is little chance that there are still buffers in use. * Also, it's now using std::map instead of the (see above) Map class. BBuffer: * Got rid of the fBufferID member. Misc.: * Got rid of the global "team" variable; the media kit is now using the private app kit's current_team() now. * Added a lot of missing error checks (mostly memory allocations). * Renamed fields like "flavorid" to flavor_id, renamed "dfi_*" fields to something more detailed. * Moved ServerInterface.h from src/servers/media/ to headers/private/media. * Notifications.h was not self contained. * Added missing licenses. * Lots of cleanups, and coding style fixes. What this doesn't fix: * Bug #4954 which started all this (this comes next, though) * Deinitialization is broken, as the PortPool is uninitialized too early, and still used afterwards. * The strange add-on monitoring code in the media_addon_server git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34500 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-05 14:11:28 +03:00
/*
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2002, Marcus Overhagen. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SHARED_BUFFER_LIST_H_
#define _SHARED_BUFFER_LIST_H_
Sorry for this large commit in advance; it's not really possible to divide this into smaller parts: media_addon_server: * Removed (broken) use of (broken and inefficient) home-brewn Map, and List classes. This also fixes a crash on shutdown when used with the malloc_debug implementation. It's using stl::vector, and stl::map now instead. _shared_buffer_list: * Renamed _shared_buffer_list to SharedBufferList, and put it into the BPrivate namespace. Also, made a class out of it. * Separated shared buffer list creation from cloning. * Enlarged maximum number of buffers to something that is not that evil, but actually uses the space it has (ie. is a useful multiple of shared_buffer_info that fills a multiple of B_PAGE_SIZE as much as possible). * No longer drops into the debugger if the * The list that is currently used is very inefficient for the features it provides though (no change there). _buffer_id_cache: * Renamed to BufferCache, and put it into the private namespace * It now deletes its buffers on deletion; since the BBufferConsumer will be gone, too, at this point, there is little chance that there are still buffers in use. * Also, it's now using std::map instead of the (see above) Map class. BBuffer: * Got rid of the fBufferID member. Misc.: * Got rid of the global "team" variable; the media kit is now using the private app kit's current_team() now. * Added a lot of missing error checks (mostly memory allocations). * Renamed fields like "flavorid" to flavor_id, renamed "dfi_*" fields to something more detailed. * Moved ServerInterface.h from src/servers/media/ to headers/private/media. * Notifications.h was not self contained. * Added missing licenses. * Lots of cleanups, and coding style fixes. What this doesn't fix: * Bug #4954 which started all this (this comes next, though) * Deinitialization is broken, as the PortPool is uninitialized too early, and still used afterwards. * The strange add-on monitoring code in the media_addon_server git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34500 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-05 14:11:28 +03:00
#include <Buffer.h>
Sorry for this large commit in advance; it's not really possible to divide this into smaller parts: media_addon_server: * Removed (broken) use of (broken and inefficient) home-brewn Map, and List classes. This also fixes a crash on shutdown when used with the malloc_debug implementation. It's using stl::vector, and stl::map now instead. _shared_buffer_list: * Renamed _shared_buffer_list to SharedBufferList, and put it into the BPrivate namespace. Also, made a class out of it. * Separated shared buffer list creation from cloning. * Enlarged maximum number of buffers to something that is not that evil, but actually uses the space it has (ie. is a useful multiple of shared_buffer_info that fills a multiple of B_PAGE_SIZE as much as possible). * No longer drops into the debugger if the * The list that is currently used is very inefficient for the features it provides though (no change there). _buffer_id_cache: * Renamed to BufferCache, and put it into the private namespace * It now deletes its buffers on deletion; since the BBufferConsumer will be gone, too, at this point, there is little chance that there are still buffers in use. * Also, it's now using std::map instead of the (see above) Map class. BBuffer: * Got rid of the fBufferID member. Misc.: * Got rid of the global "team" variable; the media kit is now using the private app kit's current_team() now. * Added a lot of missing error checks (mostly memory allocations). * Renamed fields like "flavorid" to flavor_id, renamed "dfi_*" fields to something more detailed. * Moved ServerInterface.h from src/servers/media/ to headers/private/media. * Notifications.h was not self contained. * Added missing licenses. * Lots of cleanups, and coding style fixes. What this doesn't fix: * Bug #4954 which started all this (this comes next, though) * Deinitialization is broken, as the PortPool is uninitialized too early, and still used afterwards. * The strange add-on monitoring code in the media_addon_server git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34500 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-05 14:11:28 +03:00
namespace BPrivate {
class SharedBufferList {
public:
static area_id Create(SharedBufferList** _list);
static SharedBufferList* Get();
static void Invalidate();
Sorry for this large commit in advance; it's not really possible to divide this into smaller parts: media_addon_server: * Removed (broken) use of (broken and inefficient) home-brewn Map, and List classes. This also fixes a crash on shutdown when used with the malloc_debug implementation. It's using stl::vector, and stl::map now instead. _shared_buffer_list: * Renamed _shared_buffer_list to SharedBufferList, and put it into the BPrivate namespace. Also, made a class out of it. * Separated shared buffer list creation from cloning. * Enlarged maximum number of buffers to something that is not that evil, but actually uses the space it has (ie. is a useful multiple of shared_buffer_info that fills a multiple of B_PAGE_SIZE as much as possible). * No longer drops into the debugger if the * The list that is currently used is very inefficient for the features it provides though (no change there). _buffer_id_cache: * Renamed to BufferCache, and put it into the private namespace * It now deletes its buffers on deletion; since the BBufferConsumer will be gone, too, at this point, there is little chance that there are still buffers in use. * Also, it's now using std::map instead of the (see above) Map class. BBuffer: * Got rid of the fBufferID member. Misc.: * Got rid of the global "team" variable; the media kit is now using the private app kit's current_team() now. * Added a lot of missing error checks (mostly memory allocations). * Renamed fields like "flavorid" to flavor_id, renamed "dfi_*" fields to something more detailed. * Moved ServerInterface.h from src/servers/media/ to headers/private/media. * Notifications.h was not self contained. * Added missing licenses. * Lots of cleanups, and coding style fixes. What this doesn't fix: * Bug #4954 which started all this (this comes next, though) * Deinitialization is broken, as the PortPool is uninitialized too early, and still used afterwards. * The strange add-on monitoring code in the media_addon_server git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34500 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-05 14:11:28 +03:00
void Put();
void DeleteGroupAndPut(sem_id groupReclaimSem);
status_t Lock();
status_t Unlock();
status_t AddBuffer(sem_id groupReclaimSem,
BBuffer* buffer);
status_t RequestBuffer(sem_id groupReclaimSem,
int32 buffersInGroup, size_t size,
media_buffer_id wantID, BBuffer** _buffer,
bigtime_t timeout);
status_t RecycleBuffer(BBuffer* buffer);
status_t GetBufferList(sem_id groupReclaimSem,
int32 bufferCount, BBuffer** buffers);
private:
struct _shared_buffer_info {
media_buffer_id id;
BBuffer* buffer;
bool reclaimed;
// The reclaim_sem belonging to the BBufferGroup of this BBuffer
// is also used as a unique identifier of the group
sem_id reclaim_sem;
};
Sorry for this large commit in advance; it's not really possible to divide this into smaller parts: media_addon_server: * Removed (broken) use of (broken and inefficient) home-brewn Map, and List classes. This also fixes a crash on shutdown when used with the malloc_debug implementation. It's using stl::vector, and stl::map now instead. _shared_buffer_list: * Renamed _shared_buffer_list to SharedBufferList, and put it into the BPrivate namespace. Also, made a class out of it. * Separated shared buffer list creation from cloning. * Enlarged maximum number of buffers to something that is not that evil, but actually uses the space it has (ie. is a useful multiple of shared_buffer_info that fills a multiple of B_PAGE_SIZE as much as possible). * No longer drops into the debugger if the * The list that is currently used is very inefficient for the features it provides though (no change there). _buffer_id_cache: * Renamed to BufferCache, and put it into the private namespace * It now deletes its buffers on deletion; since the BBufferConsumer will be gone, too, at this point, there is little chance that there are still buffers in use. * Also, it's now using std::map instead of the (see above) Map class. BBuffer: * Got rid of the fBufferID member. Misc.: * Got rid of the global "team" variable; the media kit is now using the private app kit's current_team() now. * Added a lot of missing error checks (mostly memory allocations). * Renamed fields like "flavorid" to flavor_id, renamed "dfi_*" fields to something more detailed. * Moved ServerInterface.h from src/servers/media/ to headers/private/media. * Notifications.h was not self contained. * Added missing licenses. * Lots of cleanups, and coding style fixes. What this doesn't fix: * Bug #4954 which started all this (this comes next, though) * Deinitialization is broken, as the PortPool is uninitialized too early, and still used afterwards. * The strange add-on monitoring code in the media_addon_server git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34500 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-05 14:11:28 +03:00
enum { kMaxBuffers = 2047 };
// 16 bytes per buffer, 8 pages in total (one entry less for the list)
status_t _Init();
void _RequestBufferInOtherGroups(
sem_id groupReclaimSem, media_buffer_id id);
private:
sem_id fSemaphore;
vint32 fAtom;
_shared_buffer_info fInfos[kMaxBuffers];
int32 fCount;
};
Sorry for this large commit in advance; it's not really possible to divide this into smaller parts: media_addon_server: * Removed (broken) use of (broken and inefficient) home-brewn Map, and List classes. This also fixes a crash on shutdown when used with the malloc_debug implementation. It's using stl::vector, and stl::map now instead. _shared_buffer_list: * Renamed _shared_buffer_list to SharedBufferList, and put it into the BPrivate namespace. Also, made a class out of it. * Separated shared buffer list creation from cloning. * Enlarged maximum number of buffers to something that is not that evil, but actually uses the space it has (ie. is a useful multiple of shared_buffer_info that fills a multiple of B_PAGE_SIZE as much as possible). * No longer drops into the debugger if the * The list that is currently used is very inefficient for the features it provides though (no change there). _buffer_id_cache: * Renamed to BufferCache, and put it into the private namespace * It now deletes its buffers on deletion; since the BBufferConsumer will be gone, too, at this point, there is little chance that there are still buffers in use. * Also, it's now using std::map instead of the (see above) Map class. BBuffer: * Got rid of the fBufferID member. Misc.: * Got rid of the global "team" variable; the media kit is now using the private app kit's current_team() now. * Added a lot of missing error checks (mostly memory allocations). * Renamed fields like "flavorid" to flavor_id, renamed "dfi_*" fields to something more detailed. * Moved ServerInterface.h from src/servers/media/ to headers/private/media. * Notifications.h was not self contained. * Added missing licenses. * Lots of cleanups, and coding style fixes. What this doesn't fix: * Bug #4954 which started all this (this comes next, though) * Deinitialization is broken, as the PortPool is uninitialized too early, and still used afterwards. * The strange add-on monitoring code in the media_addon_server git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34500 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-05 14:11:28 +03:00
} // namespace BPrivate
#endif // _SHARED_BUFFER_LIST_H_