diff --git a/examples/piano/Piano.zig b/examples/piano/Piano.zig index 4e706547..05230cf9 100644 --- a/examples/piano/Piano.zig +++ b/examples/piano/Piano.zig @@ -25,6 +25,7 @@ pub const Mod = mach.Mod(@This()); pub const global_events = .{ .init = .{ .handler = init }, + .deinit = .{ .handler = deinit }, .tick = .{ .handler = tick }, .audio_state_change = .{ .handler = audioStateChange }, }; @@ -54,6 +55,11 @@ fn init(audio: *mach.Audio.Mod, piano: *Mod) void { std.debug.print("[arrow down] decrease volume 10%\n", .{}); } +fn deinit(audio: *mach.Audio.Mod) void { + // Initialize audio module + audio.send(.deinit, .{}); +} + fn audioStateChange( audio: *mach.Audio.Mod, which: mach.EntityID, diff --git a/src/Audio.zig b/src/Audio.zig index 37a5ef13..2732af19 100644 --- a/src/Audio.zig +++ b/src/Audio.zig @@ -14,11 +14,11 @@ pub const components = .{ pub const local_events = .{ .init = .{ .handler = init }, + .deinit = .{ .handler = deinit }, .audio_tick = .{ .handler = audioTick }, }; pub const global_events = .{ - .deinit = .{ .handler = deinit }, .audio_state_change = .{ .handler = fn (mach.EntityID) void }, };