changed map and list templates to be more useable, however, they will

be rewritten soon. Changed debugging macros and use of them, too.
Also replaced the linked lists in the BufferManager (which were complicated,
but working ok) with template based ones.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2133 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2002-12-03 00:59:42 +00:00
parent 68bb610bbc
commit 353b9f6bce
26 changed files with 297 additions and 253 deletions
+23 -1
View File
@@ -5,7 +5,16 @@ template<class value> class List
{
public:
List() : count(0) {}
List(const List<value> &other)
{
printf("template<class value> class List copy constructor\n");
count = other.count;
for (int i = 0; i < count; i++)
list[i] = other.list[i];
hmpt;
}
void Insert(const value &v)
{
value temp;
@@ -42,6 +51,19 @@ public:
return true;
}
int Find(const value &v)
{
for (int i = 0; i < count; i++)
if (list[i] == v)
return i;
return -1;
}
bool IsEmpty()
{
return count == 0;
}
void MakeEmpty()
{
count = 0;
+15
View File
@@ -6,6 +6,16 @@ template<class key, class value> class Map
public:
Map() : count(0) {}
Map(const Map<key, value> &other)
{
printf("template<class key, class value> class Map copy constructor\n");
count = other.count;
for (int i = 0; i < count; i++) {
list[i].v = other.list[i].v;
list[i].k = other.list[i].k;
}
}
bool Insert(const key &k, const value &v)
{
value temp;
@@ -70,6 +80,11 @@ public:
return false;
}
bool IsEmpty()
{
return count == 0;
}
private:
enum { MAXENT = 64 };
struct ent {
+23 -13
View File
@@ -1,40 +1,50 @@
#ifndef _MEDIA_DEBUG_H_
#define _MEDIA_DEBUG_H_
#include <Debug.h>
#include <stdio.h>
#undef TRACE
#ifndef DEBUG
#define DEBUG 0
#endif
#ifndef NDEBUG
#ifndef DEBUG
#define DEBUG 2
#endif
#if DEBUG >= 1
#define UNIMPLEMENTED() printf("libmedia.so: UNIMPLEMENTED %s\n",__PRETTY_FUNCTION__)
#define UNIMPLEMENTED() printf("UNIMPLEMENTED %s\n",__PRETTY_FUNCTION__)
#define FATAL printf
#else
#define UNIMPLEMENTED() ((void)0)
#define FATAL if (1) {} else printf
#endif
#if DEBUG >= 2
#define BROKEN() printf("libmedia.so: BROKEN %s\n",__PRETTY_FUNCTION__)
#define BROKEN() printf("BROKEN %s\n",__PRETTY_FUNCTION__)
#define TRACE printf
#else
#define BROKEN() ((void)0)
#define TRACE if (1) {} else printf
#endif
#if DEBUG >= 3
#define CALLED() printf("libmedia.so: CALLED %s\n",__PRETTY_FUNCTION__)
#define CALLED() printf("CALLED %s\n",__PRETTY_FUNCTION__)
#define INFO printf
#else
#define CALLED() ((void)0)
#define INFO if (1) {} else printf
#endif
#undef TRACE
#define TRACE \
printf
#else
#define UNIMPLEMENTED() ((void)0)
#define BROKEN() ((void)0)
#define CALLED() ((void)0)
#define TRACE \
if (1) {} else printf
#define FATAL if (1) {} else printf
#define TRACE if (1) {} else printf
#define INFO if (1) {} else printf
#endif
#endif /* _MEDIA_DEBUG_H_ */
+1 -1
View File
@@ -217,7 +217,7 @@ BBuffer::BBuffer(const buffer_clone_info & info) :
fArea = clone_area("a cloned BBuffer", &fData, B_ANY_ADDRESS,B_READ_AREA | B_WRITE_AREA,id);
if (fArea <= B_OK) {
TRACE("buffer cloning failed\n");
FATAL("BBuffer::BBuffer: buffer cloning failed\n");
fData = 0;
return;
}
+1 -2
View File
@@ -8,7 +8,6 @@
#include <BufferGroup.h>
#include <Buffer.h>
#include <malloc.h>
#define DEBUG 3
#include "debug.h"
#include "DataExchange.h"
#include "BufferIdCache.h"
@@ -328,7 +327,7 @@ BBufferConsumer::HandleMessage(int32 message,
const void *data,
size_t size)
{
TRACE("BBufferConsumer::HandleMessage %#lx, node %ld\n", message, ID());
INFO("BBufferConsumer::HandleMessage %#lx, node %ld\n", message, ID());
status_t rv;
switch (message) {
case CONSUMER_ACCEPT_FORMAT:
+8 -8
View File
@@ -80,7 +80,7 @@ BBufferGroup::BBufferGroup(size_t size,
// don't allow all placement parameter values
if (placement != B_ANY_ADDRESS && placement != B_ANY_KERNEL_ADDRESS) {
TRACE("placement != B_ANY_ADDRESS && placement != B_ANY_KERNEL_ADDRESS (0x%08lx)\n",placement);
FATAL("BBufferGroup: placement != B_ANY_ADDRESS && placement != B_ANY_KERNEL_ADDRESS (0x%08lx)\n",placement);
placement = B_ANY_ADDRESS;
}
@@ -92,7 +92,7 @@ BBufferGroup::BBufferGroup(size_t size,
buffer_area = create_area("some buffers area", &start_addr,placement,area_size,lock,B_READ_AREA | B_WRITE_AREA);
if (buffer_area < B_OK) {
TRACE("failed to allocate %ld bytes area\n",area_size);
FATAL("BBufferGroup: failed to allocate %ld bytes area\n",area_size);
fInitError = (status_t)buffer_area;
return;
}
@@ -106,13 +106,13 @@ BBufferGroup::BBufferGroup(size_t size,
buffer = new BBuffer(bci);
if (0 == buffer->Data()) {
// BBuffer::Data() will return 0 if an error occured
TRACE("error while creating buffer\n");
FATAL("BBufferGroup: error while creating buffer\n");
delete buffer;
fInitError = B_ERROR;
break;
}
if (B_OK != fBufferList->AddBuffer(fReclaimSem,buffer)) {
TRACE("error when adding buffer\n");
FATAL("BBufferGroup: error when adding buffer\n");
delete buffer;
fInitError = B_ERROR;
break;
@@ -154,13 +154,13 @@ BBufferGroup::BBufferGroup(int32 count,
buffer = new BBuffer(bci);
if (0 == buffer->Data()) {
// BBuffer::Data() will return 0 if an error occured
TRACE("error while creating buffer\n");
FATAL("BBufferGroup(2): error while creating buffer\n");
delete buffer;
fInitError = B_ERROR;
break;
}
if (B_OK != fBufferList->AddBuffer(fReclaimSem,buffer)) {
TRACE("error when adding buffer\n");
FATAL("BBufferGroup(2): error when adding buffer\n");
delete buffer;
fInitError = B_ERROR;
break;
@@ -201,12 +201,12 @@ BBufferGroup::AddBuffer(const buffer_clone_info &info,
buffer = new BBuffer(info);
if (0 == buffer->Data()) {
// BBuffer::Data() will return 0 if an error occured
TRACE("error while creating buffer\n");
FATAL("BBufferGroup::AddBuffer: error while creating buffer\n");
delete buffer;
return B_ERROR;
}
if (B_OK != fBufferList->AddBuffer(fReclaimSem,buffer)) {
TRACE("error when adding buffer\n");
FATAL("BBufferGroup::AddBuffer: error when adding buffer\n");
delete buffer;
fInitError = B_ERROR;
return B_ERROR;
+1 -2
View File
@@ -6,7 +6,6 @@
#include <BufferProducer.h>
#include <BufferGroup.h>
#include <Buffer.h>
#define DEBUG 3
#include "debug.h"
#include "DataExchange.h"
@@ -102,7 +101,7 @@ BBufferProducer::HandleMessage(int32 message,
const void *data,
size_t size)
{
TRACE("BBufferProducer::HandleMessage %#lx, node %ld\n", message, fNodeID);
INFO("BBufferProducer::HandleMessage %#lx, node %ld\n", message, fNodeID);
status_t rv;
switch (message) {
+1 -1
View File
@@ -98,7 +98,7 @@ BControllable::HandleMessage(int32 message,
const void *data,
size_t size)
{
TRACE("BControllable::HandleMessage %#lx, node %ld\n", message, ID());
INFO("BControllable::HandleMessage %#lx, node %ld\n", message, ID());
return B_ERROR;
}
+5 -5
View File
@@ -60,7 +60,7 @@ status_t SendToServer(BMessage *msg)
status_t rv;
rv = MediaServerMessenger->SendMessage(msg, static_cast<BHandler *>(NULL), TIMEOUT);
if (rv != B_OK)
TRACE("SendToServer: SendMessage failed\n");
FATAL("SendToServer: SendMessage failed\n");
return rv;
}
@@ -70,7 +70,7 @@ status_t QueryServer(BMessage *request, BMessage *reply)
status_t rv;
rv = MediaServerMessenger->SendMessage(request, reply, TIMEOUT, TIMEOUT);
if (rv != B_OK)
TRACE("QueryServer: SendMessage failed\n");
FATAL("QueryServer: SendMessage failed\n");
return rv;
}
@@ -106,7 +106,7 @@ status_t SendToPort(port_id sendport, int32 msgcode, command_data *msg, int size
status_t rv;
rv = write_port_etc(sendport, msgcode, msg, size, B_RELATIVE_TIMEOUT, TIMEOUT);
if (rv != B_OK)
TRACE("SendToPort: write_port failed, port %ld, error %#lx (%s)\n", sendport, rv, strerror(rv));
FATAL("SendToPort: write_port failed, port %ld, error %#lx (%s)\n", sendport, rv, strerror(rv));
return B_OK;
}
@@ -120,7 +120,7 @@ status_t QueryPort(port_id requestport, int32 msgcode, request_data *request, in
rv = write_port_etc(requestport, msgcode, request, requestsize, B_RELATIVE_TIMEOUT, TIMEOUT);
if (rv != B_OK) {
TRACE("QueryPort: write_port failed, port %ld, error %#lx (%s)\n", requestport, rv, strerror(rv));
FATAL("QueryPort: write_port failed, port %ld, error %#lx (%s)\n", requestport, rv, strerror(rv));
_PortPool->PutPort(request->reply_port);
return rv;
}
@@ -129,7 +129,7 @@ status_t QueryPort(port_id requestport, int32 msgcode, request_data *request, in
_PortPool->PutPort(request->reply_port);
if (rv < B_OK)
TRACE("QueryPort: read_port failed, port %ld, error %#lx (%s)\n", request->reply_port, rv, strerror(rv));
FATAL("QueryPort: read_port failed, port %ld, error %#lx (%s)\n", request->reply_port, rv, strerror(rv));
return (rv < B_OK) ? rv : reply->result;
}
+25 -19
View File
@@ -26,7 +26,6 @@
#include <Path.h>
#include <Entry.h>
#include <MediaAddOn.h>
#include <Debug.h>
#include "debug.h"
#include "PortPool.h"
#include "ServerInterface.h"
@@ -53,7 +52,7 @@ DormantNodeManager::~DormantNodeManager()
// force unloading all currently loaded images
loaded_addon_info *info;
for (int32 index = 0; fAddonmap->GetPointerAt(index,&info); index++) {
printf("Forcing unload of add-on id %ld with usecount %ld\n",info->addon->AddonID(), info->usecount);
FATAL("Forcing unload of add-on id %ld with usecount %ld\n",info->addon->AddonID(), info->usecount);
UnloadAddon(info->addon, info->image);
}
@@ -85,7 +84,7 @@ DormantNodeManager::GetAddon(media_addon_id id)
{
BMediaAddOn *addon;
printf("DormantNodeManager::GetAddon, id %ld\n",id);
TRACE("DormantNodeManager::GetAddon, id %ld\n",id);
// first try to use a already loaded add-on
addon = TryGetAddon(id);
@@ -97,7 +96,7 @@ DormantNodeManager::GetAddon(media_addon_id id)
// ok, it's not loaded, try to get the path
BPath path;
if (B_OK != FindAddonPath(&path, id)) {
printf("DormantNodeManager::GetAddon: can't find path for add-on %ld\n",id);
FATAL("DormantNodeManager::GetAddon: can't find path for add-on %ld\n",id);
return NULL;
}
@@ -105,7 +104,7 @@ DormantNodeManager::GetAddon(media_addon_id id)
BMediaAddOn *newaddon;
image_id image;
if (B_OK != LoadAddon(&newaddon, &image, path.Path(), id)) {
printf("DormantNodeManager::GetAddon: can't load add-on %ld from path %s\n",id, path.Path());
FATAL("DormantNodeManager::GetAddon: can't load add-on %ld from path %s\n",id, path.Path());
return NULL;
}
@@ -127,7 +126,7 @@ DormantNodeManager::GetAddon(media_addon_id id)
fAddonmap->Insert(id, info);
}
fLock->Unlock();
ASSERT(addon->Addon() == id);
ASSERT(addon->AddonID() == id);
return addon;
}
@@ -140,11 +139,11 @@ DormantNodeManager::PutAddon(media_addon_id id)
image_id image = 0; /* avoid compiler warning */
bool unload;
printf("DormantNodeManager::PutAddon, id %ld\n",id);
TRACE("DormantNodeManager::PutAddon, id %ld\n",id);
fLock->Lock();
if (!fAddonmap->GetPointer(id, &info)) {
printf("DormantNodeManager::PutAddon: failed to find add-on %ld\n",id);
FATAL("DormantNodeManager::PutAddon: failed to find add-on %ld\n",id);
fLock->Unlock();
return;
}
@@ -172,27 +171,34 @@ DormantNodeManager::RegisterAddon(const char *path)
int32 code;
entry_ref tempref;
printf("DormantNodeManager::RegisterAddon, path %s\n",path);
TRACE("DormantNodeManager::RegisterAddon, path %s\n",path);
rv = get_ref_for_path(path, &tempref);
if (rv != B_OK)
if (rv != B_OK) {
FATAL("DormantNodeManager::RegisterAddon failed, couldn't get ref for path %s\n",path);
return 0;
}
msg.ref = tempref;
port = find_port("media_server port");
if (port <= B_OK)
if (port <= B_OK) {
FATAL("DormantNodeManager::RegisterAddon failed, couldn't find media server\n");
return 0;
}
msg.reply_port = _PortPool->GetPort();
rv = write_port(port, SERVER_REGISTER_MEDIAADDON, &msg, sizeof(msg));
if (rv != B_OK) {
_PortPool->PutPort(msg.reply_port);
FATAL("DormantNodeManager::RegisterAddon failed, couldn't talk to media server\n");
return 0;
}
rv = read_port(msg.reply_port, &code, &reply, sizeof(reply));
_PortPool->PutPort(msg.reply_port);
if (rv < B_OK)
if (rv < B_OK) {
FATAL("DormantNodeManager::RegisterAddon failed, couldn't talk to media server (2)\n");
return 0;
}
printf("DormantNodeManager::RegisterAddon finished with id %ld\n",reply.addonid);
TRACE("DormantNodeManager::RegisterAddon finished with id %ld\n",reply.addonid);
return reply.addonid;
}
@@ -204,7 +210,7 @@ DormantNodeManager::UnregisterAddon(media_addon_id id)
ASSERT(id > 0);
server_unregister_mediaaddon_command msg;
printf("DormantNodeManager::UnregisterAddon id %ld\n",id);
TRACE("DormantNodeManager::UnregisterAddon id %ld\n",id);
port_id port;
port = find_port("media_server port");
@@ -254,25 +260,25 @@ DormantNodeManager::LoadAddon(BMediaAddOn **newaddon, image_id *newimage, const
image = load_add_on(path);
if (image < B_OK) {
printf("DormantNodeManager::LoadAddon: loading failed %lx %s\n", image, strerror(image));
FATAL("DormantNodeManager::LoadAddon: loading failed %lx (%s), path %s\n", image, strerror(image), path);
return B_ERROR;
}
rv = get_image_symbol(image, "make_media_addon", B_SYMBOL_TYPE_TEXT, (void**)&make_addon);
if (rv < B_OK) {
printf("DormantNodeManager::LoadAddon: loading failed, function not found %lx %s\n", rv, strerror(rv));
FATAL("DormantNodeManager::LoadAddon: loading failed, function not found %lx %s\n", rv, strerror(rv));
unload_add_on(image);
return B_ERROR;
}
addon = make_addon(image);
if (addon == 0) {
printf("DormantNodeManager::LoadAddon: creating BMediaAddOn failed\n");
FATAL("DormantNodeManager::LoadAddon: creating BMediaAddOn failed\n");
unload_add_on(image);
return B_ERROR;
}
ASSERT(addon->Image() == image); // this should be true for a well behaving add-on
ASSERT(addon->ImageID() == image); // this should be true for a well behaving add-on
// everything ok
*newaddon = addon;
@@ -290,7 +296,7 @@ void
DormantNodeManager::UnloadAddon(BMediaAddOn *addon, image_id image)
{
ASSERT(addon);
ASSERT(addon->Image() == image); // if this failes, something bad happened to the add-on
ASSERT(addon->ImageID() == image); // if this failes, something bad happened to the add-on
delete addon;
unload_add_on(image);
}
+1 -2
View File
@@ -4,7 +4,6 @@
* DESCR:
***********************************************************************/
#include <FileInterface.h>
#define DEBUG 3
#include "debug.h"
/*************************************************************
@@ -40,7 +39,7 @@ BFileInterface::HandleMessage(int32 message,
const void *data,
size_t size)
{
TRACE("BFileInterface::HandleMessage %#lx, node %ld\n", message, ID());
INFO("BFileInterface::HandleMessage %#lx, node %ld\n", message, ID());
return B_OK;
}
-1
View File
@@ -6,7 +6,6 @@
#include <MediaAddOn.h>
#include <string.h>
#include <malloc.h>
#define DEBUG 3
#include "debug.h"
#include "DataExchange.h"
+12 -15
View File
@@ -11,8 +11,6 @@
#include <Controllable.h>
#include <FileInterface.h>
#include <string.h>
#define DEBUG 3
#include <Debug.h>
#include "debug.h"
#include "DataExchange.h"
#include "SystemTimeSource.h"
@@ -131,7 +129,7 @@ BMediaNode::Release()
CALLED();
if (atomic_add(&fRefCount,-1) == 1) {
if (DeleteHook(this) != B_OK) {
TRACE("BMediaNode::Release(): DeleteHook failed\n");
FATAL("BMediaNode::Release(): DeleteHook failed\n");
return Acquire();
}
return NULL;
@@ -224,7 +222,7 @@ BMediaNode::ReportError(node_error what,
case BMediaNode::B_NODE_IN_DISTRESS:
break;
default:
TRACE("BMediaNode::ReportError: invalid what!\n");
FATAL("BMediaNode::ReportError: invalid what!\n");
return B_BAD_VALUE;
}
@@ -291,14 +289,14 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil,
size = read_port_etc(fControlPort, &message, data, sizeof(data), B_ABSOLUTE_TIMEOUT, waitUntil);
if (size <= 0) {
if (size != B_TIMED_OUT)
TRACE("BMediaNode::WaitForMessage: read_port_etc error 0x%08lx\n",size);
FATAL("BMediaNode::WaitForMessage: read_port_etc error 0x%08lx\n",size);
return size; // returns the error code
}
TRACE("BMediaNode::WaitForMessage %#lx, node %ld, this %p\n", message, fNodeID, this);
if (message > NODE_MESSAGE_START && message < NODE_MESSAGE_END) {
TRACE("BMediaNode::WaitForMessage calling BMediaNode\n");
INFO("BMediaNode::WaitForMessage calling BMediaNode\n");
if (B_OK == BMediaNode::HandleMessage(message, data, size))
return B_OK;
}
@@ -306,7 +304,7 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil,
if (message > PRODUCER_MESSAGE_START && message < PRODUCER_MESSAGE_END) {
if (!fProducerThis)
fProducerThis = dynamic_cast<BBufferProducer *>(this);
TRACE("BMediaNode::WaitForMessage calling BBufferProducer %p\n", fProducerThis);
INFO("BMediaNode::WaitForMessage calling BBufferProducer %p\n", fProducerThis);
if (fProducerThis && B_OK == fProducerThis->BBufferProducer::HandleMessage(message, data, size))
return B_OK;
}
@@ -314,7 +312,7 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil,
if (message > CONSUMER_MESSAGE_START && message < CONSUMER_MESSAGE_END) {
if (!fConsumerThis)
fConsumerThis = dynamic_cast<BBufferConsumer *>(this);
TRACE("BMediaNode::WaitForMessage calling BBufferConsumer %p\n", fConsumerThis);
INFO("BMediaNode::WaitForMessage calling BBufferConsumer %p\n", fConsumerThis);
if (fConsumerThis && B_OK == fConsumerThis->BBufferConsumer::HandleMessage(message, data, size))
return B_OK;
}
@@ -322,7 +320,7 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil,
if (message > FILEINTERFACE_MESSAGE_START && message < FILEINTERFACE_MESSAGE_END) {
if (!fFileInterfaceThis)
fFileInterfaceThis = dynamic_cast<BFileInterface *>(this);
TRACE("BMediaNode::WaitForMessage calling BFileInterface %p\n", fFileInterfaceThis);
INFO("BMediaNode::WaitForMessage calling BFileInterface %p\n", fFileInterfaceThis);
if (fFileInterfaceThis && B_OK == fFileInterfaceThis->BFileInterface::HandleMessage(message, data, size))
return B_OK;
}
@@ -330,7 +328,7 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil,
if (message > CONTROLLABLE_MESSAGE_START && message < CONTROLLABLE_MESSAGE_END) {
if (!fControllableThis)
fControllableThis = dynamic_cast<BControllable *>(this);
TRACE("BMediaNode::WaitForMessage calling BControllable %p\n", fControllableThis);
INFO("BMediaNode::WaitForMessage calling BControllable %p\n", fControllableThis);
if (fControllableThis && B_OK == fControllableThis->BControllable::HandleMessage(message, data, size))
return B_OK;
}
@@ -338,12 +336,12 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil,
if (message > TIMESOURECE_MESSAGE_START && message < TIMESOURECE_MESSAGE_END) {
if (!fTimeSourceThis)
fTimeSourceThis = dynamic_cast<BTimeSource *>(this);
TRACE("BMediaNode::WaitForMessage calling BTimeSource %p\n", fTimeSourceThis);
INFO("BMediaNode::WaitForMessage calling BTimeSource %p\n", fTimeSourceThis);
if (fTimeSourceThis && B_OK == fTimeSourceThis->BTimeSource::HandleMessage(message, data, size))
return B_OK;
}
TRACE("BMediaNode::WaitForMessage calling default\n");
INFO("BMediaNode::WaitForMessage calling default\n");
if (B_OK == HandleMessage(message, data, size))
return B_OK;
@@ -461,8 +459,7 @@ BMediaNode::HandleMessage(int32 message,
const void *data,
size_t size)
{
// CALLED();
TRACE("BMediaNode::HandleMessage %#lx, node %ld\n", message, fNodeID);
INFO("BMediaNode::HandleMessage %#lx, node %ld\n", message, fNodeID);
switch (message) {
case NODE_START:
{
@@ -541,7 +538,7 @@ BMediaNode::HandleBadMessage(int32 code,
TRACE("BMediaNode::HandleBadMessage: code %#08lx, buffer %p, size %ld\n", code, buffer, size);
if (code < NODE_MESSAGE_START || code > TIMESOURECE_MESSAGE_END) {
TRACE("BMediaNode::HandleBadMessage: unknown code!\n");
FATAL("BMediaNode::HandleBadMessage: unknown code!\n");
} else {
/* All messages targeted to nodes should be handled here,
* messages targetted to the wrong node should be handled
+35 -37
View File
@@ -11,8 +11,6 @@
#include <OS.h>
#include <String.h>
#include <TimeSource.h>
#define DEBUG 3
#include <Debug.h>
#include "debug.h"
#include "TStack.h"
#include "PortPool.h"
@@ -114,7 +112,7 @@ GetAllOutputs(const media_node & node, Stack<media_output> *stack)
break;
cookie = reply.cookie;
if (!stack->Push(reply.output)) {
TRACE("GetAllOutputs: stack->Push failed\n");
FATAL("GetAllOutputs: stack->Push failed\n");
result = B_ERROR;
}
}
@@ -144,7 +142,7 @@ GetAllInputs(const media_node & node, Stack<media_input> *stack)
break;
cookie = reply.cookie;
if (!stack->Push(reply.input)) {
TRACE("GetAllInputs: stack->Push failed\n");
FATAL("GetAllInputs: stack->Push failed\n");
result = B_ERROR;
}
}
@@ -177,7 +175,7 @@ PublishOutputs(const media_node & node, Stack<media_output> *stack)
size = ((count * sizeof(media_output)) + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
request.area = create_area("publish outputs", &start_addr, B_ANY_ADDRESS, size, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
if (request.area < B_OK) {
TRACE("PublishOutputs: failed to create area, %#lx\n", request.area);
FATAL("PublishOutputs: failed to create area, %#lx\n", request.area);
return (status_t)request.area;
}
outputs = static_cast<media_output *>(start_addr);
@@ -221,7 +219,7 @@ PublishInputs(const media_node & node, Stack<media_input> *stack)
size = ((count * sizeof(media_input)) + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
request.area = create_area("publish inputs", &start_addr, B_ANY_ADDRESS, size, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
if (request.area < B_OK) {
TRACE("PublishInputs: failed to create area, %#lx\n", request.area);
FATAL("PublishInputs: failed to create area, %#lx\n", request.area);
return (status_t)request.area;
}
inputs = static_cast<media_input *>(start_addr);
@@ -465,11 +463,11 @@ BMediaRoster::Connect(const media_source & from,
if (io_format == NULL || out_output == NULL || out_input == NULL)
return B_BAD_VALUE;
if (from == media_source::null) {
TRACE("BMediaRoster::Connect: media_source invalid\n");
FATAL("BMediaRoster::Connect: media_source invalid\n");
return B_MEDIA_BAD_SOURCE;
}
if (to == media_destination::null) {
TRACE("BMediaRoster::Connect: media_destination invalid\n");
FATAL("BMediaRoster::Connect: media_destination invalid\n");
return B_MEDIA_BAD_DESTINATION;
}
@@ -482,7 +480,7 @@ BMediaRoster::Connect(const media_source & from,
request1.format = *io_format;
rv = QueryPort(from.port, PRODUCER_FORMAT_PROPOSAL, &request1, sizeof(request1), &reply1, sizeof(reply1));
if (rv != B_OK) {
TRACE("BMediaRoster::Connect: aborted after BBufferProducer::FormatProposal, status = %#lx\n",rv);
FATAL("BMediaRoster::Connect: aborted after BBufferProducer::FormatProposal, status = %#lx\n",rv);
return rv;
}
// reply1.format now contains the format proposed by the producer
@@ -495,7 +493,7 @@ BMediaRoster::Connect(const media_source & from,
request2.format = reply1.format;
rv = QueryPort(to.port, CONSUMER_ACCEPT_FORMAT, &request2, sizeof(request2), &reply2, sizeof(reply2));
if (rv != B_OK) {
TRACE("BMediaRoster::Connect: aborted after BBufferConsumer::AcceptFormat, status = %#lx\n",rv);
FATAL("BMediaRoster::Connect: aborted after BBufferConsumer::AcceptFormat, status = %#lx\n",rv);
return rv;
}
// reply2.format now contains the format accepted by the consumer
@@ -510,7 +508,7 @@ BMediaRoster::Connect(const media_source & from,
strcpy(request3.name, "XXX some default name"); // XXX fix this
rv = QueryPort(from.port, PRODUCER_PREPARE_TO_CONNECT, &request3, sizeof(request3), &reply3, sizeof(reply3));
if (rv != B_OK) {
TRACE("BMediaRoster::Connect: aborted after BBufferProducer::PrepareToConnect, status = %#lx\n",rv);
FATAL("BMediaRoster::Connect: aborted after BBufferProducer::PrepareToConnect, status = %#lx\n",rv);
return rv;
}
// reply3.format is still our pretty media format
@@ -527,7 +525,7 @@ BMediaRoster::Connect(const media_source & from,
request4.with_format = reply3.format;
con_status = QueryPort(to.port, CONSUMER_CONNECTED, &request4, sizeof(request4), &reply4, sizeof(reply4));
if (con_status != B_OK) {
TRACE("BMediaRoster::Connect: aborting after BBufferConsumer::Connected, status = %#lx\n",con_status);
FATAL("BMediaRoster::Connect: aborting after BBufferConsumer::Connected, status = %#lx\n",con_status);
// we do NOT return here!
}
// con_status contains the status code to be supplied to BBufferProducer::Connect's status argument
@@ -544,11 +542,11 @@ BMediaRoster::Connect(const media_source & from,
strcpy(request5.name, reply4.input.name);
rv = QueryPort(reply4.input.source.port, PRODUCER_CONNECT, &request5, sizeof(request5), &reply5, sizeof(reply5));
if (con_status != B_OK) {
TRACE("BMediaRoster::Connect: aborted\n");
FATAL("BMediaRoster::Connect: aborted\n");
return con_status;
}
if (rv != B_OK) {
TRACE("BMediaRoster::Connect: aborted after BBufferProducer::Connect, status = %#lx\n",rv);
FATAL("BMediaRoster::Connect: aborted after BBufferProducer::Connect, status = %#lx\n",rv);
return rv;
}
// reply5.name contains the name assigned to the connection by the producer
@@ -601,19 +599,19 @@ BMediaRoster::Disconnect(media_node_id source_nodeid,
{
CALLED();
if (source_nodeid <= 0) {
TRACE("BMediaRoster::Disconnect: source media_node_id invalid\n");
FATAL("BMediaRoster::Disconnect: source media_node_id invalid\n");
return B_MEDIA_BAD_SOURCE;
}
if (destination_nodeid <= 0) {
TRACE("BMediaRoster::Disconnect: source media_node_id invalid\n");
FATAL("BMediaRoster::Disconnect: source media_node_id invalid\n");
return B_MEDIA_BAD_DESTINATION;
}
if (source == media_source::null) {
TRACE("BMediaRoster::Disconnect: media_source invalid\n");
FATAL("BMediaRoster::Disconnect: media_source invalid\n");
return B_MEDIA_BAD_SOURCE;
}
if (destination == media_destination::null) {
TRACE("BMediaRoster::Disconnect: media_destination invalid\n");
FATAL("BMediaRoster::Disconnect: media_destination invalid\n");
return B_MEDIA_BAD_DESTINATION;
}
@@ -643,12 +641,12 @@ BMediaRoster::Disconnect(media_node_id source_nodeid,
if (B_OK == GetAllOutputs(sourcenode , &outstack))
PublishOutputs(sourcenode , &outstack);
ReleaseNode(sourcenode);
} else TRACE("BMediaRoster::Disconnect: source GetNodeFor failed\n");
} else FATAL("BMediaRoster::Disconnect: source GetNodeFor failed\n");
if (B_OK == GetNodeFor(destination_nodeid, &destnode)) {
if (B_OK == GetAllInputs(destnode , &instack))
PublishInputs(destnode, &instack);
ReleaseNode(destnode);
} else TRACE("BMediaRoster::Disconnect: dest GetNodeFor failed\n");
} else FATAL("BMediaRoster::Disconnect: dest GetNodeFor failed\n");
// send a notification
@@ -918,7 +916,7 @@ BMediaRoster::GetLiveNodes(live_node_info * out_live_nodes,
rv = QueryServer(SERVER_GET_LIVE_NODES, &request, sizeof(request), &reply, sizeof(reply));
if (rv != B_OK) {
TRACE("BMediaRoster::GetLiveNodes failed\n");
FATAL("BMediaRoster::GetLiveNodes failed\n");
*io_total_count = 0;
return rv;
}
@@ -929,7 +927,7 @@ BMediaRoster::GetLiveNodes(live_node_info * out_live_nodes,
clone = clone_area("live_node_info clone", reinterpret_cast<void **>(&live_info), B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, reply.area);
if (clone < B_OK) {
TRACE("BMediaRoster::GetLiveNodes failed to clone area, %#lx\n", clone);
FATAL("BMediaRoster::GetLiveNodes failed to clone area, %#lx\n", clone);
delete_area(reply.area);
*io_total_count = 0;
return B_ERROR;
@@ -1181,7 +1179,7 @@ BMediaRoster::StartWatching(const BMessenger & where)
{
CALLED();
if (!where.IsValid()) {
TRACE("BMediaRoster::StartWatching: messenger invalid!\n");
FATAL("BMediaRoster::StartWatching: messenger invalid!\n");
return B_BAD_VALUE;
}
return BPrivate::media::notifications::Register(where, media_node::null, B_MEDIA_WILDCARD);
@@ -1194,11 +1192,11 @@ BMediaRoster::StartWatching(const BMessenger & where,
{
CALLED();
if (!where.IsValid()) {
TRACE("BMediaRoster::StartWatching: messenger invalid!\n");
FATAL("BMediaRoster::StartWatching: messenger invalid!\n");
return B_BAD_VALUE;
}
if (false == BPrivate::media::notifications::IsValidNotificationRequest(false, notificationType)) {
TRACE("BMediaRoster::StartWatching: notificationType invalid!\n");
FATAL("BMediaRoster::StartWatching: notificationType invalid!\n");
return B_BAD_VALUE;
}
return BPrivate::media::notifications::Register(where, media_node::null, notificationType);
@@ -1212,15 +1210,15 @@ BMediaRoster::StartWatching(const BMessenger & where,
{
CALLED();
if (!where.IsValid()) {
TRACE("BMediaRoster::StartWatching: messenger invalid!\n");
FATAL("BMediaRoster::StartWatching: messenger invalid!\n");
return B_BAD_VALUE;
}
if (node.node <= 0) {
TRACE("BMediaRoster::StartWatching: node invalid!\n");
FATAL("BMediaRoster::StartWatching: node invalid!\n");
return B_MEDIA_BAD_NODE;
}
if (false == BPrivate::media::notifications::IsValidNotificationRequest(true, notificationType)) {
TRACE("BMediaRoster::StartWatching: notificationType invalid!\n");
FATAL("BMediaRoster::StartWatching: notificationType invalid!\n");
return B_BAD_VALUE;
}
return BPrivate::media::notifications::Register(where, node, notificationType);
@@ -1243,7 +1241,7 @@ BMediaRoster::StopWatching(const BMessenger & where,
CALLED();
// messenger may already be invalid, so we don't check this
if (false == BPrivate::media::notifications::IsValidNotificationRequest(false, notificationType)) {
TRACE("BMediaRoster::StopWatching: notificationType invalid!\n");
FATAL("BMediaRoster::StopWatching: notificationType invalid!\n");
return B_BAD_VALUE;
}
return BPrivate::media::notifications::Unregister(where, media_node::null, notificationType);
@@ -1258,11 +1256,11 @@ BMediaRoster::StopWatching(const BMessenger & where,
CALLED();
// messenger may already be invalid, so we don't check this
if (node.node <= 0) {
TRACE("BMediaRoster::StopWatching: node invalid!\n");
FATAL("BMediaRoster::StopWatching: node invalid!\n");
return B_MEDIA_BAD_NODE;
}
if (false == BPrivate::media::notifications::IsValidNotificationRequest(true, notificationType)) {
TRACE("BMediaRoster::StopWatching: notificationType invalid!\n");
FATAL("BMediaRoster::StopWatching: notificationType invalid!\n");
return B_BAD_VALUE;
}
return BPrivate::media::notifications::Unregister(where, node, notificationType);
@@ -1299,7 +1297,7 @@ BMediaRoster::RegisterNode(BMediaNode * node)
rv = QueryServer(SERVER_REGISTER_NODE, &request, sizeof(request), &reply, sizeof(reply));
if (rv != B_OK) {
TRACE("BMediaRoster::RegisterNode: failed to register node %s (error %#lx)\n", node->Name(), rv);
FATAL("BMediaRoster::RegisterNode: failed to register node %s (error %#lx)\n", node->Name(), rv);
return rv;
}
@@ -1349,11 +1347,11 @@ BMediaRoster::UnregisterNode(BMediaNode * node)
return B_BAD_VALUE;
if (node->fRefCount != 0) {
TRACE("BMediaRoster::UnregisterNode: Warning node name '%s' has local reference count of %ld\n", node->Name(), node->fRefCount);
FATAL("BMediaRoster::UnregisterNode: Warning node name '%s' has local reference count of %ld\n", node->Name(), node->fRefCount);
// no return here, we continue and unregister!
}
if (node->ID() == -2) {
TRACE("BMediaRoster::UnregisterNode: Warning node name '%s' already unregistered\n", node->Name());
FATAL("BMediaRoster::UnregisterNode: Warning node name '%s' already unregistered\n", node->Name());
return B_OK;
}
@@ -1369,7 +1367,7 @@ BMediaRoster::UnregisterNode(BMediaNode * node)
rv = QueryServer(SERVER_UNREGISTER_NODE, &request, sizeof(request), &reply, sizeof(reply));
if (rv != B_OK) {
TRACE("BMediaRoster::UnregisterNode: failed to unregister node name '%s' (error %#lx)\n", node->Name(), rv);
FATAL("BMediaRoster::UnregisterNode: failed to unregister node name '%s' (error %#lx)\n", node->Name(), rv);
return rv;
}
@@ -1856,7 +1854,7 @@ BMediaRoster::NodeIDFor(port_id source_or_destination_port)
rv = QueryServer(SERVER_NODE_ID_FOR, &request, sizeof(request), &reply, sizeof(reply));
if (rv != B_OK) {
TRACE("BMediaRoster::NodeIDFor: failed (error %#lx)\n", rv);
FATAL("BMediaRoster::NodeIDFor: failed (error %#lx)\n", rv);
return -1;
}
@@ -1886,7 +1884,7 @@ BMediaRoster::GetInstancesFor(media_addon_id addon,
rv = QueryServer(SERVER_GET_INSTANCES_FOR, &request, sizeof(request), &reply, sizeof(reply));
if (rv != B_OK) {
TRACE("BMediaRoster::GetLiveNodes failed\n");
FATAL("BMediaRoster::GetLiveNodes failed\n");
return rv;
}
-1
View File
@@ -5,7 +5,6 @@
* BContinuousParameter, BDiscreteParameter
***********************************************************************/
#include <ParameterWeb.h>
#include <Debug.h>
#include "debug.h"
//--------BEGIN-ADDED-BY-ZS----------------------------------
+3 -3
View File
@@ -241,7 +241,7 @@ _shared_buffer_list::RequestBufferInOtherGroups(sem_id group_reclaim_sem, media_
continue;
if (info[i].reclaimed == false) {
TRACE("Error, BBuffer 0x%08x, id = 0x%08x not reclaimed while requesting\n",(int)info[i].buffer,(int)id);
FATAL("_shared_buffer_list: Error, BBuffer 0x%08x, id = 0x%08x not reclaimed while requesting\n",(int)info[i].buffer,(int)id);
continue;
}
@@ -268,7 +268,7 @@ _shared_buffer_list::RecycleBuffer(BBuffer *buffer)
if (info[i].id == id) {
reclaimed_count++;
if (info[i].reclaimed) {
TRACE("Error, BBuffer 0x%08x, id = 0x%08x already reclaimed\n",(int)buffer,(int)id);
FATAL("_shared_buffer_list: Error, BBuffer 0x%08x, id = 0x%08x already reclaimed\n",(int)buffer,(int)id);
continue;
}
info[i].reclaimed = true;
@@ -279,7 +279,7 @@ _shared_buffer_list::RecycleBuffer(BBuffer *buffer)
return B_ERROR;
if (reclaimed_count == 0) {
TRACE("Error, BBuffer 0x%08x, id = 0x%08x NOT reclaimed\n",(int)buffer,(int)id);
FATAL("shared_buffer_list: Error, BBuffer 0x%08x, id = 0x%08x NOT reclaimed\n",(int)buffer,(int)id);
return B_ERROR;
}
+1 -1
View File
@@ -126,7 +126,7 @@ BTimeSource::HandleMessage(int32 message,
const void *data,
size_t size)
{
TRACE("BTimeSource::HandleMessage %#lx, node %ld\n", message, fNodeID);
INFO("BTimeSource::HandleMessage %#lx, node %ld\n", message, fNodeID);
switch (message) {
case TIMESOURCE_OP:
+1 -1
View File
@@ -542,7 +542,7 @@ _event_queue_imp::CleanupEvent(media_timed_event *event)
if (fCleanupHook)
(*fCleanupHook)(event,fCleanupHookContext);
} else {
TRACE("BTimedEventQueue cleanup unhandled! type = %ld, cleanup = %ld\n", event->type, event->cleanup);
FATAL("BTimedEventQueue cleanup unhandled! type = %ld, cleanup = %ld\n", event->type, event->cleanup);
}
}
+3 -3
View File
@@ -63,7 +63,7 @@ BTrackReader::BTrackReader(BFile *file, media_raw_audio_format const &format) :
int count = fMediaFile->CountTracks();
if (count == 0) {
TRACE("no tracks in file\n");
FATAL("BTrackReader: no tracks in file\n");
return;
}
@@ -84,7 +84,7 @@ BTrackReader::BTrackReader(BFile *file, media_raw_audio_format const &format) :
fMediaFile->ReleaseTrack(track);
}
if (audiotrack == 0) {
TRACE("no audio track in file\n");
FATAL("BTrackReader: no audio track in file\n");
return;
}
@@ -135,7 +135,7 @@ BTrackReader::SetToTrack(BMediaTrack *track)
}
//we have failed
TRACE("BTrackReader::SetToTrack failed\n");
FATAL("BTrackReader::SetToTrack failed\n");
}
BTrackReader::~BTrackReader()
+7 -9
View File
@@ -3,8 +3,6 @@
* Distributed under the terms of the MIT License.
*/
#define DEBUG 1
#include <OS.h>
#include <Application.h>
#include <Roster.h>
@@ -13,7 +11,7 @@
#include <Messenger.h>
#include <Autolock.h>
#include <stdio.h>
#include <Debug.h>
#include "debug.h"
#include "AppManager.h"
#include "NodeManager.h"
#include "BufferManager.h"
@@ -49,7 +47,7 @@ bool AppManager::HasTeam(team_id team)
status_t AppManager::RegisterTeam(team_id team, BMessenger messenger)
{
BAutolock lock(fLocker);
printf("AppManager::RegisterTeam %ld\n", team);
TRACE("AppManager::RegisterTeam %ld\n", team);
if (HasTeam(team))
return B_ERROR;
App app;
@@ -63,7 +61,7 @@ status_t AppManager::UnregisterTeam(team_id team)
bool is_removed;
bool is_addon_server;
printf("AppManager::UnregisterTeam %ld\n", team);
TRACE("AppManager::UnregisterTeam %ld\n", team);
fLocker->Lock();
is_removed = fAppMap->Remove(team);
@@ -90,12 +88,12 @@ void AppManager::RestartAddonServer()
restart_tries = 0;
}
if (restart_tries < 5) {
printf("AppManager: Restarting media_addon_server...\n");
FATAL("AppManager: Restarting media_addon_server...\n");
// XXX fixme. We should wait until it is *really* gone
snooze(5000000);
StartAddonServer();
} else {
printf("AppManager: media_addon_server crashed too often, not restarted\n");
FATAL("AppManager: media_addon_server crashed too often, not restarted\n");
}
}
@@ -176,7 +174,7 @@ void AppManager::CleanupTeam(team_id team)
{
ASSERT(false == fLocker->IsLocked());
printf("AppManager: cleaning up team %ld\n", team);
TRACE("AppManager: cleaning up team %ld\n", team);
gNodeManager->CleanupTeam(team);
gBufferManager->CleanupTeam(team);
@@ -187,7 +185,7 @@ void AppManager::CleanupAddonServer()
{
ASSERT(false == fLocker->IsLocked());
printf("AppManager: cleaning up media_addon_server\n");
TRACE("AppManager: cleaning up media_addon_server\n");
}
+75 -71
View File
@@ -1,4 +1,4 @@
/*
/*
* Copyright 2002, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
@@ -9,24 +9,26 @@
#include "debug.h"
BufferManager::BufferManager()
: fSharedBufferList(_shared_buffer_list::Clone()),
fSharedBufferListId(-1),
fNextBufferId(1),
fLocker(new BLocker("buffer manager locker")),
fBufferInfoMap(new Map<media_buffer_id, buffer_info>)
{
fSharedBufferList = _shared_buffer_list::Clone();
fAreaId = area_for(fSharedBufferList);
fBufferList = NULL;
fLocker = new BLocker("buffer manager locker");
fNextBufferId = 1;
fSharedBufferListId = area_for(fSharedBufferList);
}
BufferManager::~BufferManager()
{
fSharedBufferList->Unmap();
delete fLocker;
delete fBufferInfoMap;
}
area_id
BufferManager::SharedBufferListID()
{
return fAreaId;
return fSharedBufferListId;
}
status_t
@@ -34,28 +36,25 @@ BufferManager::RegisterBuffer(team_id teamid, media_buffer_id bufferid,
size_t *size, int32 *flags, size_t *offset, area_id *area)
{
BAutolock lock(fLocker);
TRACE("RegisterBuffer team = 0x%08x, bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
_buffer_list *list;
_team_list *team;
buffer_info *info;
if (!fBufferInfoMap->GetPointer(bufferid, &info)) {
FATAL("failed to register buffer! team = 0x%08x, bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
PrintToStream();
return B_ERROR;
}
for (list = fBufferList; list; list = list->next)
if (list->id == bufferid) {
team = new _team_list;
team->team = teamid;
team->next = list->teams;
list->teams = team;
*area = list->area;
*offset = list->offset;
*size = list->size,
*flags = list->flags;
PrintToStream();
return B_OK;
}
info->teams.Insert(teamid);
*area = info->area;
*offset = info->offset;
*size = info->size,
*flags = info->flags;
TRACE("failed to register buffer! team = 0x%08x, bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
PrintToStream();
return B_ERROR;
return B_OK;
}
status_t
@@ -68,28 +67,26 @@ BufferManager::RegisterBuffer(team_id teamid, size_t size, int32 flags, size_t o
void *adr;
area_id newarea;
newarea = clone_area("media_server buffer",&adr,B_ANY_ADDRESS,B_READ_AREA | B_WRITE_AREA,area);
newarea = clone_area("media_server cloned buffer", &adr, B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, area);
if (newarea <= B_OK) {
TRACE("failed to clone buffer! team = 0x%08x, areaid = 0x%08x, offset = 0x%08x, size = 0x%08x\n",(int)teamid,(int)area,(int)offset,(int)size);
FATAL("RegisterBuffer: failed to clone buffer! team = 0x%08x, areaid = 0x%08x, offset = 0x%08x, size = 0x%08x\n",(int)teamid,(int)area,(int)offset,(int)size);
return B_ERROR;
}
*bufferid = fNextBufferId;
buffer_info info;
_buffer_list *list;
list = new _buffer_list;
list->next = fBufferList;
list->id = fNextBufferId;
list->area = newarea;
list->offset = offset;
list->size = size;
list->flags = flags;
list->teams = new _team_list;
list->teams->next = NULL;
list->teams->team = teamid;
fBufferList = list;
*bufferid = fNextBufferId;
info.id = fNextBufferId;
info.area = newarea;
info.offset = offset;
info.size = size;
info.flags = flags;
info.teams.Insert(teamid);
fBufferInfoMap->Insert(fNextBufferId, info);
fNextBufferId++;
TRACE("RegisterBuffer: done, bufferid = 0x%08x\n", fNextBufferId);
fNextBufferId += 1;
PrintToStream();
return B_OK;
@@ -99,44 +96,49 @@ status_t
BufferManager::UnregisterBuffer(team_id teamid, media_buffer_id bufferid)
{
BAutolock lock(fLocker);
TRACE("UnregisterBuffer team = 0x%08x bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
TRACE("UnregisterBuffer: team = 0x%08x bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
_buffer_list **nextlist;
_team_list **nextteam;
buffer_info *info;
int index;
for (nextlist = &fBufferList; (*nextlist); nextlist = &((*nextlist)->next)) {
if ((*nextlist)->id == bufferid) {
for (nextteam = &((*nextlist)->teams); (*nextteam); nextteam = &((*nextteam)->next)) {
if ((*nextteam)->team == teamid) {
_team_list *temp;
temp = *nextteam;
*nextteam = (*nextteam)->next;
delete temp;
TRACE("team = 0x%08x removed from bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
PrintToStream();
break;
}
}
if ((*nextlist)->teams == NULL) {
_buffer_list *temp;
temp = *nextlist;
*nextlist = (*nextlist)->next;
delete_area(temp->area);
delete temp;
TRACE("bufferid = 0x%08x removed\n",(int)bufferid);
PrintToStream();
}
return B_OK;
}
if (!fBufferInfoMap->GetPointer(bufferid, &info)) {
FATAL("UnregisterBuffer: failed to unregister buffer! team = 0x%08x, bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
PrintToStream();
return B_ERROR;
}
PrintToStream();
TRACE("failed to unregister buffer! team = 0x%08x, bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
return B_ERROR;
index = info->teams.Find(teamid);
if (index < 0) {
FATAL("UnregisterBuffer: failed to find team = 0x%08x from bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
PrintToStream();
return B_ERROR;
}
if (!info->teams.Remove(index)) {
FATAL("UnregisterBuffer: failed to remove team = 0x%08x from bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
PrintToStream();
return B_ERROR;
}
TRACE("UnregisterBuffer: team = 0x%08x removed from bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
if (info->teams.IsEmpty()) {
if (!fBufferInfoMap->Remove(bufferid)) {
FATAL("UnregisterBuffer: failed to remove bufferid = 0x%08x\n",(int)bufferid);
PrintToStream();
return B_ERROR;
}
TRACE("UnregisterBuffer: bufferid = 0x%08x removed\n",(int)bufferid);
}
return B_OK;
}
void
BufferManager::CleanupTeam(team_id teamid)
BufferManager::CleanupTeam(team_id team)
{
FATAL("BufferManager::CleanupTeam: should cleanup team %ld\n", team);
}
@@ -144,6 +146,7 @@ void
BufferManager::PrintToStream()
{
return;
/*
BAutolock lock(fLocker);
_buffer_list *list;
_team_list *team;
@@ -156,4 +159,5 @@ BufferManager::PrintToStream()
printf(" team = 0x%08x, next = 0x%08x =>",(int)team->team,(int)team->next);
printf("\n");
}
*/
}
+9 -11
View File
@@ -4,6 +4,9 @@
*/
struct _shared_buffer_list;
#include <TMap.h>
#include <TList.h>
class BufferManager
{
public:
@@ -25,25 +28,20 @@ public:
void PrintToStream();
private:
struct _team_list
struct buffer_info
{
struct _team_list *next;
team_id team;
};
struct _buffer_list
{
struct _buffer_list *next;
media_buffer_id id;
area_id area;
size_t offset;
size_t size;
int32 flags;
_team_list *teams;
List<team_id> teams;
};
_shared_buffer_list * fSharedBufferList;
area_id fAreaId;
_buffer_list * fBufferList;
BLocker * fLocker;
area_id fSharedBufferListId;
media_buffer_id fNextBufferId;
BLocker * fLocker;
Map<media_buffer_id, buffer_info> *fBufferInfoMap;
};
+16 -17
View File
@@ -10,8 +10,6 @@
#include <Messenger.h>
#include <MediaDefs.h>
#include <MediaAddOn.h>
#define DEBUG 3
#include <Debug.h>
#include "debug.h"
#include "NodeManager.h"
@@ -69,15 +67,15 @@ NodeManager::UnregisterNode(media_addon_id *addon_id, media_node_id nodeid, team
TRACE("NodeManager::UnregisterNode enter: node %ld, team %ld\n", nodeid, team);
b = fRegisteredNodeMap->GetPointer(nodeid, &rn);
if (!b) {
TRACE("!!! NodeManager::UnregisterNode: Error: couldn't finde node %ld (team %ld)\n", nodeid, team);
FATAL("!!! NodeManager::UnregisterNode: Error: couldn't finde node %ld (team %ld)\n", nodeid, team);
return B_ERROR;
}
if (rn->team != team) {
TRACE("!!! NodeManager::UnregisterNode: Error: team %ld tried to unregister node %ld, but it was instantiated by team %ld\n", team, nodeid, rn->team);
FATAL("!!! NodeManager::UnregisterNode: Error: team %ld tried to unregister node %ld, but it was instantiated by team %ld\n", team, nodeid, rn->team);
return B_ERROR;
}
if (rn->globalrefcount != 1) {
TRACE("!!! NodeManager::UnregisterNode: Error: node %ld, team %ld, globalrefcount %ld\n", nodeid, team, rn->globalrefcount);
FATAL("!!! NodeManager::UnregisterNode: Error: node %ld, team %ld, globalrefcount %ld\n", nodeid, team, rn->globalrefcount);
//return B_ERROR;
}
*addon_id = rn->addon_id;
@@ -97,7 +95,7 @@ NodeManager::IncrementGlobalRefCount(media_node_id nodeid, team_id team)
TRACE("NodeManager::IncrementGlobalRefCount enter: node %ld, team %ld\n", nodeid, team);
b = fRegisteredNodeMap->GetPointer(nodeid, &rn);
if (!b) {
TRACE("!!! NodeManager::IncrementGlobalRefCount: Error: node %ld not found\n", nodeid);
FATAL("!!! NodeManager::IncrementGlobalRefCount: Error: node %ld not found\n", nodeid);
return B_ERROR;
}
int32 *count;
@@ -126,13 +124,13 @@ NodeManager::DecrementGlobalRefCount(media_node_id nodeid, team_id team)
TRACE("NodeManager::DecrementGlobalRefCount enter: node %ld, team %ld\n", nodeid, team);
b = fRegisteredNodeMap->GetPointer(nodeid, &rn);
if (!b) {
TRACE("!!! NodeManager::DecrementGlobalRefCount: Error: node %ld not found\n", nodeid);
FATAL("!!! NodeManager::DecrementGlobalRefCount: Error: node %ld not found\n", nodeid);
return B_ERROR;
}
int32 *count;
b = rn->teamrefcount.GetPointer(team, &count);
if (!b) {
TRACE("!!! NodeManager::DecrementGlobalRefCount: Error: node %ld has no team %ld references\n", nodeid, team);
FATAL("!!! NodeManager::DecrementGlobalRefCount: Error: node %ld has no team %ld references\n", nodeid, team);
return B_ERROR;
}
*count -= 1;
@@ -156,13 +154,13 @@ NodeManager::GetCloneForId(media_node *node, media_node_id nodeid, team_id team)
TRACE("NodeManager::GetCloneForId enter: node %ld team %ld\n", nodeid, team);
if (B_OK != IncrementGlobalRefCount(nodeid, team)) {
TRACE("!!! NodeManager::GetCloneForId: Error: couldn't increment ref count, node %ld team %ld\n", nodeid, team);
FATAL("!!! NodeManager::GetCloneForId: Error: couldn't increment ref count, node %ld team %ld\n", nodeid, team);
return B_ERROR;
}
b = fRegisteredNodeMap->GetPointer(nodeid, &rn);
if (!b) {
TRACE("!!! NodeManager::GetCloneForId: Error: node %ld not found\n", nodeid);
FATAL("!!! NodeManager::GetCloneForId: Error: node %ld not found\n", nodeid);
return B_ERROR;
}
@@ -179,7 +177,7 @@ status_t
NodeManager::GetClone(media_node *node, char *input_name, int32 *input_id, node_type type, team_id team)
{
BAutolock lock(fLocker);
TRACE("!!! NodeManager::GetClone not implemented\n");
FATAL("!!! NodeManager::GetClone not implemented\n");
*node = media_node::null;
return B_ERROR;
}
@@ -191,7 +189,7 @@ NodeManager::ReleaseNode(const media_node &node, team_id team)
BAutolock lock(fLocker);
TRACE("NodeManager::ReleaseNode enter: node %ld team %ld\n", node.node, team);
if (B_OK != DecrementGlobalRefCount(node.node, team)) {
TRACE("!!! NodeManager::ReleaseNode: Error: couldn't decrement node %ld team %ld ref count\n", node.node, team);
FATAL("!!! NodeManager::ReleaseNode: Error: couldn't decrement node %ld team %ld ref count\n", node.node, team);
}
TRACE("NodeManager::ReleaseNode leave: node %ld team %ld\n", node.node, team);
return B_OK;
@@ -206,7 +204,7 @@ NodeManager::PublishInputs(const media_node &node, const media_input *inputs, in
bool b;
b = fRegisteredNodeMap->GetPointer(node.node, &rn);
if (!b) {
TRACE("!!! NodeManager::PublishInputs: Error: node %ld not found\n", node.node);
FATAL("!!! NodeManager::PublishInputs: Error: node %ld not found\n", node.node);
return B_ERROR;
}
rn->inputlist.MakeEmpty();
@@ -224,7 +222,7 @@ NodeManager::PublishOutputs(const media_node &node, const media_output *outputs,
bool b;
b = fRegisteredNodeMap->GetPointer(node.node, &rn);
if (!b) {
TRACE("!!! NodeManager::PublishOutputs: Error: node %ld not found\n", node.node);
FATAL("!!! NodeManager::PublishOutputs: Error: node %ld not found\n", node.node);
return B_ERROR;
}
rn->outputlist.MakeEmpty();
@@ -262,7 +260,7 @@ NodeManager::FindNodeId(media_node_id *nodeid, port_id port)
}
}
}
TRACE("!!! NodeManager::FindNodeId failed, port %ld\n", port);
FATAL("!!! NodeManager::FindNodeId failed, port %ld\n", port);
return B_ERROR;
}
@@ -283,7 +281,7 @@ NodeManager::GetLiveNodeInfo(live_node_info *live_info, const media_node &node)
return B_OK;
}
}
TRACE("!!! NodeManager::GetLiveNodeInfo failed, node %ld\n", node.node);
FATAL("!!! NodeManager::GetLiveNodeInfo failed, node %ld\n", node.node);
return B_ERROR;
}
@@ -387,7 +385,7 @@ NodeManager::GetDormantNodeInfo(dormant_node_info *node_info, const media_node &
return B_OK;
}
}
TRACE("!!! NodeManager::GetDormantNodeInfo failed, node %ld\n", node.node);
FATAL("!!! NodeManager::GetDormantNodeInfo failed, node %ld\n", node.node);
return B_ERROR;
}
@@ -527,4 +525,5 @@ void
NodeManager::CleanupTeam(team_id team)
{
BAutolock lock(fLocker);
FATAL("NodeManager::CleanupTeam: should cleanup team %ld\n", team);
}
+5 -1
View File
@@ -7,7 +7,6 @@
#include <Message.h>
#include <Messenger.h>
#include <MediaNode.h>
#include <Debug.h>
#include "debug.h"
#include "NodeManager.h"
#include "DataExchange.h"
@@ -205,16 +204,21 @@ NotificationManager::CleanupTeam(team_id team)
TRACE("NotificationManager::CleanupTeam team %ld\n", team);
fLocker->Lock();
int debugcount = 0;
Notification n;
for (int32 index = 0; fNotificationList->GetAt(index, &n); index++) {
if (n.team == team) {
if (fNotificationList->Remove(index)) {
debugcount++;
index--;
} else {
ASSERT(false);
}
}
}
if (debugcount != 0)
FATAL("NotificationManager::CleanupTeam: removed %d notifications for team %ld\n", debugcount, team);
fLocker->Unlock();
}
+7 -9
View File
@@ -11,8 +11,6 @@
#include "NodeManager.h"
#include "AppManager.h"
#include "media_server.h"
#define DEBUG 1
#include <Debug.h>
#include "debug.h"
/*
@@ -107,7 +105,7 @@ ServerApp::ServerApp()
ServerApp::~ServerApp()
{
printf("####ServerApp::~ServerApp()\n");
TRACE("ServerApp::~ServerApp()\n");
delete gNotificationManager;
delete gBufferManager;
delete gAppManager;
@@ -121,7 +119,7 @@ ServerApp::~ServerApp()
bool
ServerApp::QuitRequested()
{
printf("####ServerApp::QuitRequested()\n");
TRACE("ServerApp::QuitRequested()\n");
gAppManager->TerminateAddonServer();
return true;
}
@@ -130,7 +128,7 @@ void
ServerApp::HandleMessage(int32 code, void *data, size_t size)
{
status_t rv;
printf("ServerApp::HandleMessage %#lx\n", code);
INFO("ServerApp::HandleMessage %#lx\n", code);
switch (code) {
case SERVER_REGISTER_ADDONSERVER:
{
@@ -212,7 +210,7 @@ ServerApp::HandleMessage(int32 code, void *data, size_t size)
size = ((reply.count * sizeof(live_node_info)) + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
reply.area = create_area("get live nodes", reinterpret_cast<void **>(&start_addr), B_ANY_ADDRESS, size, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
if (reply.area < B_OK) {
TRACE("SERVER_GET_LIVE_NODES: failed to create area, %#lx\n", reply.area);
FATAL("SERVER_GET_LIVE_NODES: failed to create area, %#lx\n", reply.area);
reply.count = 0;
rv = B_ERROR;
} else {
@@ -273,7 +271,7 @@ ServerApp::HandleMessage(int32 code, void *data, size_t size)
area_id clone;
clone = clone_area("media_inputs clone", reinterpret_cast<void **>(&inputs), B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, request->area);
if (clone < B_OK) {
TRACE("SERVER_PUBLISH_INPUTS: failed to clone area, %#lx\n", clone);
FATAL("SERVER_PUBLISH_INPUTS: failed to clone area, %#lx\n", clone);
rv = B_ERROR;
} else {
rv = gNodeManager->PublishInputs(request->node, inputs, request->count);
@@ -295,7 +293,7 @@ ServerApp::HandleMessage(int32 code, void *data, size_t size)
area_id clone;
clone = clone_area("media_outputs clone", reinterpret_cast<void **>(&outputs), B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, request->area);
if (clone < B_OK) {
TRACE("SERVER_PUBLISH_OUTPUTS: failed to clone area, %#lx\n", clone);
FATAL("SERVER_PUBLISH_OUTPUTS: failed to clone area, %#lx\n", clone);
rv = B_ERROR;
} else {
rv = gNodeManager->PublishOutputs(request->node, outputs, request->count);
@@ -340,7 +338,7 @@ ServerApp::HandleMessage(int32 code, void *data, size_t size)
server_get_instances_for_reply reply;
rv = gNodeManager->GetInstances(reply.node_id, &reply.count, min_c(request->maxcount, MAX_NODE_ID), request->addon_id, request->addon_flavor_id);
if (reply.count == MAX_NODE_ID && request->maxcount > MAX_NODE_ID) { // XXX might be fixed by using an area
TRACE("SERVER_GET_INSTANCES_FOR: WARNING! returning possibly truncated list of node id's\n");
FATAL("SERVER_GET_INSTANCES_FOR: WARNING! returning possibly truncated list of node id's\n");
}
request->SendReply(rv, &reply, sizeof(reply));
break;
+19 -19
View File
@@ -10,8 +10,6 @@
#include <Path.h>
#include <Directory.h>
#include <Looper.h>
#define DEBUG 1
#include <Debug.h>
#include "debug.h"
#include "TMap.h"
#include "ServerInterface.h"
@@ -99,7 +97,7 @@ MediaAddonServer::HandleMessage(int32 code, const void *data, size_t size)
BMediaAddOn *addon;
addon = _DormantNodeManager->GetAddon(command->addonid);
if (!addon) {
printf("rescan flavors: Can't find a addon object for id %d\n",(int)command->addonid);
FATAL("rescan flavors: Can't find a addon object for id %d\n",(int)command->addonid);
break;
}
ScanAddOnFlavors(addon);
@@ -108,7 +106,7 @@ MediaAddonServer::HandleMessage(int32 code, const void *data, size_t size)
}
default:
printf("media_addon_server: received unknown message code %#08lx\n",code);
FATAL("media_addon_server: received unknown message code %#08lx\n",code);
}
}
@@ -137,7 +135,7 @@ MediaAddonServer::ReadyToRun()
request.team = BPrivate::media::team;
result = QueryServer(SERVER_REGISTER_ADDONSERVER, &request, sizeof(request), &reply, sizeof(reply));
if (result != B_OK) {
printf("Communication with server failed. Terminating.\n");
FATAL("Communication with server failed. Terminating.\n");
PostMessage(B_QUIT_REQUESTED);
return;
}
@@ -173,11 +171,11 @@ MediaAddonServer::ScanAddOnFlavors(BMediaAddOn *addon)
ASSERT(addon);
ASSERT(addon->AddonID() > 0);
printf("MediaAddonServer::ScanAddOnFlavors: id %ld\n",addon->AddonID());
TRACE("MediaAddonServer::ScanAddOnFlavors: id %ld\n",addon->AddonID());
port = find_port("media_server port");
if (port <= B_OK) {
printf("couldn't find media_server port\n");
FATAL("couldn't find media_server port\n");
return;
}
@@ -192,18 +190,20 @@ MediaAddonServer::ScanAddOnFlavors(BMediaAddOn *addon)
newflavorcount = addon->CountFlavors();
*flavorcount = newflavorcount;
printf("%ld old flavors, %ld new flavors\n", oldflavorcount, newflavorcount);
TRACE("%ld old flavors, %ld new flavors\n", oldflavorcount, newflavorcount);
// during the first update (i == 0), the server removes old dormant_flavor_infos
for (int i = 0; i < newflavorcount; i++) {
const flavor_info *info;
printf("flavor %d:\n",i);
TRACE("flavor %d:\n",i);
if (B_OK != addon->GetFlavorAt(i, &info)) {
printf("failed!\n");
FATAL("MediaAddonServer::ScanAddOnFlavors GetFlavorAt failed for index %d!\n", i);
continue;
}
DumpFlavorInfo(info);
#if DEBUG >= 3
DumpFlavorInfo(info);
#endif
dormant_flavor_info dfi;
dfi = *info;
@@ -231,7 +231,7 @@ MediaAddonServer::ScanAddOnFlavors(BMediaAddOn *addon)
rv = write_port(port, SERVER_REGISTER_DORMANT_NODE, msg, msgsize);
if (rv != B_OK) {
printf("MediaAddonServer::ScanAddOnFlavors: couldn't register dormant node\n");
FATAL("MediaAddonServer::ScanAddOnFlavors: couldn't register dormant node\n");
}
free(msg);
@@ -246,25 +246,25 @@ MediaAddonServer::ScanAddOnFlavors(BMediaAddOn *addon)
void
MediaAddonServer::AddOnAdded(const char *path, ino_t file_node)
{
printf("\n\nMediaAddonServer::AddOnAdded: path %s\n",path);
TRACE("\n\nMediaAddonServer::AddOnAdded: path %s\n",path);
BMediaAddOn *addon;
media_addon_id id;
id = _DormantNodeManager->RegisterAddon(path);
if (id <= 0) {
printf("MediaAddonServer::AddOnAdded: failed to register add-on\n");
FATAL("MediaAddonServer::AddOnAdded: failed to register add-on %s\n", path);
return;
}
addon = _DormantNodeManager->GetAddon(id);
if (addon == NULL) {
printf("MediaAddonServer::AddOnAdded: failed to get add-on\n");
FATAL("MediaAddonServer::AddOnAdded: failed to get add-on %s\n", path);
_DormantNodeManager->UnregisterAddon(id);
return;
}
printf("MediaAddonServer::AddOnAdded: loading finished, id %d\n",(int)id);
TRACE("MediaAddonServer::AddOnAdded: loading finished, id %d\n",(int)id);
filemap->Insert(file_node, id);
flavorcountmap->Insert(id, 0);
@@ -272,7 +272,7 @@ MediaAddonServer::AddOnAdded(const char *path, ino_t file_node)
ScanAddOnFlavors(addon);
if (addon->WantsAutoStart())
printf("#### WantsAutoStart!\n");
TRACE("#### WantsAutoStart!\n");
/*
* the mixer (which we can't load because of unresolved symbols)
@@ -327,7 +327,7 @@ MediaAddonServer::AddOnRemoved(ino_t file_node)
{
media_addon_id id;
if (!filemap->Get(file_node,&id)) {
printf("MediaAddonServer::AddOnRemoved: inode %Ld removed, but no media add-on found\n",file_node);
FATAL("MediaAddonServer::AddOnRemoved: inode %Ld removed, but no media add-on found\n", file_node);
return;
}
filemap->Remove(file_node);
@@ -425,7 +425,7 @@ MediaAddonServer::MessageReceived(BMessage *msg)
break;
}
}
printf("Unhandled message:\n");
printf("MediaAddonServer: Unhandled message:\n");
msg->PrintToStream();
}