|
|
@ -33,7 +33,7 @@ StreamingJob::StreamingJob()
|
|
|
|
m_StreamPos(0),
|
|
|
|
m_StreamPos(0),
|
|
|
|
m_StartTime(0),
|
|
|
|
m_StartTime(0),
|
|
|
|
m_SkipCount(0),
|
|
|
|
m_SkipCount(0),
|
|
|
|
m_KIO_Job(NULL),
|
|
|
|
m_TDEIO_Job(NULL),
|
|
|
|
m_capturing(false)
|
|
|
|
m_capturing(false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -48,7 +48,7 @@ StreamingJob::StreamingJob(const TQString &_URL, const SoundFormat &_SoundFormat
|
|
|
|
m_StreamPos(0),
|
|
|
|
m_StreamPos(0),
|
|
|
|
m_StartTime(0),
|
|
|
|
m_StartTime(0),
|
|
|
|
m_SkipCount(0),
|
|
|
|
m_SkipCount(0),
|
|
|
|
m_KIO_Job(NULL),
|
|
|
|
m_TDEIO_Job(NULL),
|
|
|
|
m_capturing(false)
|
|
|
|
m_capturing(false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -63,7 +63,7 @@ StreamingJob::StreamingJob(const StreamingJob &c)
|
|
|
|
m_StreamPos(0),
|
|
|
|
m_StreamPos(0),
|
|
|
|
m_StartTime(0),
|
|
|
|
m_StartTime(0),
|
|
|
|
m_SkipCount(0),
|
|
|
|
m_SkipCount(0),
|
|
|
|
m_KIO_Job(NULL),
|
|
|
|
m_TDEIO_Job(NULL),
|
|
|
|
m_capturing(c.m_capturing)
|
|
|
|
m_capturing(c.m_capturing)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -77,8 +77,8 @@ void StreamingJob::setURL(const TQString &url)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_URL != url) {
|
|
|
|
if (m_URL != url) {
|
|
|
|
m_URL = url;
|
|
|
|
m_URL = url;
|
|
|
|
delete m_KIO_Job;
|
|
|
|
delete m_TDEIO_Job;
|
|
|
|
m_KIO_Job = NULL;
|
|
|
|
m_TDEIO_Job = NULL;
|
|
|
|
if (!m_capturing) {
|
|
|
|
if (!m_capturing) {
|
|
|
|
startPutJob();
|
|
|
|
startPutJob();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -105,13 +105,13 @@ void StreamingJob::setBufferSize(size_t buffer_size)
|
|
|
|
|
|
|
|
|
|
|
|
bool StreamingJob::startPutJob()
|
|
|
|
bool StreamingJob::startPutJob()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_KIO_Job = TDEIO::put(m_URL, -1, true, false, false);
|
|
|
|
m_TDEIO_Job = TDEIO::put(m_URL, -1, true, false, false);
|
|
|
|
if (!m_KIO_Job)
|
|
|
|
if (!m_TDEIO_Job)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
m_KIO_Job->setAsyncDataEnabled(true);
|
|
|
|
m_TDEIO_Job->setAsyncDataEnabled(true);
|
|
|
|
connect (m_KIO_Job, TQT_SIGNAL(dataReq(TDEIO::Job *job, TQByteArray &data)),
|
|
|
|
connect (m_TDEIO_Job, TQT_SIGNAL(dataReq(TDEIO::Job *job, TQByteArray &data)),
|
|
|
|
this, TQT_SLOT(slotWriteData (TDEIO::Job *job, TQByteArray &data)));
|
|
|
|
this, TQT_SLOT(slotWriteData (TDEIO::Job *job, TQByteArray &data)));
|
|
|
|
connect (m_KIO_Job, TQT_SIGNAL(result(TDEIO::Job *)),
|
|
|
|
connect (m_TDEIO_Job, TQT_SIGNAL(result(TDEIO::Job *)),
|
|
|
|
this, TQT_SLOT(slotIOJobResult(TDEIO::Job *)));
|
|
|
|
this, TQT_SLOT(slotIOJobResult(TDEIO::Job *)));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -126,10 +126,10 @@ bool StreamingJob::startPlayback()
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
m_StartTime = time(NULL);
|
|
|
|
m_StartTime = time(NULL);
|
|
|
|
m_StreamPos = 0;
|
|
|
|
m_StreamPos = 0;
|
|
|
|
if (m_KIO_Job->error()) {
|
|
|
|
if (m_TDEIO_Job->error()) {
|
|
|
|
emit logStreamError(m_URL, m_KIO_Job->errorString());
|
|
|
|
emit logStreamError(m_URL, m_TDEIO_Job->errorString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_KIO_Job->error() == 0;
|
|
|
|
return m_TDEIO_Job->error() == 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -140,8 +140,8 @@ bool StreamingJob::stopPlayback()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_OpenCounter) {
|
|
|
|
if (m_OpenCounter) {
|
|
|
|
if (!--m_OpenCounter) {
|
|
|
|
if (!--m_OpenCounter) {
|
|
|
|
delete m_KIO_Job;
|
|
|
|
delete m_TDEIO_Job;
|
|
|
|
m_KIO_Job = NULL;
|
|
|
|
m_TDEIO_Job = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -150,13 +150,13 @@ bool StreamingJob::stopPlayback()
|
|
|
|
|
|
|
|
|
|
|
|
bool StreamingJob::startGetJob()
|
|
|
|
bool StreamingJob::startGetJob()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_KIO_Job = TDEIO::get(m_URL, false, false);
|
|
|
|
m_TDEIO_Job = TDEIO::get(m_URL, false, false);
|
|
|
|
if (!m_KIO_Job)
|
|
|
|
if (!m_TDEIO_Job)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
m_KIO_Job->setAsyncDataEnabled(true);
|
|
|
|
m_TDEIO_Job->setAsyncDataEnabled(true);
|
|
|
|
connect (m_KIO_Job, TQT_SIGNAL(data(TDEIO::Job *, const TQByteArray &)),
|
|
|
|
connect (m_TDEIO_Job, TQT_SIGNAL(data(TDEIO::Job *, const TQByteArray &)),
|
|
|
|
this, TQT_SLOT(slotReadData(TDEIO::Job *, const TQByteArray &)));
|
|
|
|
this, TQT_SLOT(slotReadData(TDEIO::Job *, const TQByteArray &)));
|
|
|
|
connect (m_KIO_Job, TQT_SIGNAL(result(TDEIO::Job *)),
|
|
|
|
connect (m_TDEIO_Job, TQT_SIGNAL(result(TDEIO::Job *)),
|
|
|
|
this, TQT_SLOT(slotIOJobResult(TDEIO::Job *)));
|
|
|
|
this, TQT_SLOT(slotIOJobResult(TDEIO::Job *)));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -173,10 +173,10 @@ bool StreamingJob::startCapture(const SoundFormat &/*proposed_format*/,
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
m_StartTime = time(NULL);
|
|
|
|
m_StartTime = time(NULL);
|
|
|
|
m_StreamPos = 0;
|
|
|
|
m_StreamPos = 0;
|
|
|
|
if (m_KIO_Job->error()) {
|
|
|
|
if (m_TDEIO_Job->error()) {
|
|
|
|
emit logStreamError(m_URL, m_KIO_Job->errorString());
|
|
|
|
emit logStreamError(m_URL, m_TDEIO_Job->errorString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_KIO_Job->error() == 0;
|
|
|
|
return m_TDEIO_Job->error() == 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++m_OpenCounter;
|
|
|
|
++m_OpenCounter;
|
|
|
|
real_format = m_SoundFormat;
|
|
|
|
real_format = m_SoundFormat;
|
|
|
@ -188,8 +188,8 @@ bool StreamingJob::stopCapture()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_OpenCounter) {
|
|
|
|
if (m_OpenCounter) {
|
|
|
|
if (!--m_OpenCounter) {
|
|
|
|
if (!--m_OpenCounter) {
|
|
|
|
delete m_KIO_Job;
|
|
|
|
delete m_TDEIO_Job;
|
|
|
|
m_KIO_Job = NULL;
|
|
|
|
m_TDEIO_Job = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -211,7 +211,7 @@ void StreamingJob::slotReadData (TDEIO::Job */*job*/, const TQByteArray &data
|
|
|
|
m_StreamPos += free;
|
|
|
|
m_StreamPos += free;
|
|
|
|
|
|
|
|
|
|
|
|
if (m_Buffer.getFreeSize() < data.size()) {
|
|
|
|
if (m_Buffer.getFreeSize() < data.size()) {
|
|
|
|
m_KIO_Job->suspend();
|
|
|
|
m_TDEIO_Job->suspend();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -224,7 +224,7 @@ void StreamingJob::slotWriteData (TDEIO::Job */*job*/, TQByteArray &)
|
|
|
|
size = m_Buffer.takeData(buf, size);
|
|
|
|
size = m_Buffer.takeData(buf, size);
|
|
|
|
TQByteArray data;
|
|
|
|
TQByteArray data;
|
|
|
|
data.assign(buf, size);
|
|
|
|
data.assign(buf, size);
|
|
|
|
m_KIO_Job->sendAsyncData(data);
|
|
|
|
m_TDEIO_Job->sendAsyncData(data);
|
|
|
|
m_StreamPos += size;
|
|
|
|
m_StreamPos += size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
@ -264,7 +264,7 @@ void StreamingJob::removeData(size_t size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_Buffer.removeData(size);
|
|
|
|
m_Buffer.removeData(size);
|
|
|
|
if (m_Buffer.getFreeSize() > m_Buffer.getSize() / 2) {
|
|
|
|
if (m_Buffer.getFreeSize() > m_Buffer.getSize() / 2) {
|
|
|
|
m_KIO_Job->resume();
|
|
|
|
m_TDEIO_Job->resume();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|