2009-08-26 15:13:14 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Haiku Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _TIME_SOURCE_H
|
2002-07-09 16:24:59 +04:00
|
|
|
#define _TIME_SOURCE_H
|
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <MediaDefs.h>
|
|
|
|
#include <MediaNode.h>
|
|
|
|
|
|
|
|
|
|
|
|
class _BSlaveNodeStorageP;
|
2003-01-07 02:11:18 +03:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
namespace media {
|
|
|
|
class BMediaRosterEx;
|
|
|
|
class TimeSourceObject;
|
|
|
|
class SystemTimeSourceObject;
|
|
|
|
class SlaveNodes;
|
|
|
|
struct TimeSourceTransmit;
|
|
|
|
}
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
class BTimeSource : public virtual BMediaNode {
|
2002-07-09 16:24:59 +04:00
|
|
|
protected:
|
2009-08-26 15:13:14 +04:00
|
|
|
virtual ~BTimeSource();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
public:
|
2009-08-26 15:13:14 +04:00
|
|
|
virtual status_t SnoozeUntil(bigtime_t performanceTime,
|
|
|
|
bigtime_t withLatency = 0,
|
|
|
|
bool retrySignals = false);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
bigtime_t Now();
|
|
|
|
bigtime_t PerformanceTimeFor(bigtime_t realTime);
|
|
|
|
bigtime_t RealTimeFor(bigtime_t performanceTime,
|
|
|
|
bigtime_t withLatency);
|
|
|
|
bool IsRunning();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
status_t GetTime(bigtime_t* _performanceTime,
|
|
|
|
bigtime_t* _realTime, float* _drift);
|
|
|
|
status_t GetStartLatency(bigtime_t* _latency);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
static bigtime_t RealTime();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
protected:
|
|
|
|
BTimeSource();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
virtual status_t HandleMessage(int32 message, const void* data,
|
|
|
|
size_t size);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
void PublishTime(bigtime_t performanceTime,
|
|
|
|
bigtime_t realTime, float drift);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
void BroadcastTimeWarp(bigtime_t atRealTime,
|
|
|
|
bigtime_t newPerformanceTime);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
void SendRunMode(run_mode mode);
|
|
|
|
virtual void SetRunMode(run_mode mode);
|
|
|
|
|
|
|
|
enum time_source_op {
|
|
|
|
B_TIMESOURCE_START = 1,
|
|
|
|
B_TIMESOURCE_STOP,
|
|
|
|
B_TIMESOURCE_STOP_IMMEDIATELY,
|
|
|
|
B_TIMESOURCE_SEEK
|
|
|
|
};
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
struct time_source_op_info {
|
|
|
|
time_source_op op;
|
|
|
|
int32 _reserved1;
|
|
|
|
bigtime_t real_time;
|
|
|
|
bigtime_t performance_time;
|
|
|
|
int32 _reserved2[6];
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual status_t TimeSourceOp(const time_source_op_info& op,
|
|
|
|
void* _reserved) = 0;
|
|
|
|
|
|
|
|
private:
|
2002-07-09 16:24:59 +04:00
|
|
|
friend class BMediaNode;
|
|
|
|
friend class BMediaRoster;
|
2003-03-16 06:52:52 +03:00
|
|
|
friend class BPrivate::media::BMediaRosterEx;
|
2003-01-06 02:35:07 +03:00
|
|
|
friend class BPrivate::media::SystemTimeSourceObject;
|
2009-08-26 15:13:14 +04:00
|
|
|
friend class BPrivate::media::TimeSourceObject;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
BTimeSource(const BTimeSource& other);
|
|
|
|
BTimeSource& operator=(const BTimeSource& other);
|
|
|
|
// not implemented
|
|
|
|
|
|
|
|
explicit BTimeSource(media_node_id id);
|
|
|
|
|
|
|
|
status_t _Reserved_TimeSource_0(void*);
|
|
|
|
// used for TimeSourceOp()
|
|
|
|
virtual status_t _Reserved_TimeSource_1(void*);
|
|
|
|
virtual status_t _Reserved_TimeSource_2(void*);
|
|
|
|
virtual status_t _Reserved_TimeSource_3(void*);
|
|
|
|
virtual status_t _Reserved_TimeSource_4(void*);
|
|
|
|
virtual status_t _Reserved_TimeSource_5(void*);
|
|
|
|
|
|
|
|
virtual status_t RemoveMe(BMediaNode* node);
|
|
|
|
virtual status_t AddMe(BMediaNode* node);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
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;
|
|
|
|
area_id fArea;
|
|
|
|
volatile BPrivate::media::TimeSourceTransmit* fBuf;
|
|
|
|
BPrivate::media::SlaveNodes* fSlaveNodes;
|
|
|
|
|
|
|
|
area_id _reserved_area;
|
|
|
|
bool fIsRealtime;
|
|
|
|
bool _reserved_bool_[3];
|
|
|
|
uint32 _reserved_time_source_[10];
|
|
|
|
};
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
2009-08-26 15:13:14 +04:00
|
|
|
#endif // _TIME_SOURCE_H
|