diff --git a/src/kits/media/MediaNode.cpp b/src/kits/media/MediaNode.cpp index 8ff64f4bb7..dd264575ee 100644 --- a/src/kits/media/MediaNode.cpp +++ b/src/kits/media/MediaNode.cpp @@ -27,21 +27,24 @@ * THE SOFTWARE. * */ -//#define DEBUG 7 -#include -#include -#include + + #include #include #include #include +#include +#include +#include + #include + +#include "DataExchange.h" #include "debug.h" #include "MediaMisc.h" #include "MediaRosterEx.h" -#include "DataExchange.h" -#include "ServerInterface.h" #include "Notifications.h" +#include "ServerInterface.h" #include "TimeSourceObject.h" #include "TimeSourceObjectManager.h" @@ -56,93 +59,75 @@ using std::nothrow_t; #define TRACE(x...) #endif - -// don't rename this one, it's used and exported for binary compatibility +// Don't rename this one, it's used and exported for binary compatibility int32 BMediaNode::_m_changeTag = 0; -/************************************************************* - * media_node - *************************************************************/ +// media_node + +media_node media_node::null; -// final & verified media_node::media_node() - : node(-1), + : + node(-1), port(-1), kind(0) { } -// final & verified + media_node::~media_node() { } -/************************************************************* - * static media_node variables - *************************************************************/ +// media_input -// final & verified -media_node media_node::null; - -/************************************************************* - * media_input - *************************************************************/ - -// final media_input::media_input() { name[0] = '\0'; } -// final + media_input::~media_input() { } -/************************************************************* - * media_output - *************************************************************/ +// media_output -// final media_output::media_output() { name[0] = '\0'; } -// final + media_output::~media_output() { } -/************************************************************* - * live_node_info - *************************************************************/ +// live_node_info -// final & verified live_node_info::live_node_info() - : hint_point(0.0f, 0.0f) + : + hint_point(0.0f, 0.0f) { name[0] = '\0'; } -// final & verified + live_node_info::~live_node_info() { } -/************************************************************* - * protected BMediaNode - *************************************************************/ +// BMediaNode -/* virtual */ BMediaNode::~BMediaNode() { CALLED(); - // BeBook: UnregisterNode() unregisters a node from the Media Server. It's called automatically - // BeBook: by the BMediaNode destructor, but it might be convenient to call it sometime before - // BeBook: you delete your node instance, depending on your implementation and circumstances. + // BeBook: UnregisterNode() unregisters a node from the Media Server. + // It's called automatically by the BMediaNode destructor, but it might + // be convenient to call it sometime before you delete your node instance, + // depending on your implementation and circumstances. - // first we remove the time source + // First we remove the time source if (fTimeSource) { fTimeSource->RemoveMe(this); fTimeSource->Release(); @@ -151,19 +136,15 @@ BMediaNode::~BMediaNode() // Attention! We do not delete their control ports, since they are only a // shadow object, and the real one still exists - if (0 == (fKinds & NODE_KIND_SHADOW_TIMESOURCE)) { + if ((fKinds & NODE_KIND_SHADOW_TIMESOURCE) == 0) { if (fControlPort > 0) delete_port(fControlPort); - } else { + } else TRACE("BMediaNode::~BMediaNode: shadow timesource, not unregistering\n"); - } } -/************************************************************* - * public BMediaNode - *************************************************************/ -BMediaNode * +BMediaNode* BMediaNode::Acquire() { CALLED(); @@ -172,7 +153,7 @@ BMediaNode::Acquire() } -BMediaNode * +BMediaNode* BMediaNode::Release() { CALLED(); @@ -189,7 +170,7 @@ BMediaNode::Release() } -const char * +const char* BMediaNode::Name() const { CALLED(); @@ -219,7 +200,9 @@ BMediaNode::Node() const CALLED(); media_node temp; temp.node = ID(); - temp.port = ControlPort(); // we *must* call ControlPort(), some derived nodes use it to start the port read thread! + // We *must* call ControlPort(), some derived nodes + // use it to start the port read thread! + temp.port = ControlPort(); temp.kind = Kinds(); return temp; } @@ -233,12 +216,12 @@ BMediaNode::RunMode() const } -BTimeSource * +BTimeSource* BMediaNode::TimeSource() const { PRINT(7, "CALLED BMediaNode::TimeSource()\n"); - // return the currently assigned time source + // Return the currently assigned time source if (fTimeSource != 0) return fTimeSource; @@ -249,12 +232,10 @@ BMediaNode::TimeSource() const // but since the node does still have the default system time source, we // can use GetSystemTimeSource - BMediaNode *self = const_cast(this); -// if (fTimeSourceID == NODE_SYSTEM_TIMESOURCE_ID) { -// self->fTimeSource = _TimeSourceObjectManager->GetSystemTimeSource(); -// } else { - self->fTimeSource = MediaRosterEx(BMediaRoster::Roster())->MakeTimeSourceObject(fTimeSourceID); -// } + BMediaNode* self = const_cast(this); + self->fTimeSource = MediaRosterEx( + BMediaRoster::Roster())->MakeTimeSourceObject(fTimeSourceID); + ASSERT(fTimeSource == self->fTimeSource); if (fTimeSource == 0) { @@ -270,7 +251,7 @@ BMediaNode::TimeSource() const } -/* virtual */ port_id +port_id BMediaNode::ControlPort() const { PRINT(7, "CALLED BMediaNode::ControlPort()\n"); @@ -278,17 +259,12 @@ BMediaNode::ControlPort() const } -/************************************************************* - * protected BMediaNode - *************************************************************/ - status_t -BMediaNode::ReportError(node_error what, - const BMessage *info) +BMediaNode::ReportError(node_error what, const BMessage* info) { CALLED(); - // sanity check the what value + // Sanity check the what value switch (what) { case BMediaNode::B_NODE_FAILED_START: case BMediaNode::B_NODE_FAILED_STOP: @@ -314,15 +290,15 @@ status_t BMediaNode::NodeStopped(bigtime_t whenPerformance) { UNIMPLEMENTED(); - // called by derived classes when they have + // Called by derived classes when they have // finished handling a stop request. - // notify anyone who is listening for stop notifications! + // Notify anyone who is listening for stop notifications! BPrivate::media::notifications::NodeStopped(Node(), whenPerformance); - // XXX If your node is a BBufferProducer, downstream consumers - // XXX will be notified that your node stopped (automatically, no less) - // XXX through the BBufferConsumer::ProducerDataStatus(B_PRODUCER_STOPPED) call. + // NOTE: If your node is a BBufferProducer, downstream consumers + // will be notified that your node stopped (automatically, no less) through + // the BBufferConsumer::ProducerDataStatus(B_PRODUCER_STOPPED) call. return B_OK; } @@ -334,9 +310,7 @@ BMediaNode::NodeStopped(bigtime_t whenPerformance) * value. */ void -BMediaNode::TimerExpired(bigtime_t notifyPoint, - int32 cookie, - status_t error) +BMediaNode::TimerExpired(bigtime_t notifyPoint, int32 cookie, status_t error) { CALLED(); if (write_port((port_id)cookie, 0, &error, sizeof(error)) < 0) { @@ -346,8 +320,7 @@ BMediaNode::TimerExpired(bigtime_t notifyPoint, } -/* explicit */ -BMediaNode::BMediaNode(const char *name) +BMediaNode::BMediaNode(const char* name) { TRACE("BMediaNode::BMediaNode: name '%s'\n", name); _InitObject(name, NODE_JUST_CREATED_ID, 0); @@ -355,17 +328,16 @@ BMediaNode::BMediaNode(const char *name) status_t -BMediaNode::WaitForMessage(bigtime_t waitUntil, - uint32 flags, - void *_reserved_) +BMediaNode::WaitForMessage(bigtime_t waitUntil, uint32 flags, + void* _reserved_) { TRACE("entering: BMediaNode::WaitForMessage()\n"); // This function waits until either real time specified by // waitUntil or a message is received on the control port. // The flags are currently unused and should be 0. - - char data[B_MEDIA_MESSAGE_SIZE]; // about 16 KByte stack used + // Note: about 16 KByte stack used + char data[B_MEDIA_MESSAGE_SIZE]; int32 message; ssize_t size; while (true) { @@ -390,19 +362,23 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil, TRACE("BMediaNode::WaitForMessage request is: %#lx, node %ld, this %p\n", message, fNodeID, this); - if (message == GENERAL_PURPOSE_WAKEUP) return B_OK; // no action needed + if (message == GENERAL_PURPOSE_WAKEUP) + return B_OK; if (message > NODE_MESSAGE_START && message < NODE_MESSAGE_END) { TRACE("BMediaNode::WaitForMessage calling BMediaNode\n"); + if (B_OK == BMediaNode::HandleMessage(message, data, size)) return B_OK; } if (message > PRODUCER_MESSAGE_START && message < PRODUCER_MESSAGE_END) { if (!fProducerThis) - fProducerThis = dynamic_cast(this); + fProducerThis = dynamic_cast(this); + TRACE("BMediaNode::WaitForMessage calling BBufferProducer %p\n", fProducerThis); + if (fProducerThis && fProducerThis->BBufferProducer::HandleMessage( message, data, size) == B_OK) { return B_OK; @@ -411,9 +387,11 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil, if (message > CONSUMER_MESSAGE_START && message < CONSUMER_MESSAGE_END) { if (!fConsumerThis) - fConsumerThis = dynamic_cast(this); + fConsumerThis = dynamic_cast(this); + TRACE("BMediaNode::WaitForMessage calling BBufferConsumer %p\n", fConsumerThis); + if (fConsumerThis && fConsumerThis->BBufferConsumer::HandleMessage( message, data, size) == B_OK) { return B_OK; @@ -423,9 +401,11 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil, if (message > FILEINTERFACE_MESSAGE_START && message < FILEINTERFACE_MESSAGE_END) { if (!fFileInterfaceThis) - fFileInterfaceThis = dynamic_cast(this); + fFileInterfaceThis = dynamic_cast(this); + TRACE("BMediaNode::WaitForMessage calling BFileInterface %p\n", fFileInterfaceThis); + if (fFileInterfaceThis && fFileInterfaceThis->BFileInterface::HandleMessage( message, data, size) == B_OK) { @@ -436,9 +416,11 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil, if (message > CONTROLLABLE_MESSAGE_START && message < CONTROLLABLE_MESSAGE_END) { if (!fControllableThis) - fControllableThis = dynamic_cast(this); + fControllableThis = dynamic_cast(this); + TRACE("BMediaNode::WaitForMessage calling BControllable %p\n", fControllableThis); + if (fControllableThis && fControllableThis->BControllable::HandleMessage( message, data, size) == B_OK) { @@ -449,9 +431,11 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil, if (message > TIMESOURCE_MESSAGE_START && message < TIMESOURCE_MESSAGE_END) { if (!fTimeSourceThis) - fTimeSourceThis = dynamic_cast(this); + fTimeSourceThis = dynamic_cast(this); + TRACE("BMediaNode::WaitForMessage calling BTimeSource %p\n", fTimeSourceThis); + if (fTimeSourceThis && fTimeSourceThis->BTimeSource::HandleMessage( message, data, size) == B_OK) { return B_OK; @@ -459,7 +443,7 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil, } TRACE("BMediaNode::WaitForMessage calling default HandleMessage\n"); - if (B_OK == HandleMessage(message, data, size)) + if (HandleMessage(message, data, size) == B_OK) return B_OK; HandleBadMessage(message, data, size); @@ -468,7 +452,7 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil, } -/* virtual */ void +void BMediaNode::Start(bigtime_t performance_time) { CALLED(); @@ -482,9 +466,8 @@ BMediaNode::Start(bigtime_t performance_time) } -/* virtual */ void -BMediaNode::Stop(bigtime_t performance_time, - bool immediate) +void +BMediaNode::Stop(bigtime_t performance_time, bool immediate) { CALLED(); // This hook function is called when a node is stopped @@ -497,9 +480,8 @@ BMediaNode::Stop(bigtime_t performance_time, } -/* virtual */ void -BMediaNode::Seek(bigtime_t media_time, - bigtime_t performance_time) +void +BMediaNode::Seek(bigtime_t media_time, bigtime_t performance_time) { CALLED(); // This hook function is called when a node is asked @@ -513,31 +495,30 @@ BMediaNode::Seek(bigtime_t media_time, } -/* virtual */ void +void BMediaNode::SetRunMode(run_mode mode) { CALLED(); - // this is a hook function, and + // This is a hook function, and // may be overriden by derived classes. - // the functionality here is only to + // The functionality here is only to // support those people that don't // use the roster to set the run mode fRunMode = mode; } -/* virtual */ void -BMediaNode::TimeWarp(bigtime_t at_real_time, - bigtime_t to_performance_time) +void +BMediaNode::TimeWarp(bigtime_t at_real_time, bigtime_t to_performance_time) { CALLED(); // May be overriden by derived classes. } -/* virtual */ void +void BMediaNode::Preroll() { CALLED(); @@ -545,34 +526,32 @@ BMediaNode::Preroll() } -/* virtual */ void -BMediaNode::SetTimeSource(BTimeSource *time_source) +void +BMediaNode::SetTimeSource(BTimeSource* time_source) { CALLED(); - // this is a hook function, and + // This is a hook function, and // may be overriden by derived classes. if (time_source == NULL || time_source == fTimeSource) return; - // we just trip into debugger, code that tries to do this is broken. - debugger("BMediaNode::SetTimeSource() can't be used to set a timesource, use BMediaRoster::SetTimeSourceFor()!\n"); + // We just trip into debugger, code that tries to do this is broken. + debugger("BMediaNode::SetTimeSource() can't be used to set a timesource, " + "use BMediaRoster::SetTimeSourceFor()!\n"); } -/************************************************************* - * public BMediaNode - *************************************************************/ -/* virtual */ status_t -BMediaNode::HandleMessage(int32 message, - const void *data, - size_t size) +status_t +BMediaNode::HandleMessage(int32 message, const void* data, size_t size) { TRACE("BMediaNode::HandleMessage %#lx, node %ld\n", message, fNodeID); switch (message) { case NODE_FINAL_RELEASE: { - // const node_final_release_command *command = static_cast(data); + TRACE("BMediaNode::HandleMessage NODE_FINAL_RELEASE, this %p\n", + this); + // This is called by the media server to delete the object // after is has been released by all nodes that are using it. // We forward the function to the BMediaRoster, since the @@ -580,18 +559,16 @@ BMediaNode::HandleMessage(int32 message, // outermost destructor that will exit the thread that is // reading messages from the port (this thread contex) will // quit, and ~BMediaNode destructor won't be called ever. - - TRACE("BMediaNode::HandleMessage NODE_FINAL_RELEASE, this %p\n", this); BMessage msg(NODE_FINAL_RELEASE); msg.AddPointer("node", this); BMediaRoster::Roster()->PostMessage(&msg); - return B_OK; } case NODE_START: { - const node_start_command *command = static_cast(data); + const node_start_command* command + = static_cast(data); TRACE("BMediaNode::HandleMessage NODE_START, node %ld\n", fNodeID); Start(command->performance_time); return B_OK; @@ -599,7 +576,8 @@ BMediaNode::HandleMessage(int32 message, case NODE_STOP: { - const node_stop_command *command = static_cast(data); + const node_stop_command* command + = static_cast(data); TRACE("BMediaNode::HandleMessage NODE_STOP, node %ld\n", fNodeID); Stop(command->performance_time, command->immediate); return B_OK; @@ -607,7 +585,8 @@ BMediaNode::HandleMessage(int32 message, case NODE_SEEK: { - const node_seek_command *command = static_cast(data); + const node_seek_command* command + = static_cast(data); TRACE("BMediaNode::HandleMessage NODE_SEEK, node %ld\n", fNodeID); Seek(command->media_time, command->performance_time); return B_OK; @@ -615,9 +594,11 @@ BMediaNode::HandleMessage(int32 message, case NODE_SET_RUN_MODE: { - const node_set_run_mode_command *command = static_cast(data); - TRACE("BMediaNode::HandleMessage NODE_SET_RUN_MODE, node %ld\n", fNodeID); - // when changing this, also change PRODUCER_SET_RUN_MODE_DELAY + const node_set_run_mode_command* command + = static_cast(data); + TRACE("BMediaNode::HandleMessage NODE_SET_RUN_MODE," + " node %ld\n", fNodeID); + // Need to change PRODUCER_SET_RUN_MODE_DELAY fRunMode = command->mode; SetRunMode(fRunMode); return B_OK; @@ -625,23 +606,26 @@ BMediaNode::HandleMessage(int32 message, case NODE_TIME_WARP: { - const node_time_warp_command *command = static_cast(data); - TRACE("BMediaNode::HandleMessage NODE_TIME_WARP, node %ld\n", fNodeID); + const node_time_warp_command* command + = static_cast(data); + TRACE("BMediaNode::HandleMessage NODE_TIME_WARP," + " node %ld\n", fNodeID); TimeWarp(command->at_real_time, command->to_performance_time); return B_OK; } case NODE_PREROLL: { - TRACE("BMediaNode::HandleMessage NODE_PREROLL, node %ld\n", fNodeID); + TRACE("BMediaNode::HandleMessage NODE_PREROLL, " + " node %ld\n", fNodeID); Preroll(); return B_OK; } case NODE_ROLL: { - const node_roll_command *command - = static_cast(data); + const node_roll_command* command + = static_cast(data); TRACE("BMediaNode::HandleMessage NODE_ROLL, node %ld\n", fNodeID); @@ -657,8 +641,8 @@ BMediaNode::HandleMessage(int32 message, case NODE_SYNC_TO: { - const node_sync_to_request *request - = static_cast(data); + const node_sync_to_request* request + = static_cast(data); node_sync_to_reply reply; TRACE("BMediaNode::HandleMessage NODE_SYNC_TO, node %ld\n", @@ -677,37 +661,44 @@ BMediaNode::HandleMessage(int32 message, case NODE_SET_TIMESOURCE: { - const node_set_timesource_command *command = static_cast(data); + const node_set_timesource_command* command + = static_cast(data); - TRACE("BMediaNode::HandleMessage NODE_SET_TIMESOURCE, node %ld, timesource %ld enter\n", fNodeID, command->timesource_id); + TRACE("BMediaNode::HandleMessage NODE_SET_TIMESOURCE," + " node %ld, timesource %ld enter\n", + fNodeID, command->timesource_id); fTimeSourceID = command->timesource_id; if (fTimeSource) { - // as this node already had a timesource, we need - // we need to remove this node from time source control + // As this node already had a timesource, to remove this node + // from time source control fTimeSource->RemoveMe(this); - // Then release the time source + // Release the time source fTimeSource->Release(); - // force next call to TimeSource() to create a new object + // Force next call to TimeSource() to create a new object fTimeSource = 0; } - // create new time source object + // Create new time source object and call the SetTimeSource + // hook function to notify any derived class fTimeSource = TimeSource(); - // and call the SetTimeSource hook function to notify - // any derived class SetTimeSource(fTimeSource); - TRACE("BMediaNode::HandleMessage NODE_SET_TIMESOURCE, node %ld, timesource %ld leave\n", fNodeID, command->timesource_id); + TRACE("BMediaNode::HandleMessage NODE_SET_TIMESOURCE, node %ld," + "timesource %ld leave\n", fNodeID, command->timesource_id); return B_OK; } case NODE_GET_TIMESOURCE: { - const node_get_timesource_request *request = static_cast(data); - TRACE("BMediaNode::HandleMessage NODE_GET_TIMESOURCE, node %ld\n", fNodeID); + const node_get_timesource_request* request + = static_cast(data); + + TRACE("BMediaNode::HandleMessage NODE_GET_TIMESOURCE," + " node %ld\n", fNodeID); + node_get_timesource_reply reply; reply.timesource_id = fTimeSourceID; request->SendReply(B_OK, &reply, sizeof(reply)); @@ -716,33 +707,36 @@ BMediaNode::HandleMessage(int32 message, case NODE_REQUEST_COMPLETED: { - const node_request_completed_command *command = static_cast(data); - TRACE("BMediaNode::HandleMessage NODE_REQUEST_COMPLETED, node %ld\n", fNodeID); + const node_request_completed_command* command + = static_cast(data); + TRACE("BMediaNode::HandleMessage NODE_REQUEST_COMPLETED," + " node %ld\n", fNodeID); RequestCompleted(command->info); return B_OK; } - }; + default: + return B_ERROR; + + } return B_ERROR; } void -BMediaNode::HandleBadMessage(int32 code, - const void *buffer, - size_t size) +BMediaNode::HandleBadMessage(int32 code, const void* buffer, size_t size) { CALLED(); - TRACE("BMediaNode::HandleBadMessage: code %#08lx, buffer %p, size %ld\n", code, buffer, size); + TRACE("BMediaNode::HandleBadMessage: code %#08lx, buffer %p, size %ld\n", + code, buffer, size); if (code < NODE_MESSAGE_START || code > TIMESOURCE_MESSAGE_END) { ERROR("BMediaNode::HandleBadMessage: unknown code!\n"); } else { - /* All messages targeted to nodes should be handled here, - * messages targetted to the wrong node should be handled - * by returning an error, not by stalling the sender. - */ - const request_data *request = static_cast(buffer); + // All messages targeted to nodes should be handled here, + // messages targetted to the wrong node should be handled + // by returning an error, not by stalling the sender. + const request_data* request = static_cast(buffer); reply_data reply; request->SendReply(B_ERROR, &reply, sizeof(reply)); } @@ -753,47 +747,44 @@ void BMediaNode::AddNodeKind(uint64 kind) { TRACE("BMediaNode::AddNodeKind: node %ld, this %p\n", fNodeID, this); - fKinds |= kind; } -void * +void* BMediaNode::operator new(size_t size) { CALLED(); return ::operator new(size); } -void * -BMediaNode::operator new(size_t size, - const nothrow_t &) throw() + +void* +BMediaNode::operator new(size_t size, const nothrow_t&) throw() { CALLED(); return ::operator new(size, nothrow); } + void -BMediaNode::operator delete(void *ptr) +BMediaNode::operator delete(void* ptr) { CALLED(); ::operator delete(ptr); } + void -BMediaNode::operator delete(void * ptr, - const nothrow_t &) throw() +BMediaNode::operator delete(void* ptr, const nothrow_t&) throw() { CALLED(); ::operator delete(ptr, nothrow); } -/************************************************************* - * protected BMediaNode - *************************************************************/ -/* virtual */ status_t -BMediaNode::RequestCompleted(const media_request_info &info) +status_t +BMediaNode::RequestCompleted(const media_request_info& info) { CALLED(); // This function is called whenever a request issued by the node is completed. @@ -807,9 +798,127 @@ BMediaNode::RequestCompleted(const media_request_info &info) return B_OK; } -/************************************************************* - * private BMediaNode - *************************************************************/ + +status_t +BMediaNode::DeleteHook(BMediaNode* node) +{ + CALLED(); + // Attention! We do not unregister TimeSourceObject nodes, + // since they are only a shadow object, and the real one still exists + if ((fKinds & NODE_KIND_SHADOW_TIMESOURCE) == 0) + BMediaRoster::Roster()->UnregisterNode(this); + delete this; // delete "this" or "node", both are the same + return B_OK; +} + + +void +BMediaNode::NodeRegistered() +{ + CALLED(); + // The Media Server calls this hook function after the node has been registered. + // May be overriden by derived classes. +} + + +status_t +BMediaNode::GetNodeAttributes(media_node_attribute* outAttributes, + size_t inMaxCount) +{ + UNIMPLEMENTED(); + + return B_ERROR; +} + + +status_t +BMediaNode::AddTimer(bigtime_t at_performance_time, int32 cookie) +{ + CALLED(); + return B_ERROR; +} + + +status_t BMediaNode::_Reserved_MediaNode_0(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_1(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_2(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_3(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_4(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_5(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_6(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_7(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_8(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_9(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_10(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_11(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_12(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_13(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_14(void*) { return B_ERROR; } +status_t BMediaNode::_Reserved_MediaNode_15(void*) { return B_ERROR; } + +/* +private unimplemented +BMediaNode::BMediaNode() +BMediaNode::BMediaNode(const BMediaNode &clone) +BMediaNode &BMediaNode::operator=(const BMediaNode &clone) +*/ + +void +BMediaNode::_InitObject(const char* name, media_node_id id, uint64 kinds) +{ + TRACE("BMediaNode::_InitObject: nodeid %ld, this %p\n", id, this); + + fNodeID = id; + fRefCount = 1; + fName[0] = 0; + if (name) + strlcpy(fName, name, B_MEDIA_NAME_LENGTH); + fRunMode = B_INCREASE_LATENCY; + fKinds = kinds; + fProducerThis = 0; + fConsumerThis = 0; + fFileInterfaceThis = 0; + fControllableThis = 0; + fTimeSourceThis = 0; + + // Create control port + fControlPort = create_port(64, fName); + + // Nodes are assigned the system time source by default + fTimeSourceID = NODE_SYSTEM_TIMESOURCE_ID; + + // We can't create the timesource object here, because + // every timesource is a BMediaNode, which would result + // in infinite recursions + fTimeSource = NULL; +} + + +BMediaNode::BMediaNode(const char* name, media_node_id id, uint32 kinds) +{ + TRACE("BMediaNode::BMediaNode: name '%s', nodeid %ld, kinds %#lx\n", + name, id, kinds); + _InitObject(name, id, kinds); +} + + +int32 +BMediaNode::NewChangeTag() +{ + CALLED(); + // Change tags have been used in BeOS R4 to match up + // format change requests between producer and consumer, + // This has changed starting with R4.5 + // now "change tags" are used with the following functions: + // BMediaNode::RequestCompleted() + // BBufferConsumer::RequestFormatChange() + // BBufferConsumer::SetOutputBuffersFor() + // BBufferConsumer::SetOutputEnabled() + // BBufferConsumer::SetVideoClippingFor() + return atomic_add(&BMediaNode::_m_changeTag,1); +} + +// BeOS R4 deprecated API int32 BMediaNode::IncrementChangeTag() @@ -860,136 +969,3 @@ BMediaNode::ApplyChangeTag(int32 previously_reserved) // not supported, only for binary compatibility return B_OK; } - -/************************************************************* - * protected BMediaNode - *************************************************************/ - -/* virtual */ status_t -BMediaNode::DeleteHook(BMediaNode *node) -{ - CALLED(); - // Attention! We do not unregister TimeSourceObject nodes, - // since they are only a shadow object, and the real one still exists - if ((fKinds & NODE_KIND_SHADOW_TIMESOURCE) == 0) - BMediaRoster::Roster()->UnregisterNode(this); - delete this; // delete "this" or "node", both are the same - return B_OK; -} - - -/* virtual */ void -BMediaNode::NodeRegistered() -{ - CALLED(); - // The Media Server calls this hook function after the node has been registered. - // May be overriden by derived classes. -} - -/************************************************************* - * public BMediaNode - *************************************************************/ - -/* virtual */ status_t -BMediaNode::GetNodeAttributes(media_node_attribute *outAttributes, - size_t inMaxCount) -{ - UNIMPLEMENTED(); - - return B_ERROR; -} - - -/* virtual */ status_t -BMediaNode::AddTimer(bigtime_t at_performance_time, - int32 cookie) -{ - CALLED(); - return B_ERROR; -} - - -status_t BMediaNode::_Reserved_MediaNode_0(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_1(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_2(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_3(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_4(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_5(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_6(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_7(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_8(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_9(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_10(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_11(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_12(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_13(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_14(void *) { return B_ERROR; } -status_t BMediaNode::_Reserved_MediaNode_15(void *) { return B_ERROR; } - -/* -private unimplemented -BMediaNode::BMediaNode() -BMediaNode::BMediaNode(const BMediaNode &clone) -BMediaNode &BMediaNode::operator=(const BMediaNode &clone) -*/ - -void -BMediaNode::_InitObject(const char *name, media_node_id id, uint64 kinds) -{ - TRACE("BMediaNode::_InitObject: nodeid %ld, this %p\n", id, this); - - fNodeID = id; - fRefCount = 1; - fName[0] = 0; - if (name) - strlcpy(fName, name, B_MEDIA_NAME_LENGTH); - fRunMode = B_INCREASE_LATENCY; - fKinds = kinds; - fProducerThis = 0; - fConsumerThis = 0; - fFileInterfaceThis = 0; - fControllableThis = 0; - fTimeSourceThis = 0; - - // create control port - fControlPort = create_port(64, fName); - - // nodes are assigned the system time source by default - fTimeSourceID = NODE_SYSTEM_TIMESOURCE_ID; - - // We can't create the timesource object here, because - // every timesource is a BMediaNode, which would result - // in infinite recursions - fTimeSource = NULL; -} - - -BMediaNode::BMediaNode(const char *name, - media_node_id id, - uint32 kinds) -{ - TRACE("BMediaNode::BMediaNode: name '%s', nodeid %ld, kinds %#lx\n", name, id, kinds); - _InitObject(name, id, kinds); -} - - -/************************************************************* - * protected BMediaNode - *************************************************************/ - -/* static */ int32 -BMediaNode::NewChangeTag() -{ - CALLED(); - // change tags have been used in BeOS R4 to match up - // format change requests between producer and consumer, - // This has changed starting with R4.5 - // now "change tags" are used with - // BMediaNode::RequestCompleted() - // and - // BBufferConsumer::RequestFormatChange() - // BBufferConsumer::SetOutputBuffersFor() - // BBufferConsumer::SetOutputEnabled() - // BBufferConsumer::SetVideoClippingFor() - return atomic_add(&BMediaNode::_m_changeTag,1); -}