* Rewrote TimeSource.h.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32696 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
2d6e435398
commit
f808efaf83
@ -1,86 +1,63 @@
|
|||||||
/*******************************************************************************
|
/*
|
||||||
/
|
* Copyright 2009, Haiku Inc. All Rights Reserved.
|
||||||
/ File: TimeSource.h
|
* Distributed under the terms of the MIT License.
|
||||||
/
|
*/
|
||||||
/ Description: A BTimeSource is something to which others can slave timing information
|
#ifndef _TIME_SOURCE_H
|
||||||
/ using the Media Kit.
|
|
||||||
/
|
|
||||||
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
|
|
||||||
/
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#if !defined(_TIME_SOURCE_H)
|
|
||||||
#define _TIME_SOURCE_H
|
#define _TIME_SOURCE_H
|
||||||
|
|
||||||
|
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
#include <MediaNode.h>
|
#include <MediaNode.h>
|
||||||
|
|
||||||
|
|
||||||
class _BSlaveNodeStorageP;
|
class _BSlaveNodeStorageP;
|
||||||
|
|
||||||
namespace BPrivate { namespace media {
|
namespace BPrivate {
|
||||||
|
namespace media {
|
||||||
class BMediaRosterEx;
|
class BMediaRosterEx;
|
||||||
class TimeSourceObject;
|
class TimeSourceObject;
|
||||||
class SystemTimeSourceObject;
|
class SystemTimeSourceObject;
|
||||||
class SlaveNodes;
|
class SlaveNodes;
|
||||||
struct TimeSourceTransmit;
|
struct TimeSourceTransmit;
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class BTimeSource :
|
class BTimeSource : public virtual BMediaNode {
|
||||||
public virtual BMediaNode
|
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
/* this has to be at the top to force a vtable */
|
|
||||||
virtual ~BTimeSource();
|
virtual ~BTimeSource();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual status_t SnoozeUntil(bigtime_t performanceTime,
|
||||||
|
bigtime_t withLatency = 0,
|
||||||
|
bool retrySignals = false);
|
||||||
|
|
||||||
virtual status_t SnoozeUntil( /* returns error if stopped */
|
bigtime_t Now();
|
||||||
bigtime_t performance_time,
|
bigtime_t PerformanceTimeFor(bigtime_t realTime);
|
||||||
bigtime_t with_latency = 0,
|
bigtime_t RealTimeFor(bigtime_t performanceTime,
|
||||||
bool retry_signals = false);
|
bigtime_t withLatency);
|
||||||
|
|
||||||
bigtime_t Now(); /* convenience, less accurate */
|
|
||||||
bigtime_t PerformanceTimeFor( /* all three go through GetTime() */
|
|
||||||
bigtime_t real_time);
|
|
||||||
bigtime_t RealTimeFor(
|
|
||||||
bigtime_t performance_time,
|
|
||||||
bigtime_t with_latency);
|
|
||||||
bool IsRunning();
|
bool IsRunning();
|
||||||
|
|
||||||
status_t GetTime( /* return B_OK if reading is usable */
|
status_t GetTime(bigtime_t* _performanceTime,
|
||||||
bigtime_t * performance_time,
|
bigtime_t* _realTime, float* _drift);
|
||||||
bigtime_t * real_time,
|
status_t GetStartLatency(bigtime_t* _latency);
|
||||||
float * drift);
|
|
||||||
|
|
||||||
static bigtime_t RealTime(); /* this produces real time, nothing else is guaranteed to */
|
static bigtime_t RealTime();
|
||||||
|
|
||||||
status_t GetStartLatency(
|
|
||||||
bigtime_t * out_latency);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
BTimeSource();
|
BTimeSource();
|
||||||
|
|
||||||
virtual status_t HandleMessage(
|
virtual status_t HandleMessage(int32 message, const void* data,
|
||||||
int32 message,
|
|
||||||
const void * data,
|
|
||||||
size_t size);
|
size_t size);
|
||||||
|
|
||||||
void PublishTime( /* call this at convenient times to update approximation */
|
void PublishTime(bigtime_t performanceTime,
|
||||||
bigtime_t performance_time,
|
bigtime_t realTime, float drift);
|
||||||
bigtime_t real_time,
|
|
||||||
float drift);
|
|
||||||
|
|
||||||
void BroadcastTimeWarp(
|
void BroadcastTimeWarp(bigtime_t atRealTime,
|
||||||
bigtime_t at_real_time,
|
bigtime_t newPerformanceTime);
|
||||||
bigtime_t new_performance_time); /* when running */
|
|
||||||
void SendRunMode(
|
|
||||||
run_mode mode);
|
|
||||||
|
|
||||||
virtual void SetRunMode(
|
void SendRunMode(run_mode mode);
|
||||||
run_mode mode); /* or, instead, SendRunMode() */
|
virtual void SetRunMode(run_mode mode);
|
||||||
|
|
||||||
enum time_source_op {
|
enum time_source_op {
|
||||||
B_TIMESOURCE_START = 1,
|
B_TIMESOURCE_START = 1,
|
||||||
@ -88,6 +65,7 @@ virtual void SetRunMode(
|
|||||||
B_TIMESOURCE_STOP_IMMEDIATELY,
|
B_TIMESOURCE_STOP_IMMEDIATELY,
|
||||||
B_TIMESOURCE_SEEK
|
B_TIMESOURCE_SEEK
|
||||||
};
|
};
|
||||||
|
|
||||||
struct time_source_op_info {
|
struct time_source_op_info {
|
||||||
time_source_op op;
|
time_source_op op;
|
||||||
int32 _reserved1;
|
int32 _reserved1;
|
||||||
@ -95,31 +73,44 @@ virtual void SetRunMode(
|
|||||||
bigtime_t performance_time;
|
bigtime_t performance_time;
|
||||||
int32 _reserved2[6];
|
int32 _reserved2[6];
|
||||||
};
|
};
|
||||||
virtual status_t TimeSourceOp(
|
|
||||||
const time_source_op_info & op,
|
virtual status_t TimeSourceOp(const time_source_op_info& op,
|
||||||
void* _reserved) = 0;
|
void* _reserved) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class BMediaNode;
|
friend class BMediaNode;
|
||||||
friend class BMediaRoster;
|
friend class BMediaRoster;
|
||||||
friend class BPrivate::media::BMediaRosterEx;
|
friend class BPrivate::media::BMediaRosterEx;
|
||||||
friend class BPrivate::media::TimeSourceObject;
|
|
||||||
friend class BPrivate::media::SystemTimeSourceObject;
|
friend class BPrivate::media::SystemTimeSourceObject;
|
||||||
|
friend class BPrivate::media::TimeSourceObject;
|
||||||
|
|
||||||
BTimeSource( /* private unimplemented */
|
BTimeSource(const BTimeSource& other);
|
||||||
const BTimeSource & clone);
|
BTimeSource& operator=(const BTimeSource& other);
|
||||||
BTimeSource & operator=(
|
// not implemented
|
||||||
const BTimeSource & clone);
|
|
||||||
|
|
||||||
/* Mmmh, stuffing! */
|
explicit BTimeSource(media_node_id id);
|
||||||
status_t _Reserved_TimeSource_0(void *); // TimeSourceOp()
|
|
||||||
|
status_t _Reserved_TimeSource_0(void*);
|
||||||
|
// used for TimeSourceOp()
|
||||||
virtual status_t _Reserved_TimeSource_1(void*);
|
virtual status_t _Reserved_TimeSource_1(void*);
|
||||||
virtual status_t _Reserved_TimeSource_2(void*);
|
virtual status_t _Reserved_TimeSource_2(void*);
|
||||||
virtual status_t _Reserved_TimeSource_3(void*);
|
virtual status_t _Reserved_TimeSource_3(void*);
|
||||||
virtual status_t _Reserved_TimeSource_4(void*);
|
virtual status_t _Reserved_TimeSource_4(void*);
|
||||||
virtual status_t _Reserved_TimeSource_5(void*);
|
virtual status_t _Reserved_TimeSource_5(void*);
|
||||||
|
|
||||||
|
virtual status_t RemoveMe(BMediaNode* node);
|
||||||
|
virtual status_t AddMe(BMediaNode* node);
|
||||||
|
|
||||||
|
void FinishCreate();
|
||||||
|
|
||||||
|
void DirectStart(bigtime_t at);
|
||||||
|
void DirectStop(bigtime_t at, bool immediate);
|
||||||
|
void DirectSeek(bigtime_t to, bigtime_t at);
|
||||||
|
void DirectSetRunMode(run_mode mode);
|
||||||
|
void DirectAddMe(const media_node& node);
|
||||||
|
void DirectRemoveMe(const media_node& node);
|
||||||
|
|
||||||
|
private:
|
||||||
bool fStarted;
|
bool fStarted;
|
||||||
area_id fArea;
|
area_id fArea;
|
||||||
volatile BPrivate::media::TimeSourceTransmit* fBuf;
|
volatile BPrivate::media::TimeSourceTransmit* fBuf;
|
||||||
@ -129,22 +120,7 @@ virtual status_t _Reserved_TimeSource_5(void *);
|
|||||||
bool fIsRealtime;
|
bool fIsRealtime;
|
||||||
bool _reserved_bool_[3];
|
bool _reserved_bool_[3];
|
||||||
uint32 _reserved_time_source_[10];
|
uint32 _reserved_time_source_[10];
|
||||||
|
|
||||||
explicit BTimeSource(
|
|
||||||
media_node_id id);
|
|
||||||
void FinishCreate(); /* called by roster and/or server */
|
|
||||||
|
|
||||||
virtual status_t RemoveMe(BMediaNode * node);
|
|
||||||
virtual status_t AddMe(BMediaNode * node);
|
|
||||||
|
|
||||||
void DirectStart(bigtime_t at);
|
|
||||||
void DirectStop(bigtime_t at, bool immediate);
|
|
||||||
void DirectSeek(bigtime_t to, bigtime_t at);
|
|
||||||
void DirectSetRunMode(run_mode mode);
|
|
||||||
void DirectAddMe(const media_node &node);
|
|
||||||
void DirectRemoveMe(const media_node &node);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* _TIME_SOURCE_H */
|
#endif // _TIME_SOURCE_H
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user