Skip to content

Commit

Permalink
changed: move retrieval of cache status to iocontrol instead of seek
Browse files Browse the repository at this point in the history
This also changes it to a structure, so we can extend it with info on if it's full or not. (needed if we want progressive startup with limited cache size)
  • Loading branch information
elupus committed Mar 26, 2011
1 parent d7d5a52 commit da83718
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
7 changes: 4 additions & 3 deletions xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamFile.cpp
Expand Up @@ -116,10 +116,11 @@ __int64 CDVDInputStreamFile::GetLength()

__int64 CDVDInputStreamFile::GetCachedBytes()
{
if(!m_pFile)
SCacheStatus status;
if(m_pFile && m_pFile->IoControl(IOCTRL_CACHE_STATUS, &status) >= 0)
return status.forward;
else
return -1;

return m_pFile->Seek(0, SEEK_BUFFERED);
}

BitstreamStats CDVDInputStreamFile::GetBitstreamStats() const
Expand Down
14 changes: 12 additions & 2 deletions xbmc/filesystem/FileCache.cpp
Expand Up @@ -284,8 +284,6 @@ int64_t CFileCache::Seek(int64_t iFilePosition, int iWhence)
iTarget = iCurPos + iTarget;
else if (iWhence == SEEK_POSSIBLE)
return m_seekPossible;
else if (iWhence == SEEK_BUFFERED)
return m_pCache->WaitForData(0, 0);
else if (iWhence != SEEK_SET)
return -1;

Expand Down Expand Up @@ -350,3 +348,15 @@ CStdString CFileCache::GetContent()

return m_source.GetImplemenation()->GetContent();
}

int CFileCache::IoControl(EIoControl request, void* param)
{
if(request == IOCTRL_CACHE_STATUS)
{
SCacheStatus* status = (SCacheStatus*)param;
status->forward = m_pCache->WaitForData(0, 0);
return 0;
}

return -1;
}
7 changes: 6 additions & 1 deletion xbmc/filesystem/IFile.h
Expand Up @@ -39,7 +39,6 @@
#include <sys/stat.h>

#define SEEK_POSSIBLE 0x10 // flag used to check if protocol allows seeks
#define SEEK_BUFFERED 0x11 // how many bytes forward is buffered

namespace XFILE
{
Expand All @@ -50,8 +49,14 @@ struct SNativeIoControl
void* param;
};

struct SCacheStatus
{
uint64_t forward; /**< number of bytes cached forward of current position */
};

typedef enum {
IOCTRL_NATIVE = 1, /**< SNativeIoControl structure, containing what should be passed to native ioctrl */
IOCTRL_CACHE_STATUS = 3, /**< SCacheStatus structure */
} EIoControl;

class IFile
Expand Down

0 comments on commit da83718

Please sign in to comment.