1
0
mirror of https://github.com/rofafor/vdr-plugin-iptv.git synced 2023-10-10 13:37:03 +02:00

Changed rewinding to transparent.

This commit is contained in:
Rolf Ahrenberg 2007-09-16 17:31:38 +00:00
parent 07cb89d82e
commit b53d25a56f

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: protocolfile.c,v 1.3 2007/09/16 14:47:01 ajhseppa Exp $ * $Id: protocolfile.c,v 1.4 2007/09/16 17:31:38 rahrenbe Exp $
*/ */
#include <fcntl.h> #include <fcntl.h>
@ -43,7 +43,6 @@ bool cIptvProtocolFile::OpenFile(void)
debug("cIptvProtocolFile::OpenFile()\n"); debug("cIptvProtocolFile::OpenFile()\n");
// Check that stream address is valid // Check that stream address is valid
if (!fileActive && !isempty(streamAddr)) { if (!fileActive && !isempty(streamAddr)) {
fileStream = fopen(streamAddr, "rb"); fileStream = fopen(streamAddr, "rb");
if (ferror(fileStream) || !fileStream) { if (ferror(fileStream) || !fileStream) {
char tmp[64]; char tmp[64];
@ -59,10 +58,10 @@ bool cIptvProtocolFile::OpenFile(void)
void cIptvProtocolFile::CloseFile(void) void cIptvProtocolFile::CloseFile(void)
{ {
debug("cIptvProtocolFile::CloseFile()\n"); debug("cIptvProtocolFile::CloseFile()\n");
// Check that stream address is valid // Check that file stream is valid
if (fileActive && !isempty(streamAddr)) { if (fileActive && !isempty(streamAddr)) {
fclose(fileStream); fclose(fileStream);
// Update multicasting flag // Update active flag
fileActive = false; fileActive = false;
} }
} }
@ -71,21 +70,22 @@ int cIptvProtocolFile::Read(unsigned char* *BufferAddr)
{ {
//debug("cIptvProtocolFile::Read()\n"); //debug("cIptvProtocolFile::Read()\n");
*BufferAddr = readBuffer; *BufferAddr = readBuffer;
// Check errors
if (ferror(fileStream)) { if (ferror(fileStream)) {
debug("Read error\n"); debug("Read error\n");
return -1; return -1;
} }
if(feof(fileStream)) { // Rewind if EOF
if (feof(fileStream))
rewind(fileStream); rewind(fileStream);
return -1; // Read the file stream
}
return fread(readBuffer, sizeof(unsigned char), readBufferLen, fileStream); return fread(readBuffer, sizeof(unsigned char), readBufferLen, fileStream);
} }
bool cIptvProtocolFile::Open(void) bool cIptvProtocolFile::Open(void)
{ {
debug("cIptvProtocolFile::Open(): streamAddr=%s\n", streamAddr); debug("cIptvProtocolFile::Open(): streamAddr=%s\n", streamAddr);
// Open the file for input // Open the file stream
OpenFile(); OpenFile();
return true; return true;
} }
@ -93,7 +93,7 @@ bool cIptvProtocolFile::Open(void)
bool cIptvProtocolFile::Close(void) bool cIptvProtocolFile::Close(void)
{ {
debug("cIptvProtocolFile::Close(): streamAddr=%s\n", streamAddr); debug("cIptvProtocolFile::Close(): streamAddr=%s\n", streamAddr);
// Close the file input // Close the file stream
CloseFile(); CloseFile();
return true; return true;
} }
@ -102,7 +102,7 @@ bool cIptvProtocolFile::Set(const char* Address, const int Port)
{ {
debug("cIptvProtocolFile::Set(): %s:%d\n", Address, Port); debug("cIptvProtocolFile::Set(): %s:%d\n", Address, Port);
if (!isempty(Address)) { if (!isempty(Address)) {
// Close the file input // Close the file stream
CloseFile(); CloseFile();
// Update stream address and port // Update stream address and port
streamAddr = strcpyrealloc(streamAddr, Address); streamAddr = strcpyrealloc(streamAddr, Address);