-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Importing miniaudio.h library results in dependency loop error #19392
Comments
I stripped the miniaudio.h header down as much as I could, and here's zig and C code that replicate the problem about as minimally as I could manage: const std = @import("std");
const miniaudio = @cImport({
@cInclude("repro.h");
});
pub fn main() !void {
miniaudio.ma_device_config_init();
} typedef struct ma_device ma_device;
typedef void (* ma_device_data_proc)(struct ma_device* pDevice);
struct ma_device_config
{
ma_device_data_proc dataCallback;
};
struct ma_device
{
ma_device_data_proc onData;
};
void ma_device_config_init(void) {
struct ma_device_config val;
} The generated zig code from
|
i think this looks like #12325 |
Implement audio playback, hopefully motivation is self explanatory The audio landscape is vast in linux, we have alsa, pulse, jack, pipewire and alsa, pulse, jack interfaces into pipewire, alsa interfaces into pulse, etc. Instead of trying to deal with this ourselves, pull in an audio lib to deal with it for us Just skimming online, miniaudio fits well. PortAudio and libsoundio also seem to both be good candidates. No strong reasoning went into this choice, the single header impl of miniaudio felt easy to work with. We were tricked though, with the default miniaudio impl we hit a zig compiler bug that triggers circular dependencies. Something about using a struct pointer in a function pointer stored by the struct, see ziglang/zig#18247 (comment) Patch miniaudio to just use void pointers instead, this doesn't seem to have any negative effects Add an audio player abstraction that just injects a sin wave for now, add test binary to try it Potentially related issues... ziglang/zig#12325 ziglang/zig#16419 ziglang/zig#19392
If it's helpful, I've got this to work by just patching miniaudio to replace ma_device* function arguments with void* function arguments.
|
Implement audio playback, hopefully motivation is self explanatory The audio landscape is vast in linux, we have alsa, pulse, jack, pipewire and alsa, pulse, jack interfaces into pipewire, alsa interfaces into pulse, etc. Instead of trying to deal with this ourselves, pull in an audio lib to deal with it for us Just skimming online, miniaudio fits well. PortAudio and libsoundio also seem to both be good candidates. No strong reasoning went into this choice, the single header impl of miniaudio felt easy to work with. We were tricked though, with the default miniaudio impl we hit a zig compiler bug that triggers circular dependencies. Something about using a struct pointer in a function pointer stored by the struct, see ziglang/zig#18247 (comment) Patch miniaudio to just use void pointers instead, this doesn't seem to have any negative effects Extract audio frames from ffmepg, and feed them into our audio subsystem. Not a ton to say here, everything is just using the APIs provided by miniaudio and ffmpeg Replace test video with a 20s segment of big buck bunny Potentially related issues... ziglang/zig#12325 ziglang/zig#16419 ziglang/zig#19392
I've dug in a bit more. This is definitely just a special case of #12325
I've verified, and this bug still persists. It's not fixed by that other fix. |
Zig Version
0.12.0-dev.3403+b5cef9e8b
Steps to Reproduce and Observed Behavior
zig init
git clone https://github.com/mackron/miniaudio
edit
build.zig
, and add these lines just after theconst exe = ...
declaration:edit
src/main.zig
, and delete all the code but theconst std = @import("std");
line.add the following additional code code:
zig build
Behavior:
Expected Behavior
I expected the program to compile successfully, or at least get further.
There may be other errors to fix in the zig code, but the error in the C import would go away.
The text was updated successfully, but these errors were encountered: