1f4ec236cSAxel Dörfler /* 2f4ec236cSAxel Dörfler * Copyright 2002 Marcus Overhagen. All Rights Reserved. 3f4ec236cSAxel Dörfler * This file may be used under the terms of the MIT License. 4f4ec236cSAxel Dörfler */ 5287f7492Sbeveloper 6f4ec236cSAxel Dörfler 7f4ec236cSAxel Dörfler /*! The object returned by BMediaRoster's 8f4ec236cSAxel Dörfler MakeTimeSourceFor(const media_node& forNode); 9f4ec236cSAxel Dörfler */ 10f4ec236cSAxel Dörfler 11f4ec236cSAxel Dörfler 12f4ec236cSAxel Dörfler #include "TimeSourceObject.h" 13f4ec236cSAxel Dörfler 14287f7492Sbeveloper #include <stdio.h> 15758b1d0eSIngo Weinhold #include <string.h> 16f4ec236cSAxel Dörfler 17287f7492Sbeveloper #include <MediaRoster.h> 18f4ec236cSAxel Dörfler #include <OS.h> 19f4ec236cSAxel Dörfler 20f4ec236cSAxel Dörfler #include <MediaMisc.h> 21f4ec236cSAxel Dörfler #include <debug.h> 22f4ec236cSAxel Dörfler 23835140c8Sbeveloper #include "TimeSourceObjectManager.h" 24287f7492Sbeveloper 25f4ec236cSAxel Dörfler 26d6379053Sbeveloper TimeSourceObject::TimeSourceObject(const media_node& node) 27f4ec236cSAxel Dörfler : 28f4ec236cSAxel Dörfler BMediaNode("some timesource object", node.node, node.kind), 29d6379053Sbeveloper BTimeSource(node.node) 30287f7492Sbeveloper { 314295907bSbeveloper TRACE("TimeSourceObject::TimeSourceObject enter, id = %ld\n", node.node); 32d6379053Sbeveloper if (fControlPort > 0) 33287f7492Sbeveloper delete_port(fControlPort); 3492e575c1Sbeveloper 35f4ec236cSAxel Dörfler // We use the control port of the real time source object. 3692e575c1Sbeveloper // this way, all messages are send to the real time source, 3792e575c1Sbeveloper // and this shadow object won't receive any. 38d6379053Sbeveloper fControlPort = node.port; 39f4ec236cSAxel Dörfler 40d6379053Sbeveloper ASSERT(fNodeID == node.node); 41d6379053Sbeveloper ASSERT(fKinds == node.kind); 42d6379053Sbeveloper 435917dd5bSbeveloper if (node.node == NODE_SYSTEM_TIMESOURCE_ID) { 44*3e6fa229SStephan Aßmus strcpy(fName, "System clock"); 4592e575c1Sbeveloper fIsRealtime = true; 465917dd5bSbeveloper } else { 47f4ec236cSAxel Dörfler live_node_info liveNodeInfo; 48f4ec236cSAxel Dörfler if (BMediaRoster::Roster()->GetLiveNodeInfo(node, &liveNodeInfo) 49f4ec236cSAxel Dörfler == B_OK) 50f4ec236cSAxel Dörfler strlcpy(fName, liveNodeInfo.name, B_MEDIA_NAME_LENGTH); 51f4ec236cSAxel Dörfler else 52f4ec236cSAxel Dörfler snprintf(fName, B_MEDIA_NAME_LENGTH, "timesource %ld", node.node); 535917dd5bSbeveloper } 54d6379053Sbeveloper 55d6379053Sbeveloper AddNodeKind(NODE_KIND_SHADOW_TIMESOURCE); 5686bce45bSbeveloper AddNodeKind(NODE_KIND_NO_REFCOUNTING); 5786bce45bSbeveloper 584295907bSbeveloper TRACE("TimeSourceObject::TimeSourceObject leave, node id %ld\n", fNodeID); 59287f7492Sbeveloper } 60287f7492Sbeveloper 61f4ec236cSAxel Dörfler 62f4ec236cSAxel Dörfler status_t 63f4ec236cSAxel Dörfler TimeSourceObject::TimeSourceOp(const time_source_op_info& op, void* _reserved) 64287f7492Sbeveloper { 6592e575c1Sbeveloper // we don't get anything here 66287f7492Sbeveloper return B_OK; 67287f7492Sbeveloper } 68287f7492Sbeveloper 69f4ec236cSAxel Dörfler 70f4ec236cSAxel Dörfler BMediaAddOn* 71f4ec236cSAxel Dörfler TimeSourceObject::AddOn(int32* _id) const 72287f7492Sbeveloper { 73f4ec236cSAxel Dörfler if (_id != NULL) 74f4ec236cSAxel Dörfler *_id = 0; 75f4ec236cSAxel Dörfler 76287f7492Sbeveloper return NULL; 77287f7492Sbeveloper } 78835140c8Sbeveloper 79f4ec236cSAxel Dörfler 80f4ec236cSAxel Dörfler status_t 81835140c8Sbeveloper TimeSourceObject::DeleteHook(BMediaNode* node) 82835140c8Sbeveloper { 8392e575c1Sbeveloper // if (fIsRealtime) { 8492e575c1Sbeveloper // ERROR("TimeSourceObject::DeleteHook: system time source clone delete hook called\n"); 8592e575c1Sbeveloper // return B_ERROR; 8692e575c1Sbeveloper // } 876813f2c7SIngo Weinhold PRINT(1, "TimeSourceObject::DeleteHook enter\n"); 88f4ec236cSAxel Dörfler gTimeSourceObjectManager->ObjectDeleted(this); 89f4ec236cSAxel Dörfler status_t status = BTimeSource::DeleteHook(node); 906813f2c7SIngo Weinhold PRINT(1, "TimeSourceObject::DeleteHook leave\n"); 910e21b167Sbeveloper return status; 92835140c8Sbeveloper } 93835140c8Sbeveloper 94