haiku/headers/os/media/Buffer.h

99 lines
1.8 KiB
C
Raw Normal View History

/*
* Copyright 2009, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _BUFFER_H
#define _BUFFER_H
#include <MediaDefs.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 BufferCache;
class SharedBufferList;
}
struct buffer_clone_info {
buffer_clone_info();
~buffer_clone_info();
media_buffer_id buffer;
area_id area;
size_t offset;
size_t size;
int32 flags;
private:
uint32 _reserved_[4];
};
class BBuffer {
public:
// flags
enum {
B_F1_BUFFER = 0x1,
B_F2_BUFFER = 0x2,
B_SMALL_BUFFER = 0x80000000
};
void* Data();
size_t SizeAvailable();
size_t SizeUsed();
void SetSizeUsed(size_t used);
uint32 Flags();
void Recycle();
buffer_clone_info CloneInfo() const;
media_buffer_id ID();
media_type Type();
media_header* Header();
media_audio_header* AudioHeader();
media_video_header* VideoHeader();
size_t Size();
private:
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
friend class BPrivate::BufferCache;
friend class BPrivate::SharedBufferList;
friend class BMediaRoster;
friend class BBufferProducer;
friend class BBufferConsumer;
friend class BBufferGroup;
friend class BSmallBuffer;
explicit BBuffer(const buffer_clone_info& info);
~BBuffer();
BBuffer();
BBuffer(const BBuffer& other);
BBuffer& operator=(const BBuffer& other);
// not implemented
void SetHeader(const media_header* header);
media_header fMediaHeader;
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
BPrivate::SharedBufferList* fBufferList;
area_id fArea;
void* fData;
size_t fOffset;
size_t fSize;
int32 fFlags;
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
uint32 _reserved[12];
};
class BSmallBuffer : public BBuffer {
public:
BSmallBuffer();
static size_t SmallBufferSizeLimit();
};
#endif // _BUFFER_H