AdapterIO: Add IsRunning method
* The backend need to know if we can really get data. * Adapt WaitForData to be more reliable using this method.
This commit is contained in:
@@ -58,6 +58,8 @@ public:
|
|||||||
virtual status_t Open();
|
virtual status_t Open();
|
||||||
virtual void Close();
|
virtual void Close();
|
||||||
|
|
||||||
|
virtual bool IsRunning() const;
|
||||||
|
|
||||||
void SeekCompleted();
|
void SeekCompleted();
|
||||||
status_t SetBuffer(BPositionIO* buffer);
|
status_t SetBuffer(BPositionIO* buffer);
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public:
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t WaitForData(off_t position)
|
status_t WaitForData(off_t position, off_t size)
|
||||||
{
|
{
|
||||||
off_t bufferSize = 0;
|
off_t bufferSize = 0;
|
||||||
status_t ret = GetSize(&bufferSize);
|
status_t ret = GetSize(&bufferSize);
|
||||||
@@ -76,7 +76,12 @@ public:
|
|||||||
|
|
||||||
bigtime_t totalTimeOut = 0;
|
bigtime_t totalTimeOut = 0;
|
||||||
|
|
||||||
while(bufferSize <= position) {
|
while(bufferSize < position+size) {
|
||||||
|
// We are not running, no luck to receive
|
||||||
|
// more data, let's return and avoid locking.
|
||||||
|
if (!fOwner->IsRunning())
|
||||||
|
return B_NOT_SUPPORTED;
|
||||||
|
|
||||||
if (fTimeout != B_INFINITE_TIMEOUT && totalTimeOut >= fTimeout)
|
if (fTimeout != B_INFINITE_TIMEOUT && totalTimeOut >= fTimeout)
|
||||||
return B_TIMED_OUT;
|
return B_TIMED_OUT;
|
||||||
|
|
||||||
@@ -346,6 +351,13 @@ BAdapterIO::Close()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BAdapterIO::IsRunning() const
|
||||||
|
{
|
||||||
|
return fOpened;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BAdapterIO::SeekCompleted()
|
BAdapterIO::SeekCompleted()
|
||||||
{
|
{
|
||||||
@@ -415,7 +427,7 @@ BAdapterIO::_EvaluateWait(off_t pos, off_t size)
|
|||||||
|
|
||||||
TRACE("BAdapterIO::_EvaluateWait: waiting for data\n");
|
TRACE("BAdapterIO::_EvaluateWait: waiting for data\n");
|
||||||
|
|
||||||
return fBuffer->WaitForData(pos+size);
|
return fBuffer->WaitForData(pos, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user