iPod support restored using ctypes and libgpod #1289
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Debian/Ubuntu haven't built the Python bindings for libgpod for a while now (presumably as part of the Python 2 -> Python 3 transition, but I haven't investigated more than this):
This leaves users without an "easy" way to use iPod sync support, even on Linux.
Apart from that, I noticed that even with
python-gpodinstalled, the iPod sync support is probably just broken at the moment.This patch re-introduces "classic" iPod support using libgpod (which is still available in distros) directly using Python's ctypes FFI module to interact with the C library. It also cleans up some things in
src/gpodder/sync.pythat were unused/dead code.This actually does more than previous incarnations of iPod support in gPodder ever did:
current_positionof the episodecurrent_positionThis means that when listening to an episode on an iPod, and later syncing, the playback position (bookmark) is reflected in gPodder's UI. Deleting episodes on the iPod that have been deleted in gPodder has also been tested and works.
The other great thing about this change is, if we ever get to build
libgpodand its dependencies for Windows and/or macOS, iPod syncing would work for those devices as well (libgpodis basically just writing files on the filesystem for "classic" iPods, nothing magical there).I tried to be careful not to introduce use-after-free and memory leak bugs, and tried to document the pitfalls I ran into, but there might still be some issues lurking (
valgrindis mostly happy, though). A "proper" C extension module for Python might be the way to go, but this ctypes-based solution doesn't require development headers or even a compiler (and trying to get the SWIG-based Python bindings re-enabled in Linux distros might be more effort than what it's worth).