Comments (5)
I would presume that libsndfile is usually compiled using MinGW, whereas Python is compiled with Visual Studio 2006, if I remember correctly. Thus, they use different C runtimes. Apparently, this also means that they use different implementations for file descriptors. File descriptors are opaque pointers as far as C programs are concerned. Each runtime can define them any way they want. This is pretty bad news.
Regardless of whether we can solve this problem by finding a matching set of libsndfile and Python, we can never enforce such a setup for our users. It seems that file descriptors are not a viable option for us. This is why Unix is a good thing...
from python-soundfile.
That's annoying ... did using file descriptors ever work for you on Windows?
It seems that file descriptors are not a viable option for us.
Sadly, it seems so.
Let's discuss possible solutions in #59 and #60.
from python-soundfile.
did using file descriptors ever work for you on Windows?
Within one application, yes. If both the application and libsndfile are linked against the same runtime, everything is fine. This only becomes a problem with dynamic linking and heterogenous C-runtimes. I have wasted too much of my life with the interplay between different compilers and runtimes.
The infamous DLL HELL comes to mind -- if your application links against version X of, say, Qt, and you then dynamically load another library which happens to link against version Y of Qt, all the old Qt symbols in your namespace will get overwritten and your app will crash. This is a common problem with VST plugins.
Similar fun can be had with just installing some software which dumps its libraries to C:\Windows\System32, and overwrites a library that was already there. Library versioning is a relatively new feature in Windows.
To mitigate this problem, Visual Studio mangles all exported symbol names with a version string. This however means that you can't just dynamically link against the DLLs any more, since the function names would be all wrong. The standard practice with Visual Studio is then to link statically against a stub library, which then loads the dynamic library with the correctly mangled names at run time, thus subverting dynamic linking completely.
If you do need to create a DLL with un-mangled names, you need to create a special export-definition file that tells the Visual Studio compiler to use actual C names. Without this, GCC will not link against Visual Studio libraries.
There is also no way of un-loading a linked DLL. This is why Mex-Files sometimes can't be reloaded without restarting Matlab: Once Matlab links the Mex-File, that function is permanent part of Matlab's symbol table and can not be removed without re-starting Matlab (I don't know if this is still true).
And don't even get me started about defective Compilers, strange CPU architectures, or "minimal" embedded runtimes and operating systems. This is why I love the CFFI so much. No compilers, no weird name mangling, no version conflicts, just simple function calls and binary data. Similarly, Python just works on every platform, and is defined abstract enough so that OS differences really don't come into play usually. It is both reassuring and saddening to see problems like these crop up immediately once we leave Python, if only for something as ubiquitous as file descriptors. Maybe it should be a reminder to stick with pure Python, and trust the wisdom of abstracting away all system-level entities.
</rant>
from python-soundfile.
Thanks for the detailed rant. That's interesting. And sad.
from python-soundfile.
I'm closing this because it seems we can't do anything about the problem.
from python-soundfile.
Related Issues (20)
- numpy is a dependency, but this is not declared HOT 3
- Feature request: Support interleaved stereo data HOT 4
- buffer_read doesn't work in basic test HOT 2
- Soundfile read/write wav is not symmetric with default arguments HOT 3
- module 'soundfile' has no attribute 'SoundFileRuntimeError' HOT 5
- Value Error: array is too big when loading .flac file
- soundfile crashes when trying to export long .ogg file HOT 1
- soundfile.LibsndfileError: Error opening <_io.BytesIO object at 0x0000022B81C21850>: Format not recognised. HOT 2
- Cannot suppress warnings when decoding mp3
- Cannot open Ogg FLAC file: unknown error in flac decoder HOT 1
- miniforge3/lib/python3.9/site-packages/soundfile.py", line 1229, in _init_virtual_io def vio_get_filelen(user_data): MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks
- Cannot write Ogg files over 96 seconds long at 44.1 kHz HOT 4
- soundfile.info does not work on mp3 HOT 2
- soundfile.LibsndfileError: <exception str() failed> HOT 6
- How to save left and right channel in separate files? HOT 1
- soundfile.LibsndfileError: Error : unknown error in flac decoder. HOT 2
- "Format not recognised." for m4a files HOT 2
- soundfile.LibsndfileError: Error opening <tempfile._TemporaryFileWrapper object at 0x7feadae59070>: Format not recognised. HOT 2
- Part of mp3 is loaded. HOT 2
- unknown error in flac decoder HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-soundfile.