tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / media / TimeSourceObject.cpp
blob580880eb0e58e88f66b0f6ac502ddfb524d18973
1 /*
2 * Copyright 2002 Marcus Overhagen. All Rights Reserved.
3 * This file may be used under the terms of the MIT License.
4 */
7 /*! The object returned by BMediaRoster's
8 MakeTimeSourceFor(const media_node& forNode);
9 */
12 #include "TimeSourceObject.h"
14 #include <stdio.h>
15 #include <string.h>
17 #include <MediaRoster.h>
18 #include <OS.h>
20 #include <MediaMisc.h>
21 #include <debug.h>
23 #include "TimeSourceObjectManager.h"
26 TimeSourceObject::TimeSourceObject(const media_node& node)
28 BMediaNode("some timesource object", node.node, node.kind),
29 BTimeSource(node.node)
31 TRACE("TimeSourceObject::TimeSourceObject enter, id = %ld\n", node.node);
32 if (fControlPort > 0)
33 delete_port(fControlPort);
35 // We use the control port of the real time source object.
36 // this way, all messages are send to the real time source,
37 // and this shadow object won't receive any.
38 fControlPort = node.port;
40 ASSERT(fNodeID == node.node);
41 ASSERT(fKinds == node.kind);
43 if (node.node == NODE_SYSTEM_TIMESOURCE_ID) {
44 strcpy(fName, "System clock");
45 fIsRealtime = true;
46 } else {
47 live_node_info liveNodeInfo;
48 if (BMediaRoster::Roster()->GetLiveNodeInfo(node, &liveNodeInfo)
49 == B_OK)
50 strlcpy(fName, liveNodeInfo.name, B_MEDIA_NAME_LENGTH);
51 else {
52 snprintf(fName, B_MEDIA_NAME_LENGTH, "timesource %" B_PRId32,
53 node.node);
57 AddNodeKind(NODE_KIND_SHADOW_TIMESOURCE);
58 AddNodeKind(NODE_KIND_NO_REFCOUNTING);
60 TRACE("TimeSourceObject::TimeSourceObject leave, node id %" B_PRId32 "\n",
61 fNodeID);
65 status_t
66 TimeSourceObject::TimeSourceOp(const time_source_op_info& op, void* _reserved)
68 // we don't get anything here
69 return B_OK;
73 BMediaAddOn*
74 TimeSourceObject::AddOn(int32* _id) const
76 if (_id != NULL)
77 *_id = 0;
79 return NULL;
83 status_t
84 TimeSourceObject::DeleteHook(BMediaNode* node)
86 // if (fIsRealtime) {
87 // ERROR("TimeSourceObject::DeleteHook: system time source clone delete hook called\n");
88 // return B_ERROR;
89 // }
90 PRINT(1, "TimeSourceObject::DeleteHook enter\n");
91 gTimeSourceObjectManager->ObjectDeleted(this);
92 status_t status = BTimeSource::DeleteHook(node);
93 PRINT(1, "TimeSourceObject::DeleteHook leave\n");
94 return status;