-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove circular buffer from the VFS #100
Conversation
I have no objections re Isengard backport. This bug seems PITA for many people. Despite from the multithreading question I raised, the change looks okay to me. EDIT: @Jalle19 I wanted PR number 100! ;-) |
I removed the mutex because AFAIK the whole class is only accessed from one thread. |
Ah, okay then. |
@ksooo do you mind runtime testing this? @Glenn-1990 you too perhaps? |
I never was able to reproduce this bug. Thus I could only test whether things still do work for me. |
m_bHasData = false; | ||
m_bSeekDone = true; | ||
m_currentReadLength = INITAL_READ_LENGTH; | ||
m_seekCondition.Signal(); | ||
} | ||
|
||
int CHTSPVFS::Read ( unsigned char *buf, unsigned int len ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did I really write a function using int's like this! urgh! really this should be something sensible like size_t
I was obviously having a bad day, or just putting up with how Kodi dev's had done things.
Couple of mistakes in my comments, I can't remember the whole locking philosophy, but I think the lock removals are OK, I think these were due to addition of extra threads. I've made some suggested (but untested) changes, adamsutton@ae43216 |
I would be happy to assist with some testing if needed. |
@adamsutton I added your patch and runtime tested it, seems to be working. |
htsmsg_destroy(m); | ||
return true; | ||
|
||
return (int)read; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please use a c++ style cast here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make @adamsutton happy maybe we should return size_t
all the way up the chain and perform the cast to int
in client.cpp
(since that's where the int
requirement comes from)?
@ksooo @adamsutton better? |
@Jalle19 👍 |
Runtime-test was not a success. Crashes immediately when trying to play a recording. Compile time warning: ..../pvr.hts-master/src/HTSPVFS.cpp: In member function 'CHTSPVFS::SendFileRead(unsigned char*, unsigned int)': ....pvr.hts-master/src/HTSPVFS.cpp:296:74: warning: 'buffer' may be used uninitialized in this function [-Wmaybe-uninitialized] if (htsmsg_get_bin(m, "data", buffer, reinterpret_cast(&read))) => https://github.com/kodi-pvr/pvr.hts/pull/100/files#diff-8c04d63d169ca5038cb71164664a467bR272 Crash: 0 0x00007fe74ff489dd in htsmsg_get_bin (msg=, name=, binp=0x0, lenp=0x7fe73a7f3a50) at /home/kai/src/openelec/OpenELEC.tv/build .OpenELEC-Generic.x86_64-5.95.5/pvr.hts-master/lib/libhts/htsmsg.c:381 #1 0x00007fe74ff418ae in CHTSPVFS::SendFileRead(unsigned char*, unsigned int) (this=this@entry=0x7fe744002f40, buf=0x7fe704233100 "pnp-org:device-1-0\">\n \n 1\n 0\330\060#\004\347\177", len=) at /home/kai/src/openelec/OpenELEC.tv/build.OpenE LEC-Generic.x86_64-5.95.5/pvr.hts-master/src/HTSPVFS.cpp:296 #2 0x00007fe74ff4191f in CHTSPVFS::Read(unsigned char*, unsigned int) (this=0x7fe744002f40, buf=, len=) at /home/kai/src/openele c/OpenELEC.tv/build.OpenELEC-Generic.x86_64-5.95.5/pvr.hts-master/src/HTSPVFS.cpp:100 #3 0x00007fe74ff40aa0 in CTvheadend::VfsRead(unsigned char*, unsigned int) () at /home/kai/src/openelec/OpenELEC.tv/build.OpenELEC-Generic.x86_64-5.95.5/pvr.h ts-master/src/Tvheadend.h:581 #4 ReadRecordedStream (pBuffer=, iBufferSize=) at /home/kai/src/openelec/OpenELEC.tv/build.OpenELEC-Generic.x86_64-5.95.5/pvr.ht s-master/src/client.cpp:572 #5 0x0000000000ca988e in PVR::CPVRClient::ReadStream(void*, long) () ... |
I cherry-picked this into Isengard |
However, when trying to play a recording (directly, not in a nfs share), kodi crashes. |
Same crash here on Jarvis - LiveTV fine, immediate crash trying to play a recording. I'm a total git noob though. cherry-picked so I could build against 4.0.0 API. |
I probably screwed something up with the reinterpret cast, will look into it later. |
@ksooo mind testing again? |
@Jalle19 Your latest commit fixes the crash, but the recording will still not play. |
@Jalle19 the reinterpret_cast is okay; not related to the crash. This should fix it: diff --git a/src/HTSPVFS.cpp b/src/HTSPVFS.cpp index 3067bc1..10961f2 100644 --- a/src/HTSPVFS.cpp +++ b/src/HTSPVFS.cpp @@ -269,7 +269,7 @@ long long CHTSPVFS::SendFileSeek ( int64_t pos, int whence, bool force ) ssize_t CHTSPVFS::SendFileRead(unsigned char *buf, unsigned int len) { htsmsg_t *m; - const void **buffer; + const void *buffer; ssize_t read; /* Build */ @@ -293,7 +293,7 @@ ssize_t CHTSPVFS::SendFileRead(unsigned char *buf, unsigned int len) } /* Get Data */ - if (htsmsg_get_bin(m, "data", buffer, reinterpret_cast(&read))) + if (htsmsg_get_bin(m, "data", &buffer, reinterpret_cast(&read))) { tvherror("malformed fileRead response: 'data' missing"); read = -1; @@ -302,7 +302,7 @@ ssize_t CHTSPVFS::SendFileRead(unsigned char *buf, unsigned int len) } else { - memcpy(buf, *buffer, read); + memcpy(buf, buffer, read); } /* Cleanup */ |
@Jalle19 For me, things work just fine without your latest commit and my patch for the data type of "buffer". @bas-t cannot see how latest commit from Jalle19 could fix your crash, which is according to the log you posted, exactly the crash I encountered, btw. Could you maybe test without Jalle19's latest commit and with my patch included instead? |
@ksooo will do. |
@ksooo it won't compile. Am I missing something ? I get this: /data/kodi-addons/pvr.hts/src/HTSPVFS.cpp: In member function ‘ssize_t CHTSPVFS::SendFileRead(unsigned char_, unsigned int)’: |
@bas-t you f****d up the patch file, I guess. Try this one: http://paste.ubuntu.com/12504317/ |
@bas-t in fact it was me, who killed the patch file while pasting it into gh comment.... Always forget about problems with > and < and html. haha. |
@ksoo no, you did. look at the difference! Op 20-09-15 om 19:47 schreef Kai Sommerfeld:
|
I missed your post, and reacted too soon. Op 20-09-15 om 19:54 schreef Kai Sommerfeld:
|
all fine |
Runtime test without latest @Jalle19 patch and with @ksooo patch (http://paste.ubuntu.com/12504317/). SUCCESS! Way to go, both of you (and @adamsutton). Only remaining thing on my system seems to be that in case I jump to the beginning, or mayby past that, given the size of the jump, I sometimes don't get audio. Skipping a bit forward again restores audio. Mind you, I'm still testing in Isengard only. |
@bas-t cool. Thanks for your support. As you've tested on Isengard and I did on Jarvis, we already know that the changes of this PR will work on both versions. Cool. @Jalle19 mind adding the fix to the addon changelog? @adamsutton thank you for jumping by and giving the advices needed to find the fix. Especially like the reduction in complexity (less, sometimes is more). |
Thanks for testing. Should we keep it the way it is now or should I change it back to using reinterpret_cast? IMO a static cast on the return value is "safer" (reinterpret_cast is considered the most dangerous type of cast). |
As the reinterpret_cast is semantically correct here and we tested with that cast in place, I'd say let's stick with it. |
44aea98
to
e144861
Compare
@ksooo done |
e144861
to
b2ae7e3
Compare
@ksooo added changelog update too, should be good to go now. |
@Jalle19 mind squasing commit 3 and 4 into commit 2 (or at least 4 into 2)? EIDT: or at least the "buffer" fix part of commit 4 into commit 2? ;-) |
circular buffer and threading. Fixes kodi-pvr#92, fixes kodi-pvr#99.
b2ae7e3
to
8800657
Compare
@ksooo done (took the easiest route) |
Thank you, Sam. |
Remove circular buffer from the VFS
As if by magic this also fixes the ancient bug where the picture is basically frozen if you attempt to fast-forward or rewind in recordings. Now it's just as smooth as for local content. |
@Jalle19 that's great news, and shows why I shouldn't be allowed to code this stuff! |
As mentioned by @adamsutton in #99, this drastically simplifies the code and indeed seems to fix #92. @ksooo @adamsutton for review (especially the first commit which is kinda unrelated), @FernetMenta for sanity check.
@ksooo we'll have to backport this to Isengard even though it's quite a drastic "fix".