Fixed timestamps when playing files with rate not 8kHz.
git-svn-id: http://yate.null.ro/svn/yate/trunk@5186 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
fb276938aa
commit
db192091ed
|
@ -51,6 +51,7 @@ private:
|
||||||
Stream* m_stream;
|
Stream* m_stream;
|
||||||
DataBlock m_data;
|
DataBlock m_data;
|
||||||
bool m_swap;
|
bool m_swap;
|
||||||
|
unsigned m_rate;
|
||||||
unsigned m_brate;
|
unsigned m_brate;
|
||||||
long m_repeatPos;
|
long m_repeatPos;
|
||||||
unsigned m_total;
|
unsigned m_total;
|
||||||
|
@ -196,6 +197,7 @@ void WaveSource::init(const String& file, bool autorepeat)
|
||||||
if (!m_stream) {
|
if (!m_stream) {
|
||||||
if (file == "-") {
|
if (file == "-") {
|
||||||
m_nodata = true;
|
m_nodata = true;
|
||||||
|
m_rate = 8000;
|
||||||
m_brate = 8000;
|
m_brate = 8000;
|
||||||
start("Wave Source");
|
start("Wave Source");
|
||||||
return;
|
return;
|
||||||
|
@ -249,7 +251,7 @@ void WaveSource::init(const String& file, bool autorepeat)
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveSource::WaveSource(const char* file, CallEndpoint* chan, bool autoclose)
|
WaveSource::WaveSource(const char* file, CallEndpoint* chan, bool autoclose)
|
||||||
: m_chan(chan), m_stream(0), m_swap(false), m_brate(0), m_repeatPos(-1),
|
: m_chan(chan), m_stream(0), m_swap(false), m_rate(8000), m_brate(0), m_repeatPos(-1),
|
||||||
m_total(0), m_time(0), m_autoclose(autoclose),
|
m_total(0), m_time(0), m_autoclose(autoclose),
|
||||||
m_nodata(false)
|
m_nodata(false)
|
||||||
{
|
{
|
||||||
|
@ -289,6 +291,7 @@ void WaveSource::detectAuFormat()
|
||||||
m_stream->seek(ntohl(header.offs));
|
m_stream->seek(ntohl(header.offs));
|
||||||
int samp = ntohl(header.freq);
|
int samp = ntohl(header.freq);
|
||||||
int chan = ntohl(header.chan);
|
int chan = ntohl(header.chan);
|
||||||
|
m_rate = samp;
|
||||||
m_brate = samp;
|
m_brate = samp;
|
||||||
switch (ntohl(header.form)) {
|
switch (ntohl(header.form)) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -341,6 +344,7 @@ bool WaveSource::computeDataRate()
|
||||||
const FormatInfo* info = m_format.getInfo();
|
const FormatInfo* info = m_format.getInfo();
|
||||||
if (!info)
|
if (!info)
|
||||||
return false;
|
return false;
|
||||||
|
m_rate = info->sampleRate;
|
||||||
m_brate = info->dataRate();
|
m_brate = info->dataRate();
|
||||||
return (m_brate != 0);
|
return (m_brate != 0);
|
||||||
}
|
}
|
||||||
|
@ -419,7 +423,7 @@ void WaveSource::run()
|
||||||
if (!looping(noChan))
|
if (!looping(noChan))
|
||||||
break;
|
break;
|
||||||
Forward(m_data,ts);
|
Forward(m_data,ts);
|
||||||
ts += m_data.length()*8000/m_brate;
|
ts += m_data.length()*m_rate/m_brate;
|
||||||
m_total += r;
|
m_total += r;
|
||||||
tpos += (r*(u_int64_t)1000000/m_brate);
|
tpos += (r*(u_int64_t)1000000/m_brate);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue