Skip to content

Commit 9105f21

Browse files
authored
Merge pull request #1910 from CastagnaIT/refactor_fixes
[AdaptiveStream] A couple of fixes after the refactor PR #1902
2 parents 33a9ae1 + b55292c commit 9105f21

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/common/AdaptiveStream.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ bool adaptive::AdaptiveStream::ensureSegment()
791791
"[AS-%u] Not valid buffer segment (status %i, rep. id \"%s\", period id \"%s\")",
792792
clsId, currSegBuff.State(), current_rep_->GetId().c_str(),
793793
current_period_->GetId().c_str());
794+
segment_read_pos_ = 0;
794795
return false;
795796
}
796797
// Note: In live streaming, the segments stored in the buffers may have expired
@@ -1001,12 +1002,17 @@ bool adaptive::AdaptiveStream::ReadFullBuffer(std::vector<uint8_t>& buffer)
10011002
// Signal we have read until the last byte
10021003
segment_read_pos_ = buffer.size();
10031004

1005+
// The state is updated after read/write operations
10041006
if (currSegBuffer.State() == BufferState::DOWNLOADING)
10051007
{
1006-
// Wait for the mutex release, to ensure that the segment status is updated
1008+
// So wait for the mutex release, to ensure that the segment state is updated
10071009
std::lock_guard<std::mutex> lckWorker(thread_data_->mutexWorker);
10081010
}
1009-
return currSegBuffer.State() == BufferState::DOWNLOADED;
1011+
1012+
if (currSegBuffer.State() == BufferState::INVALID)
1013+
buffer.clear();
1014+
1015+
return true;
10101016
}
10111017

10121018
return false;

0 commit comments

Comments
 (0)