Audio: do not use event arguments
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
e711f69fad
commit
7ad38d6eff
2 changed files with 14 additions and 7 deletions
|
|
@ -32,7 +32,7 @@ ms_render_ahead: f32 = 16,
|
|||
allocator: std.mem.Allocator,
|
||||
ctx: sysaudio.Context,
|
||||
player: sysaudio.Player,
|
||||
on_state_change: mach.AnyEvent,
|
||||
on_state_change: ?mach.AnyEvent = null,
|
||||
output_mu: std.Thread.Mutex = .{},
|
||||
output: SampleBuffer,
|
||||
mixing_buffer: ?std.ArrayListUnmanaged(f32) = null,
|
||||
|
|
@ -43,7 +43,7 @@ var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|||
|
||||
const SampleBuffer = std.fifo.LinearFifo(u8, .Dynamic);
|
||||
|
||||
fn init(audio: *Mod, on_state_change: mach.AnyEvent) !void {
|
||||
fn init(audio: *Mod) !void {
|
||||
const allocator = gpa.allocator();
|
||||
const ctx = try sysaudio.Context.init(null, allocator, .{});
|
||||
try ctx.refresh();
|
||||
|
|
@ -70,7 +70,6 @@ fn init(audio: *Mod, on_state_change: mach.AnyEvent) !void {
|
|||
.allocator = allocator,
|
||||
.ctx = ctx,
|
||||
.player = player,
|
||||
.on_state_change = on_state_change,
|
||||
.output = SampleBuffer.init(allocator),
|
||||
.debug = debug,
|
||||
});
|
||||
|
|
@ -171,7 +170,9 @@ fn audioTick(audio: *Mod) !void {
|
|||
try audio.set(id, .index, index + to_read);
|
||||
}
|
||||
}
|
||||
if (did_state_change) audio.sendAnyEvent(audio.state().on_state_change);
|
||||
if (audio.state().on_state_change) |on_state_change_event| {
|
||||
if (did_state_change) audio.sendAnyEvent(on_state_change_event);
|
||||
}
|
||||
|
||||
// Write our rendered samples to the fifo, expanding its size as needed and converting our f32
|
||||
// samples to the format the driver expects.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue