flesniak / python-prodj-link

A python interface to Pioneer ProDJ Link
Apache License 2.0
141 stars 26 forks source link

Strange behavior when DJM-2000 nexus is on network #12

Closed brunchboy closed 5 years ago

brunchboy commented 6 years ago

I get a Player box for “Player 33” showing as if it is a CDJ. You probably want to filter out devices whose numbers are greater than 15 to avoid rekordbox laptops and mixers in the GUI, or add special appropriate rendering for them.

I also see the following stack trace which may be related:

INFO: Gui: Creating player 33
DEBUG: Renderer "AMD Radeon Pro 560X OpenGL Engine" OpenGL "2.1 ATI-1.68.20"
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/construct/lib/container.py", line 90, in __getattr__
    return self[name]
KeyError: 'content'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/Users/jim/git/python-prodj-link/prodj.py", line 89, in run
    self.handle_beat_packet(data, addr)
  File "/Users/jim/git/python-prodj-link/prodj.py", line 123, in handle_beat_packet
    self.cl.eatBeat(packet)
  File "/Users/jim/git/python-prodj-link/clientlist.py", line 112, in eatBeat
    on_air = beat_packet.content.ch_on_air[x-1] == 1
  File "/usr/local/lib/python3.7/site-packages/construct/lib/container.py", line 92, in __getattr__
    raise AttributeError(name)
AttributeError: content
brunchboy commented 6 years ago

Actually, the problem appears to be worse than just the stack trace. The UI window does not update when I load and play tracks on a CDJ after this point. Here is what it looks like:

Frozen UI
brunchboy commented 6 years ago

And the PDB download does not seem to take place, which is what I was hoping to watch, to try and figure out what is different from the Sun NFS client I am trying to use.

brunchboy commented 6 years ago

Actually, the problem seems to be this commit: https://github.com/flesniak/python-prodj-link/commit/ae720d11bad4c2bd9f818838e1a2c1a1cb52dca2

If I undo that change, things start working again, although the players are still in those strange positions.

flesniak commented 6 years ago

Strange that commit ae720d11bad4c2bd9f818838e1a2c1a1cb52dca2 solves the crash, in both of my test setups (construct 2.8 and 2.9) I need that change - just tested that right now. What construct version are you using? Commit 5d581a1dafd7e7793f831210a9fc206f66cd5b66 fixes the bug that sometimes a player widget for mixers etc. would be created, good find. When something in the network thread crashes, the application continues to run but won't react to anything from the network. This is caused by design and would be nice to change by for example restarting the network thread on errors, but thats not implemented yet. That's why the PDB download didn't start in this case.

flesniak commented 6 years ago

Regarding the strange layout: Currently, widgets are placed on fixed positions depending on their player number. The layout can be changed by setting gui.layout_mode (gui.py line 369), but I should just improve it to be dynamic. I'll create an issue for that.

brunchboy commented 6 years ago

According to pip (yesterday was the first time I tried using it), I am running construct 2.8.22. That was the most recent 2.8.x version I could find, and the README said I should use version 2.8. Having manually reverted the change allowed me to get to where I could watch PDB downloads, and those allowed me to hack the Sun NFSv2 source code enough to make some progress. By configuring it to support different string encodings for path names (since the players seem to require UTF-16LE), I was able to get the mount to succeed for /C. I can’t get any files, though, because the players don’t support /multi/directory/paths, and the Sun code assumes that is the way to navigate through directories. It looks like I need to write my own non-standard NFS client, just like you did. And this old Sun code is not written in a way that you can use lower-level pieces like their RPC, XDR, and Mount. (It looks like messy C code written by an intern who has barely started learning Java, to be frank! 😉) Luckily, I did find another free Java NFS client, and even though it only supports NFSv3, at least it appears to have been somewhat sanely designed so I can use the lower-level parts.

flesniak commented 5 years ago

As the gui should not attempt to create player widgets for mixers, I think this issue can be closed.