Add more stop_ tests so that when we are told to terminate, we actually do so.
This commit is contained in:
parent
b05bc211f7
commit
838704e58e
|
@ -109,7 +109,7 @@ void ZoneMinderFifoSource::WriteRun() {
|
||||||
fuNal.buffer()[2] = fuNal.buffer()[2]&~0x80; // FU header (no S bit)
|
fuNal.buffer()[2] = fuNal.buffer()[2]&~0x80; // FU header (no S bit)
|
||||||
headerSize = 3;
|
headerSize = 3;
|
||||||
}
|
}
|
||||||
while (nalRemaining) {
|
while (nalRemaining && !stop_) {
|
||||||
if ( nalRemaining < maxNalSize ) {
|
if ( nalRemaining < maxNalSize ) {
|
||||||
// This is the last fragment:
|
// This is the last fragment:
|
||||||
fuNal.buffer()[headerSize-1] |= 0x40; // set the E bit in the FU header
|
fuNal.buffer()[headerSize-1] |= 0x40; // set the E bit in the FU header
|
||||||
|
@ -166,7 +166,7 @@ int ZoneMinderFifoSource::getNextFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug(3, "%s bytes read %d bytes, buffer size %u", m_fifo.c_str(), bytes_read, m_buffer.size());
|
Debug(3, "%s bytes read %d bytes, buffer size %u", m_fifo.c_str(), bytes_read, m_buffer.size());
|
||||||
while (m_buffer.size()) {
|
while (m_buffer.size() and !stop_) {
|
||||||
unsigned int data_size = 0;
|
unsigned int data_size = 0;
|
||||||
int64_t pts;
|
int64_t pts;
|
||||||
unsigned char *header_end = nullptr;
|
unsigned char *header_end = nullptr;
|
||||||
|
@ -224,7 +224,7 @@ int ZoneMinderFifoSource::getNextFrame() {
|
||||||
int bytes_needed = data_size - (m_buffer.size() - header_size);
|
int bytes_needed = data_size - (m_buffer.size() - header_size);
|
||||||
if (bytes_needed > 0) {
|
if (bytes_needed > 0) {
|
||||||
Debug(4, "Need another %d bytes. Trying to read them", bytes_needed);
|
Debug(4, "Need another %d bytes. Trying to read them", bytes_needed);
|
||||||
while (bytes_needed) {
|
while (bytes_needed and !stop_) {
|
||||||
bytes_read = m_buffer.read_into(m_fd, bytes_needed);
|
bytes_read = m_buffer.read_into(m_fd, bytes_needed);
|
||||||
if (bytes_read <= 0) {
|
if (bytes_read <= 0) {
|
||||||
Debug(1, "Failed to read another %d bytes, got %d.", bytes_needed, bytes_read);
|
Debug(1, "Failed to read another %d bytes, got %d.", bytes_needed, bytes_read);
|
||||||
|
@ -252,13 +252,14 @@ int ZoneMinderFifoSource::getNextFrame() {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lck(mutex_);
|
std::unique_lock<std::mutex> lck(mutex_);
|
||||||
Debug(3, "have lock");
|
Debug(3, "have lock");
|
||||||
while (framesList.size()) {
|
while (!stop_ && framesList.size()) {
|
||||||
std::pair<unsigned char*, size_t> nal = framesList.front();
|
std::pair<unsigned char*, size_t> nal = framesList.front();
|
||||||
framesList.pop_front();
|
framesList.pop_front();
|
||||||
NAL_Frame *Nal = new NAL_Frame(nal.first, nal.second, pts);
|
NAL_Frame *Nal = new NAL_Frame(nal.first, nal.second, pts);
|
||||||
m_nalQueue.push(Nal);
|
m_nalQueue.push(Nal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Debug(3, "notifying");
|
||||||
condition_.notify_all();
|
condition_.notify_all();
|
||||||
} // end while m_buffer.size()
|
} // end while m_buffer.size()
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue