Bug recording cache problems
#1
Sorry for a long an detailed post. We have had a long standing, annoying bug in the wmc addon that I am finally able to investigate now that I can compile Kodi again (yeah!). I think its a bug with Kodi, but so far as I know, no other pvr addons have this problem, so maybe it is just something we are doing wrong. That's why am posting here.

bug description: When a recording starts in the backend, we trigger a refresh of the recording list in our addon so that kodi lists the new recording. When the recording finishes we refresh the recording list again. The problem is, this new recording is not playable when the user clicks it. It only plays if the user clicks another older recording first. After that, the new recording is playable (or they can restart kodi, that also fixes the new recording).

In Kodi I traced it down to this function in File.cpp

Code:
bool CFile::Open(const CURL& file, const unsigned int flags)

The first thing this function does is check to see if the input filepath is in a global directory cache, by calling this code:
Code:
if (!g_directoryCache.FileExists(url2.Get(), bPathInCache) )
    {
      if (bPathInCache)
        return false;
    }

and this is where the playback fails for us. The reason is the new file is not found in whatever this internal directory cache is, so g_directoryCache.FileExists returns false, but the directory path of the file is in the directory cache, so bPathInCache is true - so we get kicked out on the 'return false'. To prove it, I can fix our problem easily by forcing bPathInCache false.

So I don't know how this internal directory cache is getting set to the pvr recordings folder and what causes it to not refresh when the backend adds a new file - even though in the addon we are triggering a refresh of the recording list. If no other pvr addons have this problem, I assume we are doing or not doing something in pvr.wmc that is making this happen, but I don't know how either to a) not make our recordings folder part of this internal cache or b) force the internal cache to refresh when a new recording is added.

Any insight on this would be greatly appreciated.
Windows Media Center PVR addon (pvr.wmc) and server backend (ServerWMC)
http://bit.ly/serverwmc
Reply
#2
Hi there, I'm the person who found the bug several years back. I wanted to add a couple of points:

1. In investigating this bug, I found forum messages suggesting that it also affects users of ArgusTV and NextPVR. So, I don't think that its only the ServerWMC add-on. I believe that most people don't leave their machines running 24/7 as I do, and that's probably why there haven't been many reports of this issue. I'm using a dedicated OpenELEC box and I just leave it running

2. I created a bug report on this issue:

http://trac.kodi.tv/ticket/16174

3. An "update library" will also solve the problem with respect to the newly added recordings. However, you have to continue doing an update library anytime newly added recordings appear.

I'd really love to see this bug fixed, and am still willing to offer a bounty to get it fixed.
I welcome comments and suggestions for the Kodi (XBMC) Set-up Guide that I wrote.
You can read it here:  http://forum.kodi.tv/showthread.php?tid=193310
Reply
#3
I found a hack for the pvr addon that both fixes the cache and illustrates the problem. I insert the code below in the loop that is processing the recordings list returned from the backend. In the code below xRec.strStreamURL is the file path to the recording.

Code:
        if (strlen(xRec.strStreamURL) > 0 && !XBMC->FileExists(xRec.strStreamURL, true/*useCache*/))  //  if file does not exists in Kodi's stupid file cache
        {
            unsigned int numItems;
            CStdString mask = "*.wtv";
            VFSDirEntry *items;
            if (XBMC->GetDirectory(_recTVFolder, mask, &items, &numItems))  // fetch file list in RecTV folder, this makes Kodi's cache update
                XBMC->FreeDirectory(items, numItems);
        }

I thought an easier hack would be to use this when the file doesn't exist in the cache:

Code:
#define READ_NO_CACHE     0x08
  XBMC->OpenFile(xRec.strStreamURL, READ_NO_CACHE);   // open the file not using the cache

but that fails, why? because kodi reports the file doesn't exist. Even though READ_NO_CACHE is defined in File.h as:

Code:
/* open without caching. regardless to file type. */
#define READ_NO_CACHE     0x08

So there seems to be no way of opening a new recording from the addon if it doesn't exist in this cache.
Windows Media Center PVR addon (pvr.wmc) and server backend (ServerWMC)
http://bit.ly/serverwmc
Reply
#4
If you could find some way to force Kodi to update its cache, that would be the easy solution.

Sometimes, just going into the Movies or Video section solves the problem as well.
I welcome comments and suggestions for the Kodi (XBMC) Set-up Guide that I wrote.
You can read it here:  http://forum.kodi.tv/showthread.php?tid=193310
Reply
#5
This is your solution: http://forum.kodi.tv/showthread.php?tid=259830
Reply
#6
Interesting. We can run that way now, but we've been telling our users that mode is a workaround for this issue. It always seemed (to me anyway) more straightforward to point kodi at the already recorded files. Thanks for the info.

I also think users have said it doesn't solve this issue completely, but based on what I know now, it seems like it should. I'll investigate.
Windows Media Center PVR addon (pvr.wmc) and server backend (ServerWMC)
http://bit.ly/serverwmc
Reply
#7
That's correct. It does NOT solve the problem completely. Newly added recordings (particularly those in Recording Now) will NOT play until you do at least one Library Update. After you do the Library Update, the problem is totally resolved until you reboot. Once you reboot, the problem will recur until you do a Library Update again.
I welcome comments and suggestions for the Kodi (XBMC) Set-up Guide that I wrote.
You can read it here:  http://forum.kodi.tv/showthread.php?tid=193310
Reply

Logout Mark Read Team Forum Stats Members Help
recording cache problems0