1 /*********************************************************************** 2 * Copyright (c) 2002 Marcus Overhagen. All Rights Reserved. 3 * This file may be used under the terms of the OpenBeOS License. 4 * 5 * The object returned by BMediaRoster's 6 * BTimeSource * MakeTimeSourceFor(const media_node & for_node); 7 * 8 ***********************************************************************/ 9 10 #include <OS.h> 11 #include <stdio.h> 12 #include <string.h> 13 #include <MediaRoster.h> 14 #include "MediaMisc.h" 15 #include "TimeSourceObject.h" 16 #include "TimeSourceObjectManager.h" 17 18 TimeSourceObject::TimeSourceObject(const media_node &node) 19 : BMediaNode("some timesource object", node.node, node.kind), 20 BTimeSource(node.node) 21 { 22 TRACE("TimeSourceObject::TimeSourceObject enter, id = %ld\n", node.node); 23 if (fControlPort > 0) 24 delete_port(fControlPort); 25 26 // we use the control port of the real time source object. 27 // this way, all messages are send to the real time source, 28 // and this shadow object won't receive any. 29 fControlPort = node.port; 30 ASSERT(fNodeID == node.node); 31 ASSERT(fKinds == node.kind); 32 33 if (node.node == NODE_SYSTEM_TIMESOURCE_ID) { 34 strcpy(fName, "System Clock"); 35 fIsRealtime = true; 36 } else { 37 live_node_info lni; 38 if (B_OK == BMediaRoster::Roster()->GetLiveNodeInfo(node, &lni)) { 39 strcpy(fName, lni.name); 40 } else { 41 sprintf(fName, "timesource %ld", node.node); 42 } 43 } 44 45 AddNodeKind(NODE_KIND_SHADOW_TIMESOURCE); 46 AddNodeKind(NODE_KIND_NO_REFCOUNTING); 47 48 TRACE("TimeSourceObject::TimeSourceObject leave, node id %ld\n", fNodeID); 49 } 50 51 /* virtual */ status_t 52 TimeSourceObject::TimeSourceOp( 53 const time_source_op_info & op, 54 void * _reserved) 55 { 56 // we don't get anything here 57 return B_OK; 58 } 59 60 /* virtual */ BMediaAddOn* 61 TimeSourceObject::AddOn(int32 *internal_id) const 62 { 63 if (internal_id) 64 *internal_id = 0; 65 return NULL; 66 } 67 68 /* virtual */ status_t 69 TimeSourceObject::DeleteHook(BMediaNode *node) 70 { 71 status_t status; 72 // if (fIsRealtime) { 73 // ERROR("TimeSourceObject::DeleteHook: system time source clone delete hook called\n"); 74 // return B_ERROR; 75 // } 76 printf("TimeSourceObject::DeleteHook enter\n"); 77 _TimeSourceObjectManager->ObjectDeleted(this); 78 status = BTimeSource::DeleteHook(node); 79 printf("TimeSourceObject::DeleteHook leave\n"); 80 return status; 81 } 82 83