Skip to content

Commit

Permalink
[eFilePushThread]
Browse files Browse the repository at this point in the history
* change getNextSourceSpan event trigger
  • Loading branch information
jbleyel committed Aug 20, 2024
1 parent ea31720 commit 64f70b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
11 changes: 6 additions & 5 deletions lib/dvb/dvb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ static size_t diff_upto(off_t high, off_t low, size_t max)
}

/* remember, this gets called from another thread. */
void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off_t &start, size_t &size, int blocksize)
void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off_t &start, size_t &size, int blocksize, int &sof)
{
unsigned int max = align(1024*1024*1024, blocksize);
current_offset = align(current_offset, blocksize);
Expand Down Expand Up @@ -2240,7 +2240,7 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
if (current_offset < i->second)
{
start = current_offset;
size = align(diff_upto(i->second, start, max), blocksize);
size = diff_upto(i->second, start, max);
//eDebug("[eDVBChannel] HIT, %lld < %lld < %lld, size: %zd", i->first, current_offset, i->second, size);
return;
}
Expand All @@ -2258,7 +2258,7 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
{
eDebug("[eDVBChannel] reached SOF");
m_skipmode_m = 0;
m_pvr_thread->sendEvent(eFilePushThread::evtUser);
sof = 1;
}
}
else
Expand All @@ -2277,11 +2277,12 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
}
}

if ((current_offset < -m_skipmode_m) && (m_skipmode_m < 0))
// if ((current_offset < -m_skipmode_m) && (m_skipmode_m < 0))
if ((current_offset < 0) && (m_skipmode_m < 0))
{
eDebug("[eDVBChannel] reached SOF");
m_skipmode_m = 0;
m_pvr_thread->sendEvent(eFilePushThread::evtUser);
sof = 1;
}

start = current_offset;
Expand Down
2 changes: 1 addition & 1 deletion lib/dvb/dvb.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class eDVBChannel: public iDVBPVRChannel, public iFilePushScatterGather, public
int m_skipmode_m, m_skipmode_n, m_skipmode_frames, m_skipmode_frames_remainder;

std::list<std::pair<off_t, off_t> > m_source_span;
void getNextSourceSpan(off_t current_offset, size_t bytes_read, off_t &start, size_t &size, int blocksize);
void getNextSourceSpan(off_t current_offset, size_t bytes_read, off_t &start, size_t &size, int blocksize, int &sof);
void flushPVR(iDVBDemux *decoding_demux=0);

eSingleLock m_cuesheet_lock;
Expand Down
12 changes: 8 additions & 4 deletions lib/dvb/filepush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ void eFilePushThread::thread()
size_t bytes_read = 0;
off_t current_span_offset = 0;
size_t current_span_remaining = 0;
m_sof = 0;

while (!m_stop)
{
if (m_sg && !current_span_remaining)
{
m_sg->getNextSourceSpan(m_current_position, bytes_read, current_span_offset, current_span_remaining, m_blocksize);
m_sg->getNextSourceSpan(m_current_position, bytes_read, current_span_offset, current_span_remaining, m_blocksize, m_sof);
ASSERT(!(current_span_remaining % m_blocksize));
m_current_position = current_span_offset;
bytes_read = 0;
Expand All @@ -78,7 +79,7 @@ void eFilePushThread::thread()
/* align to blocksize */
maxread -= maxread % m_blocksize;

if (maxread)
if (maxread && !m_sof)
{
#ifdef SHOW_WRITE_TIME
struct timeval starttime;
Expand Down Expand Up @@ -118,7 +119,7 @@ void eFilePushThread::thread()
if (d)
buf_end -= d;

if (buf_end == 0)
if (buf_end == 0 || m_sof == 1)
{
/* on EOF, try COMMITting once. */
if (m_send_pvr_commit)
Expand Down Expand Up @@ -149,7 +150,10 @@ void eFilePushThread::thread()
over and over until somebody responds.
in stream_mode, think of evtEOF as "buffer underrun occurred". */
sendEvent(evtEOF);
if (m_sof == 0)
sendEvent(evtEOF);
else
sendEvent(evtUser); // start of file event

if (m_stream_mode)
{
Expand Down

0 comments on commit 64f70b2

Please sign in to comment.