-
Notifications
You must be signed in to change notification settings - Fork 42
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
Program crashes when trying to wrap Miniaudio #10
Comments
I don't currently have access to a Windows box (I've received a loaner Intel macbook to install VMWare, but haven't gotten around to do so yet), so can't run. However, if you have any more direct description of how/where the code crashes, I might have some idea/guess. |
It seems to crash on line 32:
config.dataCallback = callback
Can you try reproducing it on what ever you have access to? Miniaudio
should be easy to compile cross-platform:
gcc miniaudio_dll.c -shared
Then instead of loading miniaudio.dll load miniaudio.so or whatever.
…On 9/14/21, wlav ***@***.***> wrote:
I don't currently have access to a Windows box (I've received a loaner Intel
macbook to install VMWare, but haven't gotten around to do so yet), so can't
run.
However, if you have any more direct description of how/where the code
crashes, I might have some idea/guess.
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#10 (comment)
|
The cause are these two lines in
as neither structure has a Not 100% sure what is going on yet, but it is clear that the offset returned for The code should be (drop the above two lines):
I'll dig a bit further to see what exactly is going on, but the above fix should get you going. |
In Miniaudio, the sampleRate field is defined as: |
b/c I'm doing half a dozen things in parallel and don't have enough cycles to pay too much attention: I c&p-ed that |
Below is a standalone reproducer that should succeed, but doesn't. Seems to be caused by the structs being anonymous (if they are named, all works as expected),
|
I noticed something weird about anonymous structs:
C:\py\git\miniaudio>python.exe
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>> from cppyy import include, gbl
>> include("miniaudio.h")
True
>> cfg = gbl.ma_context_config()
>> dir(cfg)
['__add__', '__assign__', '__bool__', '__class__', '__delattr__',
'__destruct__', '__dict__', '__dir__', '__dispatch__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__',
'__gt__', '__hash__', '__init__', '__init_subclass__', '__invert__',
'__le__', '__lt__', '__module__', '__mul__', '__ne__', '__neg__',
'__new__', '__pos__', '__python_owns__', '__radd__', '__reduce__',
'__reduce_ex__', '__repr__', '__rmul__', '__rsub__', '__rtruediv__',
'__setattr__', '__sizeof__', '__smartptr__', '__str__', '__sub__',
'__subclasshook__', '__truediv__', '__weakref__',
'allocationCallbacks', 'alsa', 'coreaudio', 'custom', 'jack',
'logCallback', 'pLog', 'pUserData', 'pulse', 'threadPriority',
'threadStackSize']
>> dir(cfg.pulse)
['__add__', '__assign__', '__bool__', '__class__', '__delattr__',
'__destruct__', '__dict__', '__dir__', '__dispatch__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__',
'__gt__', '__hash__', '__init__', '__init_subclass__', '__invert__',
'__le__', '__lifeline', '__lt__', '__module__', '__mul__', '__ne__',
'__neg__', '__new__', '__pos__', '__python_owns__', '__radd__',
'__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__rsub__',
'__rtruediv__', '__setattr__', '__sizeof__', '__smartptr__',
'__str__', '__sub__', '__subclasshook__', '__truediv__',
'__weakref__', 'allocationCallbacks', 'alsa', 'coreaudio', 'custom',
'jack', 'logCallback', 'pLog', 'pUserData', 'pulse', 'threadPriority',
'threadStackSize']
>>
Notice how dir() returns the same both times even though it shouldn't.
…On 9/14/21, wlav ***@***.***> wrote:
Below is a standalone reproducer that should succeed, but doesn't. Seems to
be caused by the structs being anonymous (if they are named, all works as
expected),
```
import cppyy
cppyy.cppdef("""\
namespace StructInStruct {
struct Outer {
Outer() { fO = -77; inner.fI = -99; }
int fO;
struct {
int fI;
} inner;
};
int check(const Outer& p, int which) {
if (which == 1) return p.fO;
if (which == 2) return p.inner.fI;
return -1;
} }""")
ns = cppyy.gbl.StructInStruct
o = ns.Outer()
assert o.fO == -77
assert ns.check(o, 1) == -77
assert ns.check(o, 2) == -99
o.inner.fO = 42
assert ns.check(o, 1) == -77
assert ns.check(o, 2) == -99
assert hasattr(o.inner, 'fI')
o.inner.fI = 37
assert ns.check(o, 1) == -77
assert ns.check(o, 2) == 37
```
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#10 (comment)
|
Yes, it's clearly not functioning as it should. My best guess at this point is that the anonymous struct is treated the same way as an anonymous enum (which is transparently accessible in the parent class). |
Fixed in repo. |
Oops; commenting on wrong bug report. No, this one is NOT yet fixed ... |
I tried writing a simple program that uses CPPYY to use Miniaudio from Python. However, at some point it crashes and I have no idea why.
I'm using Windows 10 64-bit, CPython 3.9.5 and here is a ZIP file containg my Python code, my copy of Miniaudio (up-to-date) and miniaudio_dll.dll (to rebuild "cl miniaudio_dll.c")
problem.zip
I don't just JIT compile miniaudio.h because it causes a compilation error. Sorry if I forgot something, but nearly empty laptop batteries wait for no one.
The text was updated successfully, but these errors were encountered: