pannal / plex-for-kodi

Unoffical Plex for Kodi add-on releases.
GNU General Public License v2.0
237 stars 30 forks source link

Fix seek issue on Ugoos am6b+ #117

Closed bowlingbeeg closed 2 weeks ago

bowlingbeeg commented 2 weeks ago

GHI (If applicable): #

Description:

On the Ugoos am6b+ after seeking it can take 2-15 seconds for audio to start while the video is playing. Playing the same file using the default kodi player does not exhibit this issue. Changing to use the executebuiltin(Seek) solves this issue. Hopefully this doesn't break other things because the player.seekTime is doing something else in the background that the executebuiltin doesn't.

Checklist:

pannal commented 2 weeks ago

Hmm. This sounds like a specific fix for a specific device. I haven't had any reports yet around this issue.

Unless this is reproducible on other systems I'd rather have a specific implementation for a specific device, instead of changing something that works for everyone else. Together with a bug report for that device's maintainer.

pannal commented 2 weeks ago

In this case I'd like a device specific whitelist in util.py with a list of system identifiers that get checked, resulting in a flag that gets used by seekdialog.py.

pannal commented 2 weeks ago

Hmm I'm seeing something similar to this issue on the latest firetv kodinerds omega build. (that was network related) Can you pinpoint a version when this starts happening?

This might be a kodi issue that's just been introduced.

bowlingbeeg commented 2 weeks ago

I'm on the CoreElec Kodi Omega nightly drivers for the ugoos am6b+. I believe those are the only ones that are supported with that device. In my debugging I did try and go back to previous PM4K versions but it was present all the way back to 0.7.0.

pannal commented 2 weeks ago

I was talking about the kodi/coreelec version.

In any case, this is a device-specific fix. Please implement it that way (you should be able to detect which device kodi is running on, from code).

bowlingbeeg commented 2 weeks ago

Can you point me at some code that does this? I've been searching through the code and I can only find places where it knows the platform(Linux, Android, etc). I know Kodi has the info because it prints it in the log but I don't think the addon has access to the g_sysinfo object that has that data.

pannal commented 2 weeks ago

Probably one of those: xbmc.getInfoLabel('System.BuildVersion') xbmc.getInfoLabel('System.FriendlyName') xbmc.getInfoLabel('System.OSVersionInfo')

pannal commented 2 weeks ago

Or you can try this: https://stackoverflow.com/questions/110362/how-can-i-find-the-current-os-in-python

bowlingbeeg commented 2 weeks ago

But those only give the Linux OS values. You want me to do this for every Linux device?

pannal commented 2 weeks ago

No I want you to try and identify the ugoos device and only enable the fix for that one.

pannal commented 2 weeks ago

I have no ugoos or coreelec device, so I can't test those labels for you.

bowlingbeeg commented 2 weeks ago

Yes, I understand what you want but I don't know how to get it. None of those options you gave will give that info. That just gives the information on the Kodi level or the OS level, which in this case is just Linux. There is no option that I can find that will give device/model information.

pannal commented 2 weeks ago

Can you paste the log entry where it prints the necessary info? I'm currently hunting for the code (it might be https://github.com/xbmc/xbmc/blob/3d14ee659bc0a9f431ee094487a781d8ef0ad892/xbmc/utils/SystemInfo.cpp#L744, so we could try os.system("lsb_release") if it's that)

pannal commented 2 weeks ago

Or it's /etc/os-release can you try cat'ing that? (Found in https://github.com/xbmc/xbmc/blob/3d14ee659bc0a9f431ee094487a781d8ef0ad892/xbmc/utils/SystemInfo.cpp#L141)

bowlingbeeg commented 2 weeks ago

This will get the device model number. I see it printing Ugoos am6b+ and on my zidoo it's Zidoo Z9X.

https://github.com/xbmc/xbmc/blob/3d14ee659bc0a9f431ee094487a781d8ef0ad892/xbmc/application/Application.cpp#L3647

bowlingbeeg commented 2 weeks ago

Although I have to say I'm not sure it's worth all of this hassle. The Seek interface I'm calling is still a kodi provided seek interface. Why not just check it into a beta and see if other people have problems with it?

bowlingbeeg commented 2 weeks ago

since you asked ... but again that would then affect all coreelec users, not just the ones using Ugoos Am6b+. Of course it could be a coreelec bug and this would then work but without more user input we have no idea what devices are affected.

cat /etc/os-release NAME="CoreELEC" VERSION="21.1-Omega_nightly_20240605" ID="coreelec" VERSION_ID="21.1" PRETTY_NAME="CoreELEC (official): 21.1-Omega_nightly_20240605" HOME_URL="https://coreelec.org" BUG_REPORT_URL="https://github.com/CoreELEC/CoreELEC" BUILD_ID="5fc8d64514fbd313eb7c01e7a3ab977447274f79" LIBREELEC_ARCH="Amlogic-ng.arm" LIBREELEC_BUILD="official" LIBREELEC_PROJECT="Amlogic-ce" COREELEC_ARCH="Amlogic-ng.arm" COREELEC_BUILD="official" COREELEC_PROJECT="Amlogic-ce" COREELEC_DEVICE="Amlogic-ng" BUILDER_NAME="TheCoolest"

pannal commented 2 weeks ago

Hmm, they use m_cpuHardware for this, can you try cat'ing /sys/bus/soc/devices/soc0/machine?

Edit: Or one of these: "/sys/class/hwmon/hwmon" + std::to_string(i) + "/name"

pannal commented 2 weeks ago

See here: https://github.com/xbmc/xbmc/blob/3d14ee659bc0a9f431ee094487a781d8ef0ad892/xbmc/platform/linux/CPUInfoLinux.cpp#L71

pannal commented 2 weeks ago

Kodi doesn't do any magic here, we should be able to get the exact same info as they do, using Python.

bowlingbeeg commented 2 weeks ago

Neither of those seem to work. They don't exist.

cat /sys/bus/soc/devices/soc0/machine cat: can't open '/sys/bus/soc/devices/soc0/machine': No such file or directory

ls -a /sys/class/hwmon/ . ..

bowlingbeeg commented 2 weeks ago

This one does ... I'm not sure what will happen on other devices though.

cat /proc/cpuinfo . . . Serial : 290b4000011a0f0000023236394e4e50 model name : Amlogic S922X rev b Hardware : UGOOS AM6B

pannal commented 2 weeks ago

Great, /proc/cpuinfo is almost always available, we could also utilize something like https://github.com/workhorsy/py-cpuinfo, but that might be overkill just for that issue.

I'd just try/except wrap around catting /proc/cpuinfo and grepping for the Hardware you want, and add a special case then. Otherwise ignore the output.

bowlingbeeg commented 2 weeks ago

Can you try this out on your devices and see if it causes any problems?

pannal commented 2 weeks ago

I'll check, thank you! I'd check for whether the OS is Linux, though, to avoid unnecessary calls on all other platforms.

pannal commented 2 weeks ago

No issues over here on Windows.

bowlingbeeg commented 2 weeks ago

ugh .. the Ugoos return RaspberryPi for the platform

pannal commented 2 weeks ago

That's fine, then just add both - then we're at least skipping the call for Android Windows etc.

bowlingbeeg commented 2 weeks ago

oh shoot, didn't see your response before I uploaded ... since for now we only want the ugoos just having the raspberrypi check works.

pannal commented 2 weeks ago

The latest push looks weird:

# of devices.
def getDeviceModel():
    try:
        stdout = subprocess.check_output('cat /proc/cpuinfo', shell=True).decode()
        hardwareRegex = re.compile(r'Hardware\s*:\s*(.*)')
        match = hardwareRegex.search(stdout)
        deviceModel = "Unknown"
        if match:
            deviceModel = match.group(1)

        return deviceModel
    except:
        return "Unknown"

deviceModel = getDeviceModel()

# There are lots of different devices and different ways to get the device model.  This way is known
# to work with the Ugoos am6b+ device but probably doesn't work for others.
def getDeviceModel():
    try:
        deviceModel = "Unknown"
        if(getPlatform() == "RaspberryPi"):
            stdout = subprocess.check_output('cat /proc/cpuinfo', shell=True).decode()
            hardwareRegex = re.compile(r'Hardware\s*:\s*(.*)')
            match = hardwareRegex.search(stdout)
            deviceModel = "Unknown"
            if match:
                deviceModel = match.group(1)

        return deviceModel
    except:
        return "Unknown"

deviceModel = getDeviceModel()

Also please use the PEP standard for line spacing (I've added comments before) before/after functions

bowlingbeeg commented 2 weeks ago

Never heard of PEP standard and I did add two lines before/after functions.

pannal commented 2 weeks ago

Yeah after duplicating the code somehow :D (What I pasted above is what I get when I pull your latest branch)

pannal commented 2 weeks ago

Ah no, sorry, I had a bad merge because I missed that you force pushed.

pannal commented 2 weeks ago

if(getPlatform() == "RaspberryPi"): has redundant parentheses, but doesn't matter, I'll merge this and fix it in post.

Thank you for fixing this!

bowlingbeeg commented 2 weeks ago

Agh, sorry ... Python is not my normal language. Too much c++ in me :)