2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // NodeSyncThread.h [rewrite 14oct99]
34 // Provide continuous synchronization notices on
35 // a particular BMediaNode. Notification is sent
36 // to a provided BMessenger.
38 // As long as a NodeSyncThread object exists its thread
39 // is running. The thread blocks indefinitely, waiting
40 // for a message to show up on an internal port.
42 // Sync-notice requests (via the +++++ sync() operation)
43 // trigger a message sent to that port. The thread wakes
44 // up, then calls BMediaRoster::SyncToNode() to wait
45 // until a particular performace time arrives for that node.
47 // If SyncToNode() times out, an M_TIMED_OUT message is sent;
48 // otherwise, an M_SYNC_COMPLETE message is sent.
51 // e.moon 14oct99 Rewrite begun.
53 #ifndef __NodeSyncThread_H__
54 #define __NodeSyncThread_H__
56 #include <MediaNode.h>
57 #include <Messenger.h>
60 #include "cortex_defs.h"
61 __BEGIN_CORTEX_NAMESPACE
63 class NodeSyncThread
{
64 public: // *** messages
66 // 'nodeID' (int32) media_node_id value
67 // 'perfTime' (int64) the performance time
68 // 'position' (int64) corresponding (caller-provided) position
69 M_SYNC_COMPLETE
=NodeSyncThread_message_base
,
71 // 'nodeID' (int32) media_node_id value
72 // 'error' (int32) status_t value from SyncToNode()
73 // 'perfTime' (int64) the performance time
74 // 'position' (int64) corresponding (caller-provided) position
78 public: // *** dtor/ctors
79 virtual ~NodeSyncThread();
82 const media_node
& node
,
83 BMessenger
* messenger
);
85 public: // *** operations
86 // trigger a sync operation: when 'perfTime' arrives
87 // for the node, a M_SYNC_COMPLETE message with the given
88 // position value will be sent, unless the sync operation
89 // times out, in which case M_TIMED_OUT will be sent.
100 // the messenger to inform
101 BMessenger
* m_messenger
;
103 // if the thread is running, it has exclusive write access
105 volatile bool m_syncInProgress
;
111 ssize_t m_portBufferSize
;
118 bigtime_t targetTime
;
123 static status_t
_Sync(
128 __END_CORTEX_NAMESPACE
129 #endif /*__NodeSyncThread_H__*/