Fixed bug in automatical generation of data timestamps.
git-svn-id: http://voip.null.ro/svn/yate@1030 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
13da6ec16f
commit
927d5db29a
|
@ -485,12 +485,19 @@ void DataSource::Forward(const DataBlock& data, unsigned long tStamp)
|
|||
DDebug(DebugInfo,"Forwarding on a dead DataSource! [%p]",this);
|
||||
return;
|
||||
}
|
||||
// no timestamp provided - try to guess
|
||||
if (tStamp == (unsigned long)-1) {
|
||||
tStamp = m_timestamp;
|
||||
|
||||
// try to evaluate amount of samples in this packet
|
||||
const FormatInfo* f = m_format.getInfo();
|
||||
if (f)
|
||||
tStamp += f->guessSamples(data.length());
|
||||
unsigned long nSamp = f ? f->guessSamples(data.length()) : 0;
|
||||
|
||||
// if no timestamp provided - try to use next expected
|
||||
if (tStamp == invalidStamp())
|
||||
tStamp = m_nextStamp;
|
||||
// still no timestamp known - wild guess based on this packet size
|
||||
if (tStamp == invalidStamp()) {
|
||||
DDebug(DebugNote,"Unknow timestamp - assuming %lu + %lu [%p]",
|
||||
m_timestamp,nSamp,this);
|
||||
tStamp = m_timestamp + nSamp;
|
||||
}
|
||||
ObjList *l = m_consumers.skipNull();
|
||||
for (; l; l=l->skipNext()) {
|
||||
|
@ -498,6 +505,7 @@ void DataSource::Forward(const DataBlock& data, unsigned long tStamp)
|
|||
c->Consume(data,tStamp,this);
|
||||
}
|
||||
m_timestamp = tStamp;
|
||||
m_nextStamp = nSamp ? (tStamp + nSamp) : invalidStamp();
|
||||
}
|
||||
|
||||
bool DataSource::attach(DataConsumer* consumer, bool override)
|
||||
|
@ -582,6 +590,7 @@ void DataSource::synchronize(unsigned long tStamp)
|
|||
return;
|
||||
}
|
||||
m_timestamp = tStamp;
|
||||
m_nextStamp = invalidStamp();
|
||||
ObjList *l = m_consumers.skipNull();
|
||||
for (; l; l=l->skipNext()) {
|
||||
DataConsumer *c = static_cast<DataConsumer *>(l->get());
|
||||
|
|
19
yatephone.h
19
yatephone.h
|
@ -330,6 +330,13 @@ public:
|
|||
inline unsigned long timeStamp() const
|
||||
{ return m_timestamp; }
|
||||
|
||||
/**
|
||||
* Get the internal representation of an invalid or unknown timestamp
|
||||
* @return Invalid timestamp - unsigned long conversion of -1
|
||||
*/
|
||||
inline static unsigned long invalidStamp()
|
||||
{ return (unsigned long)-1; }
|
||||
|
||||
protected:
|
||||
DataFormat m_format;
|
||||
unsigned long m_timestamp;
|
||||
|
@ -428,7 +435,7 @@ public:
|
|||
* @param format Name of the data format, default "slin" (Signed Linear)
|
||||
*/
|
||||
inline DataSource(const char* format = "slin")
|
||||
: DataNode(format), m_translator(0) { }
|
||||
: DataNode(format), m_nextStamp(invalidStamp()), m_translator(0) { }
|
||||
|
||||
/**
|
||||
* Source's destructor - detaches all consumers
|
||||
|
@ -447,7 +454,7 @@ public:
|
|||
* @param data The raw data block to forward; an empty block ends data
|
||||
* @param tStamp Timestamp of data - typically samples
|
||||
*/
|
||||
void Forward(const DataBlock& data, unsigned long tStamp = (unsigned long)-1);
|
||||
void Forward(const DataBlock& data, unsigned long tStamp = invalidStamp());
|
||||
|
||||
/**
|
||||
* Attach a data consumer
|
||||
|
@ -489,7 +496,15 @@ public:
|
|||
*/
|
||||
void synchronize(unsigned long tStamp);
|
||||
|
||||
/**
|
||||
* Get the next expected position in the data stream
|
||||
* @return Timestamp of next expected data position, may be invalid/unknown
|
||||
*/
|
||||
inline unsigned long nextStamp() const
|
||||
{ return m_nextStamp; }
|
||||
|
||||
protected:
|
||||
unsigned long m_nextStamp;
|
||||
DataTranslator* m_translator;
|
||||
ObjList m_consumers;
|
||||
Mutex m_mutex;
|
||||
|
|
Loading…
Reference in New Issue