Skip to content

Commit

Permalink
AdapterIO: Size could be 0
Browse files Browse the repository at this point in the history
* Also avoid seeking completely when we are sure
we have to block.
  • Loading branch information
Numerio committed Jun 22, 2016
1 parent 6b69757 commit bcab157
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/kits/media/AdapterIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class RelativePositionIO : public BPositionIO
// block on that.
if (IsMutable())
return B_WOULD_BLOCK;
else if (size == 0)
return B_RESOURCE_UNAVAILABLE;
else
return B_ERROR;
}
Expand Down Expand Up @@ -319,13 +321,15 @@ BAdapterIO::_EvaluateWait(off_t pos)

status_t err = fBuffer->EvaluatePosition(pos);

if (err != B_RESOURCE_UNAVAILABLE && err != B_OK)
return B_UNSUPPORTED;

if (err == B_RESOURCE_UNAVAILABLE && fBuffer->IsStreaming()
&& fBuffer->IsSeekable()) {
if (SeekRequested(pos) != B_OK)
if (err != B_WOULD_BLOCK) {
if (err != B_RESOURCE_UNAVAILABLE && err != B_OK)
return B_UNSUPPORTED;

if (err == B_RESOURCE_UNAVAILABLE && fBuffer->IsStreaming()
&& fBuffer->IsSeekable()) {
if (SeekRequested(pos) != B_OK)
return B_UNSUPPORTED;
}
}

return fBuffer->WaitForData(pos);
Expand Down

0 comments on commit bcab157

Please sign in to comment.