2003-04-14 23:31:32 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2002, 2003 Marcus Overhagen <Marcus@Overhagen.de>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files or portions
|
|
|
|
* thereof (the "Software"), to deal in the Software without restriction,
|
|
|
|
* including without limitation the rights to use, copy, modify, merge,
|
|
|
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
|
* and to permit persons to whom the Software is furnished to do so, subject
|
|
|
|
* to the following conditions:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright notice
|
|
|
|
* in the binary, as well as this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided with
|
|
|
|
* the distribution.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
#include <BufferGroup.h>
|
2009-08-05 16:08:47 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
#include <Buffer.h>
|
2009-08-05 16:08:47 +00:00
|
|
|
|
2018-10-23 13:19:14 +00:00
|
|
|
#include "MediaDebug.h"
|
2002-12-08 23:53:51 +00:00
|
|
|
#include "DataExchange.h"
|
2009-08-05 16:08:47 +00:00
|
|
|
#include "SharedBufferList.h"
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
BBufferGroup::BBufferGroup(size_t size, int32 count, uint32 placement,
|
|
|
|
uint32 lock)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
CALLED();
|
2015-04-14 23:09:29 +00:00
|
|
|
fInitError = _Init();
|
|
|
|
if (fInitError != B_OK)
|
2002-07-09 12:24:59 +00:00
|
|
|
return;
|
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 11:11:28 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
// This one is easy. We need to create "count" BBuffers,
|
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 11:11:28 +00:00
|
|
|
// each one "size" bytes large. They all go into one
|
2002-07-09 12:24:59 +00:00
|
|
|
// area, with "placement" and "lock" attributes.
|
|
|
|
// The BBuffers created will clone the area, and
|
|
|
|
// then we delete our area. This way BBuffers are
|
|
|
|
// independent from the BBufferGroup
|
|
|
|
|
|
|
|
// don't allow all placement parameter values
|
|
|
|
if (placement != B_ANY_ADDRESS && placement != B_ANY_KERNEL_ADDRESS) {
|
2009-08-05 16:08:47 +00:00
|
|
|
ERROR("BBufferGroup: placement != B_ANY_ADDRESS "
|
2012-11-30 12:14:44 +00:00
|
|
|
"&& placement != B_ANY_KERNEL_ADDRESS (0x%#" B_PRIx32 ")\n",
|
|
|
|
placement);
|
2002-07-09 12:24:59 +00:00
|
|
|
placement = B_ANY_ADDRESS;
|
|
|
|
}
|
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 11:11:28 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
// first we roundup for a better placement in memory
|
2009-08-05 16:08:47 +00:00
|
|
|
size_t allocSize = (size + 63) & ~63;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
// now we create the area
|
2009-08-05 16:08:47 +00:00
|
|
|
size_t areaSize
|
|
|
|
= ((allocSize * count) + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
|
|
|
|
|
|
|
|
void* startAddress;
|
|
|
|
area_id bufferArea = create_area("some buffers area", &startAddress,
|
2019-08-10 21:55:27 +00:00
|
|
|
placement, areaSize, lock, B_READ_AREA | B_WRITE_AREA | B_CLONEABLE_AREA);
|
2009-08-05 16:08:47 +00:00
|
|
|
if (bufferArea < 0) {
|
|
|
|
ERROR("BBufferGroup: failed to allocate %ld bytes area\n", areaSize);
|
|
|
|
fInitError = (status_t)bufferArea;
|
2002-07-09 12:24:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-08-05 16:08:47 +00:00
|
|
|
|
|
|
|
buffer_clone_info info;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
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 11:11:28 +00:00
|
|
|
for (int32 i = 0; i < count; i++) {
|
2009-08-05 16:08:47 +00:00
|
|
|
info.area = bufferArea;
|
|
|
|
info.offset = i * allocSize;
|
|
|
|
info.size = size;
|
|
|
|
|
|
|
|
fInitError = AddBuffer(info);
|
|
|
|
if (fInitError != B_OK)
|
2002-07-09 12:24:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
delete_area(bufferArea);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
BBufferGroup::BBufferGroup()
|
|
|
|
{
|
|
|
|
CALLED();
|
2015-04-14 23:09:29 +00:00
|
|
|
fInitError = _Init();
|
|
|
|
if (fInitError != B_OK)
|
2002-07-09 12:24:59 +00:00
|
|
|
return;
|
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 11:11:28 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
// this one simply creates an empty BBufferGroup
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
BBufferGroup::BBufferGroup(int32 count, const media_buffer_id* buffers)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
CALLED();
|
2015-04-14 23:09:29 +00:00
|
|
|
fInitError = _Init();
|
|
|
|
if (fInitError != B_OK)
|
2002-07-09 12:24:59 +00:00
|
|
|
return;
|
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 11:11:28 +00:00
|
|
|
|
2015-04-14 23:09:29 +00:00
|
|
|
// This one creates "BBuffer"s from "media_buffer_id"s passed
|
2002-07-09 12:24:59 +00:00
|
|
|
// by the application.
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
buffer_clone_info info;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
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 11:11:28 +00:00
|
|
|
for (int32 i = 0; i < count; i++) {
|
2009-08-05 16:08:47 +00:00
|
|
|
info.buffer = buffers[i];
|
|
|
|
|
|
|
|
fInitError = AddBuffer(info);
|
|
|
|
if (fInitError != B_OK)
|
2002-07-09 12:24:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BBufferGroup::~BBufferGroup()
|
|
|
|
{
|
|
|
|
CALLED();
|
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 11:11:28 +00:00
|
|
|
if (fBufferList != NULL)
|
|
|
|
fBufferList->DeleteGroupAndPut(fReclaimSem);
|
2009-08-05 16:08:47 +00:00
|
|
|
|
|
|
|
delete_sem(fReclaimSem);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
BBufferGroup::InitCheck()
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
return fInitError;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
2009-08-05 16:08:47 +00:00
|
|
|
BBufferGroup::AddBuffer(const buffer_clone_info& info, BBuffer** _buffer)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
if (fInitError != B_OK)
|
|
|
|
return B_NO_INIT;
|
|
|
|
|
2015-04-14 21:29:57 +00:00
|
|
|
status_t status = fBufferList->AddBuffer(fReclaimSem, info, _buffer);
|
2009-08-05 16:08:47 +00:00
|
|
|
if (status != B_OK) {
|
|
|
|
ERROR("BBufferGroup: error when adding buffer\n");
|
|
|
|
return status;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
2009-08-05 16:08:47 +00:00
|
|
|
atomic_add(&fBufferCount, 1);
|
2002-07-09 12:24:59 +00:00
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
BBuffer*
|
|
|
|
BBufferGroup::RequestBuffer(size_t size, bigtime_t timeout)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
if (fInitError != B_OK)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (size <= 0)
|
|
|
|
return NULL;
|
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 11:11:28 +00:00
|
|
|
|
2015-04-14 23:09:29 +00:00
|
|
|
BBuffer *buffer = NULL;
|
|
|
|
fRequestError = fBufferList->RequestBuffer(fReclaimSem, fBufferCount,
|
|
|
|
size, 0, &buffer, timeout);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2015-04-14 23:09:29 +00:00
|
|
|
return fRequestError == B_OK ? buffer : NULL;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
2009-08-05 16:08:47 +00:00
|
|
|
BBufferGroup::RequestBuffer(BBuffer* buffer, bigtime_t timeout)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
if (fInitError != B_OK)
|
|
|
|
return B_NO_INIT;
|
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 11:11:28 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
if (buffer == NULL)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
|
2015-04-14 23:09:29 +00:00
|
|
|
fRequestError = fBufferList->RequestBuffer(fReclaimSem, fBufferCount, 0, 0,
|
2009-08-05 16:08:47 +00:00
|
|
|
&buffer, timeout);
|
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 11:11:28 +00:00
|
|
|
|
2015-04-14 23:09:29 +00:00
|
|
|
return fRequestError;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
BBufferGroup::RequestError()
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
if (fInitError != B_OK)
|
|
|
|
return B_NO_INIT;
|
|
|
|
|
|
|
|
return fRequestError;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
2009-08-05 16:08:47 +00:00
|
|
|
BBufferGroup::CountBuffers(int32* _count)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
if (fInitError != B_OK)
|
|
|
|
return B_NO_INIT;
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
*_count = fBufferCount;
|
2002-07-09 12:24:59 +00:00
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
2009-08-05 16:08:47 +00:00
|
|
|
BBufferGroup::GetBufferList(int32 bufferCount, BBuffer** _buffers)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
if (fInitError != B_OK)
|
|
|
|
return B_NO_INIT;
|
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 11:11:28 +00:00
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
if (bufferCount <= 0 || bufferCount > fBufferCount)
|
2002-07-09 12:24:59 +00:00
|
|
|
return B_BAD_VALUE;
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
return fBufferList->GetBufferList(fReclaimSem, bufferCount, _buffers);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
BBufferGroup::WaitForBuffers()
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
if (fInitError != B_OK)
|
|
|
|
return B_NO_INIT;
|
|
|
|
|
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 11:11:28 +00:00
|
|
|
// TODO: this function is not really useful anyway, and will
|
2009-08-05 16:08:47 +00:00
|
|
|
// not work exactly as documented, but it is close enough
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
if (fBufferCount < 0)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (fBufferCount == 0)
|
|
|
|
return B_OK;
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
// We need to wait until at least one buffer belonging to this group is
|
|
|
|
// reclaimed.
|
|
|
|
// This has happened when can aquire "fReclaimSem"
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
status_t status;
|
2009-08-05 16:08:47 +00:00
|
|
|
while ((status = acquire_sem(fReclaimSem)) == B_INTERRUPTED)
|
2002-07-09 12:24:59 +00:00
|
|
|
;
|
2009-08-05 16:08:47 +00:00
|
|
|
if (status != B_OK)
|
2002-07-09 12:24:59 +00:00
|
|
|
return status;
|
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 11:11:28 +00:00
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
// we need to release the "fReclaimSem" now, else we would block
|
|
|
|
// requesting of new buffers
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
return release_sem(fReclaimSem);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
BBufferGroup::ReclaimAllBuffers()
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
if (fInitError != B_OK)
|
|
|
|
return B_NO_INIT;
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
// because additional BBuffers might get added to this group betweeen
|
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 11:11:28 +00:00
|
|
|
// acquire and release
|
2002-07-09 12:24:59 +00:00
|
|
|
int32 count = fBufferCount;
|
|
|
|
|
|
|
|
if (count < 0)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (count == 0)
|
|
|
|
return B_OK;
|
|
|
|
|
|
|
|
// we need to wait until all BBuffers belonging to this group are reclaimed.
|
2009-08-05 16:08:47 +00:00
|
|
|
// this has happened when the "fReclaimSem" can be aquired "fBufferCount"
|
|
|
|
// times
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2015-09-21 12:49:39 +00:00
|
|
|
status_t status = B_ERROR;
|
2009-08-05 16:08:47 +00:00
|
|
|
do {
|
2015-09-21 12:49:39 +00:00
|
|
|
status = acquire_sem_etc(fReclaimSem, count, B_RELATIVE_TIMEOUT, 0);
|
2009-08-05 16:08:47 +00:00
|
|
|
} while (status == B_INTERRUPTED);
|
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 11:11:28 +00:00
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
if (status != B_OK)
|
2002-07-09 12:24:59 +00:00
|
|
|
return status;
|
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 11:11:28 +00:00
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
// we need to release the "fReclaimSem" now, else we would block
|
|
|
|
// requesting of new buffers
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
return release_sem_etc(fReclaimSem, count, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
// #pragma mark - deprecated BeOS R4 API
|
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
status_t
|
2009-08-05 16:08:47 +00:00
|
|
|
BBufferGroup::AddBuffersTo(BMessage* message, const char* name, bool needLock)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
if (fInitError != B_OK)
|
|
|
|
return B_NO_INIT;
|
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 11:11:28 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
// BeOS R4 legacy API. Implemented as a wrapper around GetBufferList
|
|
|
|
// "needLock" is ignored, GetBufferList will do locking
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
|
|
|
|
if (name == NULL || strlen(name) == 0)
|
|
|
|
return B_BAD_VALUE;
|
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 11:11:28 +00:00
|
|
|
|
2015-04-14 21:29:29 +00:00
|
|
|
BBuffer* buffers[fBufferCount];
|
|
|
|
status_t status = GetBufferList(fBufferCount, buffers);
|
2009-08-05 16:08:47 +00:00
|
|
|
if (status != B_OK)
|
2015-04-14 21:29:29 +00:00
|
|
|
return status;
|
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 11:11:28 +00:00
|
|
|
|
2015-04-14 21:29:29 +00:00
|
|
|
for (int32 i = 0; i < fBufferCount; i++) {
|
2009-08-05 16:08:47 +00:00
|
|
|
status = message->AddInt32(name, int32(buffers[i]->ID()));
|
|
|
|
if (status != B_OK)
|
2015-04-14 21:29:29 +00:00
|
|
|
return status;
|
2009-08-05 16:08:47 +00:00
|
|
|
}
|
|
|
|
|
2015-04-14 21:29:29 +00:00
|
|
|
return B_OK;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
|
|
|
|
// #pragma mark - private methods
|
|
|
|
|
|
|
|
|
|
|
|
/* not implemented */
|
|
|
|
//BBufferGroup::BBufferGroup(const BBufferGroup &)
|
|
|
|
//BBufferGroup & BBufferGroup::operator=(const BBufferGroup &)
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
BBufferGroup::_Init()
|
|
|
|
{
|
|
|
|
CALLED();
|
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 11:11:28 +00:00
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
// some defaults in case we drop out early
|
2015-04-14 23:09:29 +00:00
|
|
|
fBufferList = NULL;
|
2009-08-05 16:08:47 +00:00
|
|
|
fRequestError = B_ERROR;
|
|
|
|
fBufferCount = 0;
|
|
|
|
|
|
|
|
// Create the reclaim semaphore
|
|
|
|
// This is also used as a system wide unique identifier for this group
|
|
|
|
fReclaimSem = create_sem(0, "buffer reclaim sem");
|
2015-04-14 23:09:29 +00:00
|
|
|
if (fReclaimSem < 0) {
|
2009-08-05 16:08:47 +00:00
|
|
|
ERROR("BBufferGroup::InitBufferGroup: couldn't create fReclaimSem\n");
|
2015-04-14 23:09:29 +00:00
|
|
|
return (status_t)fReclaimSem;
|
2009-08-05 16:08:47 +00:00
|
|
|
}
|
|
|
|
|
2009-12-05 11:52:01 +00:00
|
|
|
fBufferList = BPrivate::SharedBufferList::Get();
|
2009-08-05 16:08:47 +00:00
|
|
|
if (fBufferList == NULL) {
|
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 11:11:28 +00:00
|
|
|
ERROR("BBufferGroup::InitBufferGroup: SharedBufferList::Get() "
|
2009-08-05 16:08:47 +00:00
|
|
|
"failed\n");
|
2015-04-14 23:09:29 +00:00
|
|
|
return B_ERROR;
|
2009-08-05 16:08:47 +00:00
|
|
|
}
|
|
|
|
|
2015-04-14 23:09:29 +00:00
|
|
|
return B_OK;
|
2009-08-05 16:08:47 +00:00
|
|
|
}
|
|
|
|
|