Skip to content

Commit

Permalink
Merge pull request #216 from phunkyfish/fix-file-open-omega
Browse files Browse the repository at this point in the history
Disable buffering to fix incompatibility with Kodi's file stream buffer - Omega
  • Loading branch information
phunkyfish authored Oct 19, 2024
2 parents ee1bcb8 + 947160e commit 233664a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pvr.mediaportal.tvserver/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.mediaportal.tvserver"
version="21.0.3"
version="21.0.4"
name="MediaPortal PVR Client"
provider-name="Marcel Groothuis">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
3 changes: 3 additions & 0 deletions pvr.mediaportal.tvserver/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v21.0.4
- Disable buffering to fix incompatibility with Kodi's file stream buffer

v21.0.3
- Update settings to new format

Expand Down
14 changes: 12 additions & 2 deletions src/lib/tsreader/FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
/* calcuate bitrate for file while reading */
#define READ_BITRATE 0x10

/* indicate that caller want open a file without intermediate buffer regardless to file type */
#define READ_NO_BUFFER 0x200

template<typename T> void SafeDelete(T*& p)
{
if (p)
Expand All @@ -69,7 +72,8 @@ namespace MPTV
{
FileReader::FileReader() :
m_fileSize(0),
m_fileName("")
m_fileName(""),
m_flags(READ_NO_CACHE | READ_TRUNCATED | READ_BITRATE)
{
}

Expand Down Expand Up @@ -125,7 +129,7 @@ namespace MPTV
do
{
kodi::Log(ADDON_LOG_INFO, "FileReader::OpenFile() %s.", m_fileName.c_str());
if (m_hFile.OpenFile(m_fileName, READ_NO_CACHE | READ_TRUNCATED | READ_BITRATE))
if (m_hFile.OpenFile(m_fileName, m_flags))
{
break;
}
Expand Down Expand Up @@ -205,6 +209,12 @@ namespace MPTV
}


void FileReader::SetNoBuffer(void)
{
m_flags |= READ_NO_BUFFER;
}


long FileReader::Read(unsigned char* pbData, size_t lDataLength, size_t *dwReadBytes)
{
ssize_t read_bytes = m_hFile.Read((void*)pbData, lDataLength);//Read file data into buffer
Expand Down
2 changes: 2 additions & 0 deletions src/lib/tsreader/FileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ namespace MPTV
virtual bool IsBuffer() { return false; };
virtual int64_t OnChannelChange(void);
virtual size_t HasData(){ return 0; };
virtual void SetNoBuffer();

protected:
kodi::vfs::CFile m_hFile; // Handle to file for streaming
std::string m_fileName; // The filename where we read from
int64_t m_fileSize;
uint32_t m_flags;
};
}
5 changes: 5 additions & 0 deletions src/lib/tsreader/MultiFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ namespace MPTV
//
long MultiFileReader::OpenFile()
{
// The underlying CFileStreamBuffer class used by kodi::vfs::CFile.Open() appears
// to be incompatible with the TS buffer files created by the TvServer, so disable
// the buffering.
m_TSBufferFile.SetNoBuffer();

long hResult = m_TSBufferFile.OpenFile();
kodi::Log(ADDON_LOG_DEBUG, "MultiFileReader: buffer file opened return code %d.", hResult);

Expand Down

0 comments on commit 233664a

Please sign in to comment.