all: update to latest Zig APIs (zig fmt)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
d95a453e78
commit
4bc32adeb8
61 changed files with 806 additions and 806 deletions
|
|
@ -134,7 +134,7 @@ pub const Context = struct {
|
|||
pub fn init(allocator: std.mem.Allocator, options: main.Context.Options) !backends.BackendContext {
|
||||
try lib.load();
|
||||
|
||||
_ = lib.snd_lib_error_set_handler(@ptrCast(c.snd_lib_error_handler_t, &util.doNothing));
|
||||
_ = lib.snd_lib_error_set_handler(@as(c.snd_lib_error_handler_t, @ptrCast(&util.doNothing)));
|
||||
|
||||
var self = try allocator.create(Context);
|
||||
errdefer allocator.destroy(self);
|
||||
|
|
@ -273,8 +273,8 @@ pub const Context = struct {
|
|||
var i: usize = 0;
|
||||
var evt: *inotify_event = undefined;
|
||||
while (i < buf.len) : (i += @sizeOf(inotify_event) + evt.len) {
|
||||
evt = @ptrCast(*inotify_event, @alignCast(4, buf[i..]));
|
||||
const evt_name = @ptrCast([*]u8, buf[i..])[@sizeOf(inotify_event) .. @sizeOf(inotify_event) + 8];
|
||||
evt = @as(*inotify_event, @ptrCast(@alignCast(4, buf[i..])));
|
||||
const evt_name = @as([*]u8, @ptrCast(buf[i..]))[@sizeOf(inotify_event) .. @sizeOf(inotify_event) + 8];
|
||||
|
||||
if (evt.mask & std.os.linux.IN.ISDIR != 0 or !std.mem.startsWith(u8, evt_name, "pcm"))
|
||||
continue;
|
||||
|
|
@ -320,7 +320,7 @@ pub const Context = struct {
|
|||
if (lib.snd_ctl_pcm_next_device(ctl, &dev_idx) < 0)
|
||||
return error.SystemResources;
|
||||
|
||||
lib.snd_pcm_info_set_device(pcm_info, @intCast(c_uint, dev_idx));
|
||||
lib.snd_pcm_info_set_device(pcm_info, @as(c_uint, @intCast(dev_idx)));
|
||||
lib.snd_pcm_info_set_subdevice(pcm_info, 0);
|
||||
const name = std.mem.span(lib.snd_pcm_info_get_name(pcm_info) orelse continue);
|
||||
|
||||
|
|
@ -328,7 +328,7 @@ pub const Context = struct {
|
|||
const snd_stream = modeToStream(mode);
|
||||
lib.snd_pcm_info_set_stream(pcm_info, snd_stream);
|
||||
const err = lib.snd_ctl_pcm_info(ctl, pcm_info);
|
||||
switch (@enumFromInt(std.os.E, -err)) {
|
||||
switch (@as(std.os.E, @enumFromInt(-err))) {
|
||||
.SUCCESS => {},
|
||||
.NOENT,
|
||||
.NXIO,
|
||||
|
|
@ -417,8 +417,8 @@ pub const Context = struct {
|
|||
if (lib.snd_pcm_hw_params_get_rate_max(params, &rate_max, null) < 0)
|
||||
continue;
|
||||
break :blk .{
|
||||
.min = @intCast(u24, rate_min),
|
||||
.max = @intCast(u24, rate_max),
|
||||
.min = @as(u24, @intCast(rate_min)),
|
||||
.max = @as(u24, @intCast(rate_max)),
|
||||
};
|
||||
},
|
||||
.id = try self.allocator.dupeZ(u8, id),
|
||||
|
|
@ -464,7 +464,7 @@ pub const Context = struct {
|
|||
pcm,
|
||||
toAlsaFormat(format),
|
||||
c.SND_PCM_ACCESS_RW_INTERLEAVED,
|
||||
@intCast(c_uint, device.channels.len),
|
||||
@as(c_uint, @intCast(device.channels.len)),
|
||||
sample_rate,
|
||||
1,
|
||||
main.default_latency,
|
||||
|
|
@ -622,10 +622,10 @@ pub const Player = struct {
|
|||
if (lib.snd_mixer_selem_get_playback_volume_range(self.mixer_elm, &min_vol, &max_vol) < 0)
|
||||
return error.CannotSetVolume;
|
||||
|
||||
const dist = @floatFromInt(f32, max_vol - min_vol);
|
||||
const dist = @as(f32, @floatFromInt(max_vol - min_vol));
|
||||
if (lib.snd_mixer_selem_set_playback_volume_all(
|
||||
self.mixer_elm,
|
||||
@intFromFloat(c_long, dist * vol) + min_vol,
|
||||
@as(c_long, @intFromFloat(dist * vol)) + min_vol,
|
||||
) < 0)
|
||||
return error.CannotSetVolume;
|
||||
}
|
||||
|
|
@ -652,7 +652,7 @@ pub const Player = struct {
|
|||
if (lib.snd_mixer_selem_get_playback_volume_range(self.mixer_elm, &min_vol, &max_vol) < 0)
|
||||
return error.CannotGetVolume;
|
||||
|
||||
return @floatFromInt(f32, vol) / @floatFromInt(f32, max_vol - min_vol);
|
||||
return @as(f32, @floatFromInt(vol)) / @as(f32, @floatFromInt(max_vol - min_vol));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ pub const Context = struct {
|
|||
0,
|
||||
null,
|
||||
&io_size,
|
||||
@ptrCast(*anyopaque, devs),
|
||||
@as(*anyopaque, @ptrCast(devs)),
|
||||
) != c.noErr) {
|
||||
return error.OpeningDevice;
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ pub const Context = struct {
|
|||
0,
|
||||
null,
|
||||
&io_size,
|
||||
@ptrCast(*anyopaque, buf_list),
|
||||
@as(*anyopaque, @ptrCast(buf_list)),
|
||||
) != c.noErr) {
|
||||
return error.OpeningDevice;
|
||||
}
|
||||
|
|
@ -210,8 +210,8 @@ pub const Context = struct {
|
|||
.channels = channels,
|
||||
.formats = &.{ .i16, .i32, .f32 },
|
||||
.sample_rate = .{
|
||||
.min = @intFromFloat(u24, @floor(sample_rate)),
|
||||
.max = @intFromFloat(u24, @floor(sample_rate)),
|
||||
.min = @as(u24, @intFromFloat(@floor(sample_rate))),
|
||||
.max = @as(u24, @intFromFloat(@floor(sample_rate))),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -334,10 +334,10 @@ pub const Player = struct {
|
|||
_ = bus_number;
|
||||
_ = frames_left;
|
||||
|
||||
const self = @ptrCast(*Player, @alignCast(@alignOf(*Player), self_opaque.?));
|
||||
const self = @as(*Player, @ptrCast(@alignCast(@alignOf(*Player), self_opaque.?)));
|
||||
|
||||
for (self.channels, 0..) |*ch, i| {
|
||||
ch.ptr = @ptrCast([*]u8, buf.*.mBuffers[0].mData.?) + self.format.frameSize(i);
|
||||
ch.ptr = @as([*]u8, @ptrCast(buf.*.mBuffers[0].mData.?)) + self.format.frameSize(i);
|
||||
}
|
||||
const frames = buf.*.mBuffers[0].mDataByteSize / self.format.frameSize(self.channels.len);
|
||||
self.writeFn(self.user_data, frames);
|
||||
|
|
@ -412,7 +412,7 @@ fn freeDevice(allocator: std.mem.Allocator, device: main.Device) void {
|
|||
|
||||
fn createStreamDesc(format: main.Format, sample_rate: u24, ch_count: usize) !c.AudioStreamBasicDescription {
|
||||
var desc = c.AudioStreamBasicDescription{
|
||||
.mSampleRate = @floatFromInt(f64, sample_rate),
|
||||
.mSampleRate = @as(f64, @floatFromInt(sample_rate)),
|
||||
.mFormatID = c.kAudioFormatLinearPCM,
|
||||
.mFormatFlags = switch (format) {
|
||||
.i16 => c.kAudioFormatFlagIsSignedInteger,
|
||||
|
|
@ -425,7 +425,7 @@ fn createStreamDesc(format: main.Format, sample_rate: u24, ch_count: usize) !c.A
|
|||
.mBytesPerPacket = format.frameSize(ch_count),
|
||||
.mFramesPerPacket = 1,
|
||||
.mBytesPerFrame = format.frameSize(ch_count),
|
||||
.mChannelsPerFrame = @intCast(c_uint, ch_count),
|
||||
.mChannelsPerFrame = @as(c_uint, @intCast(ch_count)),
|
||||
.mBitsPerChannel = switch (format) {
|
||||
.i16 => 16,
|
||||
.i24 => 24,
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ pub const Context = struct {
|
|||
pub fn init(allocator: std.mem.Allocator, options: main.Context.Options) !backends.BackendContext {
|
||||
try lib.load();
|
||||
|
||||
lib.jack_set_error_function(@ptrCast(?*const fn ([*c]const u8) callconv(.C) void, &util.doNothing));
|
||||
lib.jack_set_info_function(@ptrCast(?*const fn ([*c]const u8) callconv(.C) void, &util.doNothing));
|
||||
lib.jack_set_error_function(@as(?*const fn ([*c]const u8) callconv(.C) void, @ptrCast(&util.doNothing)));
|
||||
lib.jack_set_info_function(@as(?*const fn ([*c]const u8) callconv(.C) void, @ptrCast(&util.doNothing)));
|
||||
|
||||
var status: c.jack_status_t = 0;
|
||||
var self = try allocator.create(Context);
|
||||
|
|
@ -120,16 +120,16 @@ pub const Context = struct {
|
|||
freeDevice(self.allocator, d);
|
||||
self.devices_info.clear(self.allocator);
|
||||
|
||||
const sample_rate = @intCast(u24, lib.jack_get_sample_rate(self.client));
|
||||
const sample_rate = @as(u24, @intCast(lib.jack_get_sample_rate(self.client)));
|
||||
|
||||
const port_names = lib.jack_get_ports(self.client, null, null, 0) orelse
|
||||
return error.OutOfMemory;
|
||||
defer lib.jack_free(@ptrCast(?*anyopaque, port_names));
|
||||
defer lib.jack_free(@as(?*anyopaque, @ptrCast(port_names)));
|
||||
|
||||
var i: usize = 0;
|
||||
outer: while (port_names[i] != null) : (i += 1) {
|
||||
const port = lib.jack_port_by_name(self.client, port_names[i]) orelse break;
|
||||
const port_type = lib.jack_port_type(port)[0..@intCast(usize, lib.jack_port_type_size())];
|
||||
const port_type = lib.jack_port_type(port)[0..@as(usize, @intCast(lib.jack_port_type_size()))];
|
||||
if (!std.mem.startsWith(u8, port_type, c.JACK_DEFAULT_AUDIO_TYPE))
|
||||
continue;
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ pub const Context = struct {
|
|||
for (self.devices_info.list.items) |*dev| {
|
||||
if (std.mem.eql(u8, dev.id, id) and mode == dev.mode) {
|
||||
const new_ch = main.Channel{
|
||||
.id = @enumFromInt(main.Channel.Id, dev.channels.len),
|
||||
.id = @as(main.Channel.Id, @enumFromInt(dev.channels.len)),
|
||||
};
|
||||
dev.channels = try self.allocator.realloc(dev.channels, dev.channels.len + 1);
|
||||
dev.channels[dev.channels.len - 1] = new_ch;
|
||||
|
|
@ -156,7 +156,7 @@ pub const Context = struct {
|
|||
.mode = mode,
|
||||
.channels = blk: {
|
||||
var channels = try self.allocator.alloc(main.Channel, 1);
|
||||
channels[0] = .{ .id = @enumFromInt(main.Channel.Id, 0) };
|
||||
channels[0] = .{ .id = @as(main.Channel.Id, @enumFromInt(0)) };
|
||||
break :blk channels;
|
||||
},
|
||||
.formats = &.{.f32},
|
||||
|
|
@ -174,18 +174,18 @@ pub const Context = struct {
|
|||
}
|
||||
|
||||
fn sampleRateCallback(_: c.jack_nframes_t, arg: ?*anyopaque) callconv(.C) c_int {
|
||||
var self = @ptrCast(*Context, @alignCast(@alignOf(*Context), arg.?));
|
||||
var self = @as(*Context, @ptrCast(@alignCast(@alignOf(*Context), arg.?)));
|
||||
self.watcher.?.deviceChangeFn(self.watcher.?.user_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fn portRegistrationCallback(_: c.jack_port_id_t, _: c_int, arg: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Context, @alignCast(@alignOf(*Context), arg.?));
|
||||
var self = @as(*Context, @ptrCast(@alignCast(@alignOf(*Context), arg.?)));
|
||||
self.watcher.?.deviceChangeFn(self.watcher.?.user_data);
|
||||
}
|
||||
|
||||
fn portRenameCalllback(_: c.jack_port_id_t, _: [*c]const u8, _: [*c]const u8, arg: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Context, @alignCast(@alignOf(*Context), arg.?));
|
||||
var self = @as(*Context, @ptrCast(@alignCast(@alignOf(*Context), arg.?)));
|
||||
self.watcher.?.deviceChangeFn(self.watcher.?.user_data);
|
||||
}
|
||||
|
||||
|
|
@ -266,10 +266,10 @@ pub const Player = struct {
|
|||
}
|
||||
|
||||
fn processCallback(n_frames: c.jack_nframes_t, self_opaque: ?*anyopaque) callconv(.C) c_int {
|
||||
const self = @ptrCast(*Player, @alignCast(@alignOf(*Player), self_opaque.?));
|
||||
const self = @as(*Player, @ptrCast(@alignCast(@alignOf(*Player), self_opaque.?)));
|
||||
|
||||
for (self.channels, 0..) |*ch, i| {
|
||||
ch.*.ptr = @ptrCast([*]u8, lib.jack_port_get_buffer(self.ports[i], n_frames));
|
||||
ch.*.ptr = @as([*]u8, @ptrCast(lib.jack_port_get_buffer(self.ports[i], n_frames)));
|
||||
}
|
||||
self.writeFn(self.user_data, n_frames);
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ pub const Player = struct {
|
|||
}
|
||||
|
||||
pub fn sampleRate(self: Player) u24 {
|
||||
return @intCast(u24, lib.jack_get_sample_rate(self.client));
|
||||
return @as(u24, @intCast(lib.jack_get_sample_rate(self.client)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ pub const Context = struct {
|
|||
} else {
|
||||
inline for (std.meta.fields(Backend), 0..) |b, i| {
|
||||
if (@typeInfo(
|
||||
std.meta.fieldInfo(backends.BackendContext, @enumFromInt(Backend, b.value)).type,
|
||||
std.meta.fieldInfo(backends.BackendContext, @as(Backend, @enumFromInt(b.value))).type,
|
||||
).Pointer.child.init(allocator, options)) |d| {
|
||||
break :blk d;
|
||||
} else |err| {
|
||||
|
|
@ -275,37 +275,37 @@ pub const Player = struct {
|
|||
fn unsignedToSigned(comptime T: type, sample: anytype) T {
|
||||
const half = 1 << (@bitSizeOf(@TypeOf(sample)) - 1);
|
||||
const trunc = @bitSizeOf(T) - @bitSizeOf(@TypeOf(sample));
|
||||
return @intCast(T, sample -% half) << trunc;
|
||||
return @as(T, @intCast(sample -% half)) << trunc;
|
||||
}
|
||||
|
||||
fn unsignedToFloat(comptime T: type, sample: anytype) T {
|
||||
const max_int = std.math.maxInt(@TypeOf(sample)) + 1.0;
|
||||
return (@floatFromInt(T, sample) - max_int) * 1.0 / max_int;
|
||||
return (@as(T, @floatFromInt(sample)) - max_int) * 1.0 / max_int;
|
||||
}
|
||||
|
||||
fn signedToSigned(comptime T: type, sample: anytype) T {
|
||||
const trunc = @bitSizeOf(@TypeOf(sample)) - @bitSizeOf(T);
|
||||
return @intCast(T, sample >> trunc);
|
||||
return @as(T, @intCast(sample >> trunc));
|
||||
}
|
||||
|
||||
fn signedToUnsigned(comptime T: type, sample: anytype) T {
|
||||
const half = 1 << (@bitSizeOf(T) - 1);
|
||||
const trunc = @bitSizeOf(@TypeOf(sample)) - @bitSizeOf(T);
|
||||
return @intCast(T, (sample >> trunc) + half);
|
||||
return @as(T, @intCast((sample >> trunc) + half));
|
||||
}
|
||||
|
||||
fn signedToFloat(comptime T: type, sample: anytype) T {
|
||||
const max_int = std.math.maxInt(@TypeOf(sample)) + 1.0;
|
||||
return @floatFromInt(T, sample) * 1.0 / max_int;
|
||||
return @as(T, @floatFromInt(sample)) * 1.0 / max_int;
|
||||
}
|
||||
|
||||
fn floatToSigned(comptime T: type, sample: f64) T {
|
||||
return @intFromFloat(T, sample * std.math.maxInt(T));
|
||||
return @as(T, @intFromFloat(sample * std.math.maxInt(T)));
|
||||
}
|
||||
|
||||
fn floatToUnsigned(comptime T: type, sample: f64) T {
|
||||
const half = 1 << @bitSizeOf(T) - 1;
|
||||
return @intFromFloat(T, sample * (half - 1) + half);
|
||||
return @as(T, @intFromFloat(sample * (half - 1) + half));
|
||||
}
|
||||
|
||||
pub const Device = struct {
|
||||
|
|
@ -404,7 +404,7 @@ pub const Format = enum {
|
|||
}
|
||||
|
||||
pub fn frameSize(self: Format, ch_count: usize) u8 {
|
||||
return self.size() * @intCast(u5, ch_count);
|
||||
return self.size() * @as(u5, @intCast(ch_count));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ pub const Context = struct {
|
|||
c.PW_KEY_AUDIO_RATE,
|
||||
audio_rate.ptr,
|
||||
|
||||
@ptrFromInt(*allowzero u0, 0),
|
||||
@as(*allowzero u0, @ptrFromInt(0)),
|
||||
);
|
||||
|
||||
var player = try self.allocator.create(Player);
|
||||
|
|
@ -236,7 +236,7 @@ pub const Context = struct {
|
|||
};
|
||||
var info = c.spa_audio_info_raw{
|
||||
.format = c.SPA_AUDIO_FORMAT_F32,
|
||||
.channels = @intCast(u32, device.channels.len),
|
||||
.channels = @as(u32, @intCast(device.channels.len)),
|
||||
.rate = options.sample_rate,
|
||||
.flags = 0,
|
||||
.position = undefined,
|
||||
|
|
@ -289,7 +289,7 @@ pub const Player = struct {
|
|||
_ = old_state;
|
||||
_ = err;
|
||||
|
||||
var self = @ptrCast(*Player, @alignCast(@alignOf(*Player), self_opaque.?));
|
||||
var self = @as(*Player, @ptrCast(@alignCast(@alignOf(*Player), self_opaque.?)));
|
||||
|
||||
if (state == c.PW_STREAM_STATE_STREAMING or state == c.PW_STREAM_STATE_ERROR) {
|
||||
lib.pw_thread_loop_signal(self.thread, false);
|
||||
|
|
@ -297,7 +297,7 @@ pub const Player = struct {
|
|||
}
|
||||
|
||||
pub fn processCb(self_opaque: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Player, @alignCast(@alignOf(*Player), self_opaque.?));
|
||||
var self = @as(*Player, @ptrCast(@alignCast(@alignOf(*Player), self_opaque.?)));
|
||||
|
||||
const buf = lib.pw_stream_dequeue_buffer(self.stream) orelse unreachable;
|
||||
if (buf.*.buffer.*.datas[0].data == null) return;
|
||||
|
|
@ -313,10 +313,10 @@ pub const Player = struct {
|
|||
const stride = self.format.frameSize(self.channels.len);
|
||||
const n_frames = @min(buf.*.requested, buf.*.buffer.*.datas[0].maxsize / stride);
|
||||
buf.*.buffer.*.datas[0].chunk.*.stride = stride;
|
||||
buf.*.buffer.*.datas[0].chunk.*.size = @intCast(u32, n_frames * stride);
|
||||
buf.*.buffer.*.datas[0].chunk.*.size = @as(u32, @intCast(n_frames * stride));
|
||||
|
||||
for (self.channels, 0..) |*ch, i| {
|
||||
ch.ptr = @ptrCast([*]u8, buf.*.buffer.*.datas[0].data.?) + self.format.frameSize(i);
|
||||
ch.ptr = @as([*]u8, @ptrCast(buf.*.buffer.*.datas[0].data.?)) + self.format.frameSize(i);
|
||||
}
|
||||
self.writeFn(self.user_data, n_frames);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,12 +192,12 @@ pub const Context = struct {
|
|||
}
|
||||
|
||||
fn subscribeOp(_: ?*c.pa_context, _: c.pa_subscription_event_type_t, _: u32, user_data: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Context, @alignCast(@alignOf(*Context), user_data.?));
|
||||
var self = @as(*Context, @ptrCast(@alignCast(@alignOf(*Context), user_data.?)));
|
||||
self.watcher.?.deviceChangeFn(self.watcher.?.user_data);
|
||||
}
|
||||
|
||||
fn contextStateOp(ctx: ?*c.pa_context, user_data: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Context, @alignCast(@alignOf(*Context), user_data.?));
|
||||
var self = @as(*Context, @ptrCast(@alignCast(@alignOf(*Context), user_data.?)));
|
||||
|
||||
self.ctx_state = lib.pa_context_get_state(ctx);
|
||||
lib.pa_threaded_mainloop_signal(self.main_loop, 0);
|
||||
|
|
@ -255,7 +255,7 @@ pub const Context = struct {
|
|||
}
|
||||
|
||||
fn serverInfoOp(_: ?*c.pa_context, info: [*c]const c.pa_server_info, user_data: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Context, @alignCast(@alignOf(*Context), user_data.?));
|
||||
var self = @as(*Context, @ptrCast(@alignCast(@alignOf(*Context), user_data.?)));
|
||||
|
||||
defer lib.pa_threaded_mainloop_signal(self.main_loop, 0);
|
||||
self.default_sink = self.allocator.dupeZ(u8, std.mem.span(info.*.default_sink_name)) catch return;
|
||||
|
|
@ -266,7 +266,7 @@ pub const Context = struct {
|
|||
}
|
||||
|
||||
fn sinkInfoOp(_: ?*c.pa_context, info: [*c]const c.pa_sink_info, eol: c_int, user_data: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Context, @alignCast(@alignOf(*Context), user_data.?));
|
||||
var self = @as(*Context, @ptrCast(@alignCast(@alignOf(*Context), user_data.?)));
|
||||
if (eol != 0) {
|
||||
lib.pa_threaded_mainloop_signal(self.main_loop, 0);
|
||||
return;
|
||||
|
|
@ -276,7 +276,7 @@ pub const Context = struct {
|
|||
}
|
||||
|
||||
fn sourceInfoOp(_: ?*c.pa_context, info: [*c]const c.pa_source_info, eol: c_int, user_data: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Context, @alignCast(@alignOf(*Context), user_data.?));
|
||||
var self = @as(*Context, @ptrCast(@alignCast(@alignOf(*Context), user_data.?)));
|
||||
if (eol != 0) {
|
||||
lib.pa_threaded_mainloop_signal(self.main_loop, 0);
|
||||
return;
|
||||
|
|
@ -301,8 +301,8 @@ pub const Context = struct {
|
|||
},
|
||||
.formats = available_formats,
|
||||
.sample_rate = .{
|
||||
.min = @intCast(u24, info.*.sample_spec.rate),
|
||||
.max = @intCast(u24, info.*.sample_spec.rate),
|
||||
.min = @as(u24, @intCast(info.*.sample_spec.rate)),
|
||||
.max = @as(u24, @intCast(info.*.sample_spec.rate)),
|
||||
},
|
||||
.id = id,
|
||||
.name = name,
|
||||
|
|
@ -329,7 +329,7 @@ pub const Context = struct {
|
|||
const sample_spec = c.pa_sample_spec{
|
||||
.format = toPAFormat(format),
|
||||
.rate = sample_rate,
|
||||
.channels = @intCast(u5, device.channels.len),
|
||||
.channels = @as(u5, @intCast(device.channels.len)),
|
||||
};
|
||||
|
||||
const channel_map = try toPAChannelMap(device.channels);
|
||||
|
|
@ -397,7 +397,7 @@ pub const Context = struct {
|
|||
};
|
||||
|
||||
fn streamStateOp(stream: ?*c.pa_stream, user_data: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*StreamStatus, @alignCast(@alignOf(*StreamStatus), user_data.?));
|
||||
var self = @as(*StreamStatus, @ptrCast(@alignCast(@alignOf(*StreamStatus), user_data.?)));
|
||||
|
||||
switch (lib.pa_stream_get_state(stream)) {
|
||||
c.PA_STREAM_UNCONNECTED,
|
||||
|
|
@ -456,14 +456,14 @@ pub const Player = struct {
|
|||
}
|
||||
|
||||
fn playbackStreamWriteOp(_: ?*c.pa_stream, nbytes: usize, user_data: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Player, @alignCast(@alignOf(*Player), user_data.?));
|
||||
var self = @as(*Player, @ptrCast(@alignCast(@alignOf(*Player), user_data.?)));
|
||||
|
||||
var frames_left = nbytes;
|
||||
if (lib.pa_stream_begin_write(
|
||||
self.stream,
|
||||
@ptrCast(
|
||||
@as(
|
||||
[*c]?*anyopaque,
|
||||
@alignCast(@alignOf([*c]?*anyopaque), &self.write_ptr),
|
||||
@ptrCast(@alignCast(@alignOf([*c]?*anyopaque), &self.write_ptr)),
|
||||
),
|
||||
&frames_left,
|
||||
) != 0) {
|
||||
|
|
@ -519,7 +519,7 @@ pub const Player = struct {
|
|||
|
||||
var cvolume: c.pa_cvolume = undefined;
|
||||
_ = lib.pa_cvolume_init(&cvolume);
|
||||
_ = lib.pa_cvolume_set(&cvolume, @intCast(c_uint, self.channels.len), lib.pa_sw_volume_from_linear(vol));
|
||||
_ = lib.pa_cvolume_set(&cvolume, @as(c_uint, @intCast(self.channels.len)), lib.pa_sw_volume_from_linear(vol));
|
||||
|
||||
performOperation(
|
||||
self.main_loop,
|
||||
|
|
@ -534,7 +534,7 @@ pub const Player = struct {
|
|||
}
|
||||
|
||||
fn successOp(_: ?*c.pa_context, success: c_int, user_data: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Player, @alignCast(@alignOf(*Player), user_data.?));
|
||||
var self = @as(*Player, @ptrCast(@alignCast(@alignOf(*Player), user_data.?)));
|
||||
if (success == 1)
|
||||
lib.pa_threaded_mainloop_signal(self.main_loop, 0);
|
||||
}
|
||||
|
|
@ -557,14 +557,14 @@ pub const Player = struct {
|
|||
}
|
||||
|
||||
fn sinkInputInfoOp(_: ?*c.pa_context, info: [*c]const c.pa_sink_input_info, eol: c_int, user_data: ?*anyopaque) callconv(.C) void {
|
||||
var self = @ptrCast(*Player, @alignCast(@alignOf(*Player), user_data.?));
|
||||
var self = @as(*Player, @ptrCast(@alignCast(@alignOf(*Player), user_data.?)));
|
||||
|
||||
if (eol != 0) {
|
||||
lib.pa_threaded_mainloop_signal(self.main_loop, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
self.vol = @floatFromInt(f32, info.*.volume.values[0]) / @floatFromInt(f32, c.PA_VOLUME_NORM);
|
||||
self.vol = @as(f32, @floatFromInt(info.*.volume.values[0])) / @as(f32, @floatFromInt(c.PA_VOLUME_NORM));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -638,7 +638,7 @@ pub fn toPAFormat(format: main.Format) c.pa_sample_format_t {
|
|||
|
||||
pub fn toPAChannelMap(channels: []const main.Channel) !c.pa_channel_map {
|
||||
var channel_map: c.pa_channel_map = undefined;
|
||||
channel_map.channels = @intCast(u5, channels.len);
|
||||
channel_map.channels = @as(u5, @intCast(channels.len));
|
||||
for (channels, 0..) |ch, i|
|
||||
channel_map.map[i] = try toPAChannelPos(ch.id);
|
||||
return channel_map;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ pub const Context = struct {
|
|||
null,
|
||||
win32.CLSCTX_ALL,
|
||||
win32.IID_IMMDeviceEnumerator,
|
||||
@ptrCast(*?*anyopaque, &enumerator),
|
||||
@as(*?*anyopaque, @ptrCast(&enumerator)),
|
||||
);
|
||||
switch (hr) {
|
||||
win32.S_OK => {},
|
||||
|
|
@ -99,7 +99,7 @@ pub const Context = struct {
|
|||
|
||||
fn queryInterfaceCB(self: *const win32.IUnknown, riid: ?*const win32.Guid, ppv: ?*?*anyopaque) callconv(std.os.windows.WINAPI) win32.HRESULT {
|
||||
if (riid.?.eql(win32.IID_IUnknown.*) or riid.?.eql(win32.IID_IMMNotificationClient.*)) {
|
||||
ppv.?.* = @ptrFromInt(?*anyopaque, @intFromPtr(self));
|
||||
ppv.?.* = @as(?*anyopaque, @ptrFromInt(@intFromPtr(self)));
|
||||
_ = self.AddRef();
|
||||
return win32.S_OK;
|
||||
} else {
|
||||
|
|
@ -266,16 +266,16 @@ pub const Context = struct {
|
|||
win32.S_OK, win32.INPLACE_S_TRUNCATED => {},
|
||||
else => return error.OpeningDevice,
|
||||
}
|
||||
var wf = @ptrCast(
|
||||
var wf = @as(
|
||||
*win32.WAVEFORMATEXTENSIBLE,
|
||||
variant.anon.anon.anon.blob.pBlobData,
|
||||
@ptrCast(variant.anon.anon.anon.blob.pBlobData),
|
||||
);
|
||||
defer win32.CoTaskMemFree(variant.anon.anon.anon.blob.pBlobData);
|
||||
|
||||
var device = main.Device{
|
||||
.mode = blk: {
|
||||
var endpoint: ?*win32.IMMEndpoint = null;
|
||||
hr = imm_device.?.QueryInterface(win32.IID_IMMEndpoint, @ptrCast(?*?*anyopaque, &endpoint));
|
||||
hr = imm_device.?.QueryInterface(win32.IID_IMMEndpoint, @as(?*?*anyopaque, @ptrCast(&endpoint)));
|
||||
switch (hr) {
|
||||
win32.S_OK => {},
|
||||
win32.E_POINTER => unreachable,
|
||||
|
|
@ -308,12 +308,12 @@ pub const Context = struct {
|
|||
break :blk try chn_arr.toOwnedSlice();
|
||||
},
|
||||
.sample_rate = .{
|
||||
.min = @intCast(u24, wf.Format.nSamplesPerSec),
|
||||
.max = @intCast(u24, wf.Format.nSamplesPerSec),
|
||||
.min = @as(u24, @intCast(wf.Format.nSamplesPerSec)),
|
||||
.max = @as(u24, @intCast(wf.Format.nSamplesPerSec)),
|
||||
},
|
||||
.formats = blk: {
|
||||
var audio_client: ?*win32.IAudioClient = null;
|
||||
hr = imm_device.?.Activate(win32.IID_IAudioClient, win32.CLSCTX_ALL, null, @ptrCast(?*?*anyopaque, &audio_client));
|
||||
hr = imm_device.?.Activate(win32.IID_IAudioClient, win32.CLSCTX_ALL, null, @as(?*?*anyopaque, @ptrCast(&audio_client)));
|
||||
switch (hr) {
|
||||
win32.S_OK => {},
|
||||
win32.E_POINTER => unreachable,
|
||||
|
|
@ -330,7 +330,7 @@ pub const Context = struct {
|
|||
setWaveFormatFormat(wf, format);
|
||||
if (audio_client.?.IsFormatSupported(
|
||||
.SHARED,
|
||||
@ptrCast(?*const win32.WAVEFORMATEX, @alignCast(@alignOf(*win32.WAVEFORMATEX), wf)),
|
||||
@as(?*const win32.WAVEFORMATEX, @ptrCast(@alignCast(@alignOf(*win32.WAVEFORMATEX), wf))),
|
||||
&closest_match,
|
||||
) == win32.S_OK) {
|
||||
try fmt_arr.append(format);
|
||||
|
|
@ -448,9 +448,9 @@ pub const Context = struct {
|
|||
|
||||
var audio_client: ?*win32.IAudioClient = null;
|
||||
var audio_client3: ?*win32.IAudioClient3 = null;
|
||||
hr = imm_device.?.Activate(win32.IID_IAudioClient3, win32.CLSCTX_ALL, null, @ptrCast(?*?*anyopaque, &audio_client3));
|
||||
hr = imm_device.?.Activate(win32.IID_IAudioClient3, win32.CLSCTX_ALL, null, @as(?*?*anyopaque, @ptrCast(&audio_client3)));
|
||||
if (hr == win32.S_OK) {
|
||||
hr = audio_client3.?.QueryInterface(win32.IID_IAudioClient, @ptrCast(?*?*anyopaque, &audio_client));
|
||||
hr = audio_client3.?.QueryInterface(win32.IID_IAudioClient, @as(?*?*anyopaque, @ptrCast(&audio_client)));
|
||||
switch (hr) {
|
||||
win32.S_OK => {},
|
||||
win32.E_NOINTERFACE => unreachable,
|
||||
|
|
@ -458,7 +458,7 @@ pub const Context = struct {
|
|||
else => return error.OpeningDevice,
|
||||
}
|
||||
} else {
|
||||
hr = imm_device.?.Activate(win32.IID_IAudioClient, win32.CLSCTX_ALL, null, @ptrCast(?*?*anyopaque, &audio_client));
|
||||
hr = imm_device.?.Activate(win32.IID_IAudioClient, win32.CLSCTX_ALL, null, @as(?*?*anyopaque, @ptrCast(&audio_client)));
|
||||
switch (hr) {
|
||||
win32.S_OK => {},
|
||||
win32.E_POINTER => unreachable,
|
||||
|
|
@ -476,7 +476,7 @@ pub const Context = struct {
|
|||
const wave_format = win32.WAVEFORMATEXTENSIBLE{
|
||||
.Format = .{
|
||||
.wFormatTag = win32.WAVE_FORMAT_EXTENSIBLE,
|
||||
.nChannels = @intCast(u16, device.channels.len),
|
||||
.nChannels = @as(u16, @intCast(device.channels.len)),
|
||||
.nSamplesPerSec = sample_rate,
|
||||
.nAvgBytesPerSec = sample_rate * format.frameSize(device.channels.len),
|
||||
.nBlockAlign = format.frameSize(device.channels.len),
|
||||
|
|
@ -494,7 +494,7 @@ pub const Context = struct {
|
|||
hr = audio_client3.?.InitializeSharedAudioStream(
|
||||
win32.AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
|
||||
0, // TODO: use the advantage of AudioClient3
|
||||
@ptrCast(?*const win32.WAVEFORMATEX, @alignCast(@alignOf(*win32.WAVEFORMATEX), &wave_format)),
|
||||
@as(?*const win32.WAVEFORMATEX, @ptrCast(@alignCast(@alignOf(*win32.WAVEFORMATEX), &wave_format))),
|
||||
null,
|
||||
);
|
||||
switch (hr) {
|
||||
|
|
@ -521,7 +521,7 @@ pub const Context = struct {
|
|||
win32.AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
|
||||
0,
|
||||
0,
|
||||
@ptrCast(?*const win32.WAVEFORMATEX, @alignCast(@alignOf(*win32.WAVEFORMATEX), &wave_format)),
|
||||
@as(?*const win32.WAVEFORMATEX, @ptrCast(@alignCast(@alignOf(*win32.WAVEFORMATEX), &wave_format))),
|
||||
null,
|
||||
);
|
||||
switch (hr) {
|
||||
|
|
@ -547,7 +547,7 @@ pub const Context = struct {
|
|||
}
|
||||
|
||||
var render_client: ?*win32.IAudioRenderClient = null;
|
||||
hr = audio_client.?.GetService(win32.IID_IAudioRenderClient, @ptrCast(?*?*anyopaque, &render_client));
|
||||
hr = audio_client.?.GetService(win32.IID_IAudioRenderClient, @as(?*?*anyopaque, @ptrCast(&render_client)));
|
||||
switch (hr) {
|
||||
win32.S_OK => {},
|
||||
win32.E_POINTER => unreachable,
|
||||
|
|
@ -560,7 +560,7 @@ pub const Context = struct {
|
|||
}
|
||||
|
||||
var simple_volume: ?*win32.ISimpleAudioVolume = null;
|
||||
hr = audio_client.?.GetService(win32.IID_ISimpleAudioVolume, @ptrCast(?*?*anyopaque, &simple_volume));
|
||||
hr = audio_client.?.GetService(win32.IID_ISimpleAudioVolume, @as(?*?*anyopaque, @ptrCast(&simple_volume)));
|
||||
switch (hr) {
|
||||
win32.S_OK => {},
|
||||
win32.E_POINTER => unreachable,
|
||||
|
|
@ -728,7 +728,7 @@ pub const Player = struct {
|
|||
const frames = buf_frames - padding_frames;
|
||||
if (frames > 0) {
|
||||
var data: [*]u8 = undefined;
|
||||
hr = self.render_client.?.GetBuffer(frames, @ptrCast(?*?*u8, &data));
|
||||
hr = self.render_client.?.GetBuffer(frames, @as(?*?*u8, @ptrCast(&data)));
|
||||
switch (hr) {
|
||||
win32.S_OK => {},
|
||||
win32.E_POINTER => unreachable,
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ pub const Guid = extern union {
|
|||
return guid;
|
||||
}
|
||||
fn hexVal(c: u8) u4 {
|
||||
if (c <= '9') return @intCast(u4, c - '0');
|
||||
if (c >= 'a') return @intCast(u4, c + 10 - 'a');
|
||||
return @intCast(u4, c + 10 - 'A');
|
||||
if (c <= '9') return @as(u4, @intCast(c - '0'));
|
||||
if (c >= 'a') return @as(u4, @intCast(c + 10 - 'a'));
|
||||
return @as(u4, @intCast(c + 10 - 'A'));
|
||||
}
|
||||
fn decodeHexByte(hex: [2]u8) u8 {
|
||||
return @intCast(u8, hexVal(hex[0])) << 4 | hexVal(hex[1]);
|
||||
return @as(u8, @intCast(hexVal(hex[0]))) << 4 | hexVal(hex[1]);
|
||||
}
|
||||
pub fn eql(riid1: Guid, riid2: Guid) bool {
|
||||
return riid1.Ints.a == riid2.Ints.a and
|
||||
|
|
@ -259,13 +259,13 @@ pub const IUnknown = extern struct {
|
|||
pub fn MethodMixin(comptime T: type) type {
|
||||
return struct {
|
||||
pub inline fn QueryInterface(self: *const T, riid: ?*const Guid, ppvObject: ?*?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IUnknown.VTable, self.vtable).QueryInterface(@ptrCast(*const IUnknown, self), riid, ppvObject);
|
||||
return @as(*const IUnknown.VTable, @ptrCast(self.vtable)).QueryInterface(@as(*const IUnknown, @ptrCast(self)), riid, ppvObject);
|
||||
}
|
||||
pub inline fn AddRef(self: *const T) u32 {
|
||||
return @ptrCast(*const IUnknown.VTable, self.vtable).AddRef(@ptrCast(*const IUnknown, self));
|
||||
return @as(*const IUnknown.VTable, @ptrCast(self.vtable)).AddRef(@as(*const IUnknown, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn Release(self: *const T) u32 {
|
||||
return @ptrCast(*const IUnknown.VTable, self.vtable).Release(@ptrCast(*const IUnknown, self));
|
||||
return @as(*const IUnknown.VTable, @ptrCast(self.vtable)).Release(@as(*const IUnknown, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1239,40 +1239,40 @@ pub const IAudioClient = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IUnknown.MethodMixin(T);
|
||||
pub inline fn Initialize(self: *const T, ShareMode: AUDCLNT_SHAREMODE, StreamFlags: u32, hnsBufferDuration: i64, hnsPeriodicity: i64, pFormat: ?*const WAVEFORMATEX, AudioSessionGuid: ?*const Guid) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).Initialize(@ptrCast(*const IAudioClient, self), ShareMode, StreamFlags, hnsBufferDuration, hnsPeriodicity, pFormat, AudioSessionGuid);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).Initialize(@as(*const IAudioClient, @ptrCast(self)), ShareMode, StreamFlags, hnsBufferDuration, hnsPeriodicity, pFormat, AudioSessionGuid);
|
||||
}
|
||||
pub inline fn GetBufferSize(self: *const T, pNumBufferFrames: ?*u32) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).GetBufferSize(@ptrCast(*const IAudioClient, self), pNumBufferFrames);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).GetBufferSize(@as(*const IAudioClient, @ptrCast(self)), pNumBufferFrames);
|
||||
}
|
||||
pub inline fn GetStreamLatency(self: *const T, phnsLatency: ?*i64) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).GetStreamLatency(@ptrCast(*const IAudioClient, self), phnsLatency);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).GetStreamLatency(@as(*const IAudioClient, @ptrCast(self)), phnsLatency);
|
||||
}
|
||||
pub inline fn GetCurrentPadding(self: *const T, pNumPaddingFrames: ?*u32) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).GetCurrentPadding(@ptrCast(*const IAudioClient, self), pNumPaddingFrames);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).GetCurrentPadding(@as(*const IAudioClient, @ptrCast(self)), pNumPaddingFrames);
|
||||
}
|
||||
pub inline fn IsFormatSupported(self: *const T, ShareMode: AUDCLNT_SHAREMODE, pFormat: ?*const WAVEFORMATEX, ppClosestMatch: ?*?*WAVEFORMATEX) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).IsFormatSupported(@ptrCast(*const IAudioClient, self), ShareMode, pFormat, ppClosestMatch);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).IsFormatSupported(@as(*const IAudioClient, @ptrCast(self)), ShareMode, pFormat, ppClosestMatch);
|
||||
}
|
||||
pub inline fn GetMixFormat(self: *const T, ppDeviceFormat: ?*?*WAVEFORMATEX) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).GetMixFormat(@ptrCast(*const IAudioClient, self), ppDeviceFormat);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).GetMixFormat(@as(*const IAudioClient, @ptrCast(self)), ppDeviceFormat);
|
||||
}
|
||||
pub inline fn GetDevicePeriod(self: *const T, phnsDefaultDevicePeriod: ?*i64, phnsMinimumDevicePeriod: ?*i64) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).GetDevicePeriod(@ptrCast(*const IAudioClient, self), phnsDefaultDevicePeriod, phnsMinimumDevicePeriod);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).GetDevicePeriod(@as(*const IAudioClient, @ptrCast(self)), phnsDefaultDevicePeriod, phnsMinimumDevicePeriod);
|
||||
}
|
||||
pub inline fn Start(self: *const T) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).Start(@ptrCast(*const IAudioClient, self));
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).Start(@as(*const IAudioClient, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn Stop(self: *const T) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).Stop(@ptrCast(*const IAudioClient, self));
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).Stop(@as(*const IAudioClient, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn Reset(self: *const T) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).Reset(@ptrCast(*const IAudioClient, self));
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).Reset(@as(*const IAudioClient, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn SetEventHandle(self: *const T, eventHandle: ?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).SetEventHandle(@ptrCast(*const IAudioClient, self), eventHandle);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).SetEventHandle(@as(*const IAudioClient, @ptrCast(self)), eventHandle);
|
||||
}
|
||||
pub inline fn GetService(self: *const T, riid: ?*const Guid, ppv: ?*?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.vtable).GetService(@ptrCast(*const IAudioClient, self), riid, ppv);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.vtable)).GetService(@as(*const IAudioClient, @ptrCast(self)), riid, ppv);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1354,13 +1354,13 @@ pub const IAudioClient2 = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IAudioClient.MethodMixin(T);
|
||||
pub inline fn IsOffloadCapable(self: *const T, Category: AUDIO_STREAM_CATEGORY, pbOffloadCapable: ?*BOOL) HRESULT {
|
||||
return @ptrCast(*const IAudioClient2.VTable, self.vtable).IsOffloadCapable(@ptrCast(*const IAudioClient2, self), Category, pbOffloadCapable);
|
||||
return @as(*const IAudioClient2.VTable, @ptrCast(self.vtable)).IsOffloadCapable(@as(*const IAudioClient2, @ptrCast(self)), Category, pbOffloadCapable);
|
||||
}
|
||||
pub inline fn SetClientProperties(self: *const T, pProperties: ?*const AudioClientProperties) HRESULT {
|
||||
return @ptrCast(*const IAudioClient2.VTable, self.vtable).SetClientProperties(@ptrCast(*const IAudioClient2, self), pProperties);
|
||||
return @as(*const IAudioClient2.VTable, @ptrCast(self.vtable)).SetClientProperties(@as(*const IAudioClient2, @ptrCast(self)), pProperties);
|
||||
}
|
||||
pub inline fn GetBufferSizeLimits(self: *const T, pFormat: ?*const WAVEFORMATEX, bEventDriven: BOOL, phnsMinBufferDuration: ?*i64, phnsMaxBufferDuration: ?*i64) HRESULT {
|
||||
return @ptrCast(*const IAudioClient2.VTable, self.vtable).GetBufferSizeLimits(@ptrCast(*const IAudioClient2, self), pFormat, bEventDriven, phnsMinBufferDuration, phnsMaxBufferDuration);
|
||||
return @as(*const IAudioClient2.VTable, @ptrCast(self.vtable)).GetBufferSizeLimits(@as(*const IAudioClient2, @ptrCast(self)), pFormat, bEventDriven, phnsMinBufferDuration, phnsMaxBufferDuration);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1422,13 +1422,13 @@ pub const IAudioClient3 = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IAudioClient2.MethodMixin(T);
|
||||
pub inline fn GetSharedModeEnginePeriod(self: *const T, pFormat: ?*const WAVEFORMATEX, pDefaultPeriodInFrames: ?*u32, pFundamentalPeriodInFrames: ?*u32, pMinPeriodInFrames: ?*u32, pMaxPeriodInFrames: ?*u32) HRESULT {
|
||||
return @ptrCast(*const IAudioClient3.VTable, self.vtable).GetSharedModeEnginePeriod(@ptrCast(*const IAudioClient3, self), pFormat, pDefaultPeriodInFrames, pFundamentalPeriodInFrames, pMinPeriodInFrames, pMaxPeriodInFrames);
|
||||
return @as(*const IAudioClient3.VTable, @ptrCast(self.vtable)).GetSharedModeEnginePeriod(@as(*const IAudioClient3, @ptrCast(self)), pFormat, pDefaultPeriodInFrames, pFundamentalPeriodInFrames, pMinPeriodInFrames, pMaxPeriodInFrames);
|
||||
}
|
||||
pub inline fn GetCurrentSharedModeEnginePeriod(self: *const T, ppFormat: ?*?*WAVEFORMATEX, pCurrentPeriodInFrames: ?*u32) HRESULT {
|
||||
return @ptrCast(*const IAudioClient3.VTable, self.vtable).GetCurrentSharedModeEnginePeriod(@ptrCast(*const IAudioClient3, self), ppFormat, pCurrentPeriodInFrames);
|
||||
return @as(*const IAudioClient3.VTable, @ptrCast(self.vtable)).GetCurrentSharedModeEnginePeriod(@as(*const IAudioClient3, @ptrCast(self)), ppFormat, pCurrentPeriodInFrames);
|
||||
}
|
||||
pub inline fn InitializeSharedAudioStream(self: *const T, StreamFlags: u32, PeriodInFrames: u32, pFormat: ?*const WAVEFORMATEX, AudioSessionGuid: ?*const Guid) HRESULT {
|
||||
return @ptrCast(*const IAudioClient3.VTable, self.vtable).InitializeSharedAudioStream(@ptrCast(*const IAudioClient3, self), StreamFlags, PeriodInFrames, pFormat, AudioSessionGuid);
|
||||
return @as(*const IAudioClient3.VTable, @ptrCast(self.vtable)).InitializeSharedAudioStream(@as(*const IAudioClient3, @ptrCast(self)), StreamFlags, PeriodInFrames, pFormat, AudioSessionGuid);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1455,10 +1455,10 @@ pub const IAudioRenderClient = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IUnknown.MethodMixin(T);
|
||||
pub inline fn GetBuffer(self: *const T, NumFramesRequested: u32, ppData: ?*?*u8) HRESULT {
|
||||
return @ptrCast(*const IAudioRenderClient.VTable, self.vtable).GetBuffer(@ptrCast(*const IAudioRenderClient, self), NumFramesRequested, ppData);
|
||||
return @as(*const IAudioRenderClient.VTable, @ptrCast(self.vtable)).GetBuffer(@as(*const IAudioRenderClient, @ptrCast(self)), NumFramesRequested, ppData);
|
||||
}
|
||||
pub inline fn ReleaseBuffer(self: *const T, NumFramesWritten: u32, dwFlags: u32) HRESULT {
|
||||
return @ptrCast(*const IAudioRenderClient.VTable, self.vtable).ReleaseBuffer(@ptrCast(*const IAudioRenderClient, self), NumFramesWritten, dwFlags);
|
||||
return @as(*const IAudioRenderClient.VTable, @ptrCast(self.vtable)).ReleaseBuffer(@as(*const IAudioRenderClient, @ptrCast(self)), NumFramesWritten, dwFlags);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1492,16 +1492,16 @@ pub const ISimpleAudioVolume = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IUnknown.MethodMixin(T);
|
||||
pub inline fn SetMasterVolume(self: *const T, fLevel: f32, EventContext: ?*const Guid) HRESULT {
|
||||
return @ptrCast(*const ISimpleAudioVolume.VTable, self.vtable).SetMasterVolume(@ptrCast(*const ISimpleAudioVolume, self), fLevel, EventContext);
|
||||
return @as(*const ISimpleAudioVolume.VTable, @ptrCast(self.vtable)).SetMasterVolume(@as(*const ISimpleAudioVolume, @ptrCast(self)), fLevel, EventContext);
|
||||
}
|
||||
pub inline fn GetMasterVolume(self: *const T, pfLevel: ?*f32) HRESULT {
|
||||
return @ptrCast(*const ISimpleAudioVolume.VTable, self.vtable).GetMasterVolume(@ptrCast(*const ISimpleAudioVolume, self), pfLevel);
|
||||
return @as(*const ISimpleAudioVolume.VTable, @ptrCast(self.vtable)).GetMasterVolume(@as(*const ISimpleAudioVolume, @ptrCast(self)), pfLevel);
|
||||
}
|
||||
pub inline fn SetMute(self: *const T, bMute: BOOL, EventContext: ?*const Guid) HRESULT {
|
||||
return @ptrCast(*const ISimpleAudioVolume.VTable, self.vtable).SetMute(@ptrCast(*const ISimpleAudioVolume, self), bMute, EventContext);
|
||||
return @as(*const ISimpleAudioVolume.VTable, @ptrCast(self.vtable)).SetMute(@as(*const ISimpleAudioVolume, @ptrCast(self)), bMute, EventContext);
|
||||
}
|
||||
pub inline fn GetMute(self: *const T, pbMute: ?*BOOL) HRESULT {
|
||||
return @ptrCast(*const ISimpleAudioVolume.VTable, self.vtable).GetMute(@ptrCast(*const ISimpleAudioVolume, self), pbMute);
|
||||
return @as(*const ISimpleAudioVolume.VTable, @ptrCast(self.vtable)).GetMute(@as(*const ISimpleAudioVolume, @ptrCast(self)), pbMute);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1538,19 +1538,19 @@ pub const IPropertyStore = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IUnknown.MethodMixin(T);
|
||||
pub inline fn GetCount(self: *const T, cProps: ?*u32) HRESULT {
|
||||
return @ptrCast(*const IPropertyStore.VTable, self.vtable).GetCount(@ptrCast(*const IPropertyStore, self), cProps);
|
||||
return @as(*const IPropertyStore.VTable, @ptrCast(self.vtable)).GetCount(@as(*const IPropertyStore, @ptrCast(self)), cProps);
|
||||
}
|
||||
pub inline fn GetAt(self: *const T, iProp: u32, pkey: ?*PROPERTYKEY) HRESULT {
|
||||
return @ptrCast(*const IPropertyStore.VTable, self.vtable).GetAt(@ptrCast(*const IPropertyStore, self), iProp, pkey);
|
||||
return @as(*const IPropertyStore.VTable, @ptrCast(self.vtable)).GetAt(@as(*const IPropertyStore, @ptrCast(self)), iProp, pkey);
|
||||
}
|
||||
pub inline fn GetValue(self: *const T, key: ?*const PROPERTYKEY, pv: ?*PROPVARIANT) HRESULT {
|
||||
return @ptrCast(*const IPropertyStore.VTable, self.vtable).GetValue(@ptrCast(*const IPropertyStore, self), key, pv);
|
||||
return @as(*const IPropertyStore.VTable, @ptrCast(self.vtable)).GetValue(@as(*const IPropertyStore, @ptrCast(self)), key, pv);
|
||||
}
|
||||
pub inline fn SetValue(self: *const T, key: ?*const PROPERTYKEY, propvar: ?*const PROPVARIANT) HRESULT {
|
||||
return @ptrCast(*const IPropertyStore.VTable, self.vtable).SetValue(@ptrCast(*const IPropertyStore, self), key, propvar);
|
||||
return @as(*const IPropertyStore.VTable, @ptrCast(self.vtable)).SetValue(@as(*const IPropertyStore, @ptrCast(self)), key, propvar);
|
||||
}
|
||||
pub inline fn Commit(self: *const T) HRESULT {
|
||||
return @ptrCast(*const IPropertyStore.VTable, self.vtable).Commit(@ptrCast(*const IPropertyStore, self));
|
||||
return @as(*const IPropertyStore.VTable, @ptrCast(self.vtable)).Commit(@as(*const IPropertyStore, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1586,16 +1586,16 @@ pub const IMMDevice = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IUnknown.MethodMixin(T);
|
||||
pub inline fn Activate(self: *const T, iid: ?*const Guid, dwClsCtx: u32, pActivationParams: ?*PROPVARIANT, ppInterface: ?*?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IMMDevice.VTable, self.vtable).Activate(@ptrCast(*const IMMDevice, self), iid, dwClsCtx, pActivationParams, ppInterface);
|
||||
return @as(*const IMMDevice.VTable, @ptrCast(self.vtable)).Activate(@as(*const IMMDevice, @ptrCast(self)), iid, dwClsCtx, pActivationParams, ppInterface);
|
||||
}
|
||||
pub inline fn OpenPropertyStore(self: *const T, stgmAccess: u32, ppProperties: ?*?*IPropertyStore) HRESULT {
|
||||
return @ptrCast(*const IMMDevice.VTable, self.vtable).OpenPropertyStore(@ptrCast(*const IMMDevice, self), stgmAccess, ppProperties);
|
||||
return @as(*const IMMDevice.VTable, @ptrCast(self.vtable)).OpenPropertyStore(@as(*const IMMDevice, @ptrCast(self)), stgmAccess, ppProperties);
|
||||
}
|
||||
pub inline fn GetId(self: *const T, ppstrId: ?*?PWSTR) HRESULT {
|
||||
return @ptrCast(*const IMMDevice.VTable, self.vtable).GetId(@ptrCast(*const IMMDevice, self), ppstrId);
|
||||
return @as(*const IMMDevice.VTable, @ptrCast(self.vtable)).GetId(@as(*const IMMDevice, @ptrCast(self)), ppstrId);
|
||||
}
|
||||
pub inline fn GetState(self: *const T, pdwState: ?*u32) HRESULT {
|
||||
return @ptrCast(*const IMMDevice.VTable, self.vtable).GetState(@ptrCast(*const IMMDevice, self), pdwState);
|
||||
return @as(*const IMMDevice.VTable, @ptrCast(self.vtable)).GetState(@as(*const IMMDevice, @ptrCast(self)), pdwState);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1635,19 +1635,19 @@ pub const IMMNotificationClient = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IUnknown.MethodMixin(T);
|
||||
pub inline fn OnDeviceStateChanged(self: *const T, pwstrDeviceId: ?[*:0]const u16, dwNewState: u32) HRESULT {
|
||||
return @ptrCast(*const IMMNotificationClient.VTable, self.vtable).OnDeviceStateChanged(@ptrCast(*const IMMNotificationClient, self), pwstrDeviceId, dwNewState);
|
||||
return @as(*const IMMNotificationClient.VTable, @ptrCast(self.vtable)).OnDeviceStateChanged(@as(*const IMMNotificationClient, @ptrCast(self)), pwstrDeviceId, dwNewState);
|
||||
}
|
||||
pub inline fn OnDeviceAdded(self: *const T, pwstrDeviceId: ?[*:0]const u16) HRESULT {
|
||||
return @ptrCast(*const IMMNotificationClient.VTable, self.vtable).OnDeviceAdded(@ptrCast(*const IMMNotificationClient, self), pwstrDeviceId);
|
||||
return @as(*const IMMNotificationClient.VTable, @ptrCast(self.vtable)).OnDeviceAdded(@as(*const IMMNotificationClient, @ptrCast(self)), pwstrDeviceId);
|
||||
}
|
||||
pub inline fn OnDeviceRemoved(self: *const T, pwstrDeviceId: ?[*:0]const u16) HRESULT {
|
||||
return @ptrCast(*const IMMNotificationClient.VTable, self.vtable).OnDeviceRemoved(@ptrCast(*const IMMNotificationClient, self), pwstrDeviceId);
|
||||
return @as(*const IMMNotificationClient.VTable, @ptrCast(self.vtable)).OnDeviceRemoved(@as(*const IMMNotificationClient, @ptrCast(self)), pwstrDeviceId);
|
||||
}
|
||||
pub inline fn OnDefaultDeviceChanged(self: *const T, flow: DataFlow, role: Role, pwstrDefaultDeviceId: ?[*:0]const u16) HRESULT {
|
||||
return @ptrCast(*const IMMNotificationClient.VTable, self.vtable).OnDefaultDeviceChanged(@ptrCast(*const IMMNotificationClient, self), flow, role, pwstrDefaultDeviceId);
|
||||
return @as(*const IMMNotificationClient.VTable, @ptrCast(self.vtable)).OnDefaultDeviceChanged(@as(*const IMMNotificationClient, @ptrCast(self)), flow, role, pwstrDefaultDeviceId);
|
||||
}
|
||||
pub inline fn OnPropertyValueChanged(self: *const T, pwstrDeviceId: ?[*:0]const u16, key: PROPERTYKEY) HRESULT {
|
||||
return @ptrCast(*const IMMNotificationClient.VTable, self.vtable).OnPropertyValueChanged(@ptrCast(*const IMMNotificationClient, self), pwstrDeviceId, key);
|
||||
return @as(*const IMMNotificationClient.VTable, @ptrCast(self.vtable)).OnPropertyValueChanged(@as(*const IMMNotificationClient, @ptrCast(self)), pwstrDeviceId, key);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1672,10 +1672,10 @@ pub const IMMDeviceCollection = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IUnknown.MethodMixin(T);
|
||||
pub inline fn GetCount(self: *const T, pcDevices: ?*u32) HRESULT {
|
||||
return @ptrCast(*const IMMDeviceCollection.VTable, self.vtable).GetCount(@ptrCast(*const IMMDeviceCollection, self), pcDevices);
|
||||
return @as(*const IMMDeviceCollection.VTable, @ptrCast(self.vtable)).GetCount(@as(*const IMMDeviceCollection, @ptrCast(self)), pcDevices);
|
||||
}
|
||||
pub inline fn Item(self: *const T, nDevice: u32, ppDevice: ?*?*IMMDevice) HRESULT {
|
||||
return @ptrCast(*const IMMDeviceCollection.VTable, self.vtable).Item(@ptrCast(*const IMMDeviceCollection, self), nDevice, ppDevice);
|
||||
return @as(*const IMMDeviceCollection.VTable, @ptrCast(self.vtable)).Item(@as(*const IMMDeviceCollection, @ptrCast(self)), nDevice, ppDevice);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1716,19 +1716,19 @@ pub const IMMDeviceEnumerator = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IUnknown.MethodMixin(T);
|
||||
pub inline fn EnumAudioEndpoints(self: *const T, dataFlow: DataFlow, dwStateMask: u32, ppDevices: ?*?*IMMDeviceCollection) HRESULT {
|
||||
return @ptrCast(*const IMMDeviceEnumerator.VTable, self.vtable).EnumAudioEndpoints(@ptrCast(*const IMMDeviceEnumerator, self), dataFlow, dwStateMask, ppDevices);
|
||||
return @as(*const IMMDeviceEnumerator.VTable, @ptrCast(self.vtable)).EnumAudioEndpoints(@as(*const IMMDeviceEnumerator, @ptrCast(self)), dataFlow, dwStateMask, ppDevices);
|
||||
}
|
||||
pub inline fn GetDefaultAudioEndpoint(self: *const T, dataFlow: DataFlow, role: Role, ppEndpoint: ?*?*IMMDevice) HRESULT {
|
||||
return @ptrCast(*const IMMDeviceEnumerator.VTable, self.vtable).GetDefaultAudioEndpoint(@ptrCast(*const IMMDeviceEnumerator, self), dataFlow, role, ppEndpoint);
|
||||
return @as(*const IMMDeviceEnumerator.VTable, @ptrCast(self.vtable)).GetDefaultAudioEndpoint(@as(*const IMMDeviceEnumerator, @ptrCast(self)), dataFlow, role, ppEndpoint);
|
||||
}
|
||||
pub inline fn GetDevice(self: *const T, pwstrId: ?[*:0]const u16, ppDevice: ?*?*IMMDevice) HRESULT {
|
||||
return @ptrCast(*const IMMDeviceEnumerator.VTable, self.vtable).GetDevice(@ptrCast(*const IMMDeviceEnumerator, self), pwstrId, ppDevice);
|
||||
return @as(*const IMMDeviceEnumerator.VTable, @ptrCast(self.vtable)).GetDevice(@as(*const IMMDeviceEnumerator, @ptrCast(self)), pwstrId, ppDevice);
|
||||
}
|
||||
pub inline fn RegisterEndpointNotificationCallback(self: *const T, pClient: ?*IMMNotificationClient) HRESULT {
|
||||
return @ptrCast(*const IMMDeviceEnumerator.VTable, self.vtable).RegisterEndpointNotificationCallback(@ptrCast(*const IMMDeviceEnumerator, self), pClient);
|
||||
return @as(*const IMMDeviceEnumerator.VTable, @ptrCast(self.vtable)).RegisterEndpointNotificationCallback(@as(*const IMMDeviceEnumerator, @ptrCast(self)), pClient);
|
||||
}
|
||||
pub inline fn UnregisterEndpointNotificationCallback(self: *const T, pClient: ?*IMMNotificationClient) HRESULT {
|
||||
return @ptrCast(*const IMMDeviceEnumerator.VTable, self.vtable).UnregisterEndpointNotificationCallback(@ptrCast(*const IMMDeviceEnumerator, self), pClient);
|
||||
return @as(*const IMMDeviceEnumerator.VTable, @ptrCast(self.vtable)).UnregisterEndpointNotificationCallback(@as(*const IMMDeviceEnumerator, @ptrCast(self)), pClient);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1748,7 +1748,7 @@ pub const IMMEndpoint = extern struct {
|
|||
return struct {
|
||||
pub usingnamespace IUnknown.MethodMixin(T);
|
||||
pub inline fn GetDataFlow(self: *const T, pDataFlow: ?*DataFlow) HRESULT {
|
||||
return @ptrCast(*const IMMEndpoint.VTable, self.vtable).GetDataFlow(@ptrCast(*const IMMEndpoint, self), pDataFlow);
|
||||
return @as(*const IMMEndpoint.VTable, @ptrCast(self.vtable)).GetDataFlow(@as(*const IMMEndpoint, @ptrCast(self)), pDataFlow);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ pub const Player = struct {
|
|||
}
|
||||
|
||||
fn resumeOnClick(args: js.Object, _: usize, captures: []js.Value) js.Value {
|
||||
const self = @ptrFromInt(*Player, @intFromFloat(usize, captures[0].view(.num)));
|
||||
const self = @as(*Player, @ptrFromInt(@as(usize, @intFromFloat(captures[0].view(.num)))));
|
||||
self.play() catch {};
|
||||
|
||||
const document = js.global().get("document").view(.object);
|
||||
|
|
@ -177,7 +177,7 @@ pub const Player = struct {
|
|||
}
|
||||
|
||||
fn audioProcessEvent(args: js.Object, _: usize, captures: []js.Value) js.Value {
|
||||
const self = @ptrFromInt(*Player, @intFromFloat(usize, captures[0].view(.num)));
|
||||
const self = @as(*Player, @ptrFromInt(@as(usize, @intFromFloat(captures[0].view(.num)))));
|
||||
|
||||
const event = args.getIndex(0).view(.object);
|
||||
defer event.deinit();
|
||||
|
|
@ -219,7 +219,7 @@ pub const Player = struct {
|
|||
pub fn volume(self: Player) !f32 {
|
||||
const gain = self.gain_node.get("gain").view(.object);
|
||||
defer gain.deinit();
|
||||
return @floatCast(f32, gain.get("value").view(.num));
|
||||
return @as(f32, @floatCast(gain.get("value").view(.num)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue