changed BufferManager communication to use ports.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2193 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper 2002-12-08 23:49:40 +00:00
parent 3ca7b9c952
commit 075570786d
2 changed files with 74 additions and 34 deletions

View File

@ -10,6 +10,7 @@
#include <MediaNode.h>
#include <MediaAddOn.h>
#include <Messenger.h>
#include <Buffer.h>
#include <Entry.h>
namespace BPrivate {
@ -22,7 +23,7 @@ struct command_data;
// BMessage based data exchange with the media_server
status_t SendToServer(BMessage *msg);
status_t QueryServer(BMessage *request, BMessage *reply);
//status_t QueryServer(BMessage *request, BMessage *reply);
// Raw data based data exchange with the media_server
status_t SendToServer(int32 msgcode, command_data *msg, int size);
@ -93,6 +94,9 @@ enum {
SERVER_UNREGISTER_NODE,
SERVER_GET_DORMANT_NODE_FOR,
SERVER_GET_INSTANCES_FOR,
SERVER_GET_SHARED_BUFFER_AREA,
SERVER_REGISTER_BUFFER,
SERVER_UNREGISTER_BUFFER,
SERVER_MESSAGE_END,
NODE_MESSAGE_START = 0x200,
@ -805,14 +809,32 @@ struct server_get_mediaaddon_ref_reply : public reply_data
xfer_entry_ref ref; // a ref to the file
};
struct server_get_shared_buffer_area_request : public request_data
{
};
struct server_get_shared_buffer_area_reply : public reply_data
{
area_id area;
};
struct server_register_buffer_request : public request_data
{
team_id team;
//either info.buffer is != 0, or the area, size, offset is used
buffer_clone_info info;
};
struct server_register_buffer_reply : public reply_data
{
buffer_clone_info info;
};
struct server_unregister_buffer_command : public command_data
{
team_id team;
media_buffer_id bufferid;
};
struct node_request_completed_command : public command_data
{

View File

@ -37,11 +37,11 @@ BufferManager::RegisterBuffer(team_id teamid, media_buffer_id bufferid,
{
BAutolock lock(fLocker);
TRACE("RegisterBuffer team = 0x%08x, bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
TRACE("RegisterBuffer team = %ld, bufferid = %ld\n", teamid, bufferid);
buffer_info *info;
if (!fBufferInfoMap->GetPointer(bufferid, &info)) {
FATAL("failed to register buffer! team = 0x%08x, bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
if (!fBufferInfoMap->Get(bufferid, &info)) {
FATAL("failed to register buffer! team = %ld, bufferid = %ld\n", teamid, bufferid);
PrintToStream();
return B_ERROR;
}
@ -62,14 +62,14 @@ BufferManager::RegisterBuffer(team_id teamid, size_t size, int32 flags, size_t o
media_buffer_id *bufferid)
{
BAutolock lock(fLocker);
TRACE("RegisterBuffer team = 0x%08x, areaid = 0x%08x, offset = 0x%08x, size = 0x%08x\n",(int)teamid,(int)area,(int)offset,(int)size);
TRACE("RegisterBuffer team = %ld, areaid = %ld, offset = %ld, size = %ld\n", teamid, area, offset, size);
void *adr;
area_id newarea;
newarea = clone_area("media_server cloned buffer", &adr, B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, area);
if (newarea <= B_OK) {
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);
FATAL("RegisterBuffer: failed to clone buffer! error = %#lx, team = %ld, areaid = %ld, offset = %ld, size = %ld\n", newarea, teamid, area, offset, size);
return B_ERROR;
}
@ -84,7 +84,7 @@ BufferManager::RegisterBuffer(team_id teamid, size_t size, int32 flags, size_t o
info.teams.Insert(teamid);
fBufferInfoMap->Insert(fNextBufferId, info);
TRACE("RegisterBuffer: done, bufferid = 0x%08x\n", fNextBufferId);
TRACE("RegisterBuffer: done, bufferid = %ld\n", fNextBufferId);
fNextBufferId += 1;
@ -96,40 +96,40 @@ 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 = %ld, bufferid = %ld\n", teamid, bufferid);
buffer_info *info;
int index;
if (!fBufferInfoMap->GetPointer(bufferid, &info)) {
FATAL("UnregisterBuffer: failed to unregister buffer! team = 0x%08x, bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
if (!fBufferInfoMap->Get(bufferid, &info)) {
FATAL("UnregisterBuffer: failed to unregister buffer! team = %ld, bufferid = %ld\n", teamid, bufferid);
PrintToStream();
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);
FATAL("UnregisterBuffer: failed to find team = %ld belonging to bufferid = %ld\n", teamid, 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);
FATAL("UnregisterBuffer: failed to remove team = %ld from bufferid = %ld\n", teamid, bufferid);
PrintToStream();
return B_ERROR;
}
TRACE("UnregisterBuffer: team = 0x%08x removed from bufferid = 0x%08x\n",(int)teamid,(int)bufferid);
TRACE("UnregisterBuffer: team = %ld removed from bufferid = %ld\n", teamid, bufferid);
if (info->teams.IsEmpty()) {
if (!fBufferInfoMap->Remove(bufferid)) {
FATAL("UnregisterBuffer: failed to remove bufferid = 0x%08x\n",(int)bufferid);
FATAL("UnregisterBuffer: failed to remove bufferid = %ld\n", bufferid);
PrintToStream();
return B_ERROR;
}
TRACE("UnregisterBuffer: bufferid = 0x%08x removed\n",(int)bufferid);
TRACE("UnregisterBuffer: bufferid = %ld removed\n", bufferid);
}
return B_OK;
@ -138,26 +138,44 @@ BufferManager::UnregisterBuffer(team_id teamid, media_buffer_id bufferid)
void
BufferManager::CleanupTeam(team_id team)
{
FATAL("BufferManager::CleanupTeam: should cleanup team %ld\n", team);
BAutolock lock(fLocker);
buffer_info *info;
TRACE("BufferManager::CleanupTeam: team %ld\n", team);
PrintToStream();
for (fBufferInfoMap->Rewind(); fBufferInfoMap->GetNext(&info); ) {
team_id *otherteam;
for (info->teams.Rewind(); info->teams.GetNext(&otherteam); ) {
if (team == *otherteam) {
FATAL("BufferManager::CleanupTeam: removing team %ld from buffer id %ld\n", team, info->id);
info->teams.RemoveCurrent();
}
}
if (info->teams.IsEmpty()) {
FATAL("BufferManager::CleanupTeam: removing buffer id %ld that has no teams\n", info->id);
fBufferInfoMap->RemoveCurrent();
}
}
PrintToStream();
}
void
BufferManager::PrintToStream()
{
return;
/*
BAutolock lock(fLocker);
_buffer_list *list;
_team_list *team;
printf("Buffer list:\n");
for (list = fBufferList; list; list = list->next) {
printf(" bufferid = 0x%08x, areaid = 0x%08x, offset = 0x%08x, size = 0x%08x, flags = 0x%08x, next = 0x%08x\n",
(int)list->id,(int)list->area,(int)list->offset,(int)list->size,(int)list->flags,(int)list->next);
for (team = list->teams; team; team = team->next)
printf(" team = 0x%08x, next = 0x%08x =>",(int)team->team,(int)team->next);
printf("\n");
buffer_info *info;
team_id *team;
TRACE("BufferManager: list of buffers follows:\n");
for (fBufferInfoMap->Rewind(); fBufferInfoMap->GetNext(&info); ) {
TRACE(" bufferid = %ld, areaid = %ld, offset = %ld, size = %ld, flags = %#08lx\n",
info->id, info->area, info->offset, info->size, info->flags);
for (info->teams.Rewind(); info->teams.GetNext(&team); ) {
TRACE(" team = %ld", *team);
}
TRACE("\n");
}
*/
TRACE("BufferManager: list end\n");
}