Audio: initial interface #394
Labels
No labels
CI
all
basisu
blog
bug
build
contributor-friendly
core
correctness
deferred
dev
direct3d-headers
docs
driver-os-issue
duplicate
dxcompiler
editor
examples
experiment
feature-idea
feedback
flac
freetype
gamemode
gkurve
glfw
gpu
gpu-dawn
harfbuzz
help welcome
in-progress
infrastructure
invalid
libmach
linux-audio-headers
long-term
mach
mach.gfx
mach.math
mach.physics
mach.testing
model3d
needs-triage
object
opengl-headers
opus
os/linux
os/macos
os/wasm
os/windows
package-manager
priority
proposal
proposal-accepted
question
roadmap
slipped
stability
sysaudio
sysgpu
sysjs
validating-fix
vulkan-zig-generated
wayland-headers
website
wontfix
wrench
www
x11-headers
xcode-frameworks
zig-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
hexops/mach!394
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -0,0 +1,140 @@const std = @import("std");This is a bad idea. This should be strictly kept inside soundio.zig's Device struct
@ -0,0 +1,159 @@const std = @import("std");Naming is incorrect. These are not device but actually streams
Why are we storing so much information with id. DeviceDescriptor already has is_raw and mode fields.
Lets not store it, we should get the device only in
requestDeviceas mentioned above.Lets not forget to mention that this PR depends on https://github.com/slimsag/libsoundio/pull/2 and also https://github.com/hexops/soundio needs to be updated accordingly.
I think the purpose of Descriptor should be just to be able to store all the necessary information about a device which we can use to initialize it. It should not store the device handle itself. That would be a bad design. We already have
soundio.get(*)DeviceFromIDwhich just needs Descriptor.id and Descriptor.is_raw.@ -0,0 +1,159 @@const std = @import("std");if user save
idsomewhere and try to use it again there may be more devices.also has cross-platform reasons. there might be no
is_rawfield in Web and Android backends so user get confused why he got error in desktop platform but not in other platforms@ -0,0 +1,140 @@const std = @import("std");in fact there's no need to move it into somewhere else
i was also doubt to keep it, just waited for reviews
@ -0,0 +1,159 @@const std = @import("std");so if
internalandparseIDget removed, which is correct strategy?InvalidParamserror, ifidexist butmodeandis_rawwas nullidexist butmodeandis_rawwas null@ -0,0 +1,159 @@const std = @import("std");I think we had discussed that we may want to allow device creation just from id, and if I understand it correctly id doesn't have enough information to uniquely identify the devices. So that does justifies what you did above. But it has its problems.
The id held by soundio we actually get it from the internal audio server itself, so if we made id a custom format, it would be difficult to use the id in future non-soundio native backends.
We can in theory make the id format a standard which all backends must adhere to but it has the drawback that id would have to be allocated. Alternatively we can just not allow creating device solely from id but require the complete descriptor. cc: @slimsag
@ -0,0 +1,159 @@const std = @import("std");I'm not worried about this. In my view, ID should be clearly marked as "a string of garbage only this backend understands" - nobody except that backend should try to interpret it, and there could be changes to the backend (like if we ever move away from soundio) that invalidate those IDs. It's safe to store it in a file and get the device from that ID, but only using the same backend - and not if the backend changes in the future.
@ -0,0 +1,140 @@const std = @import("std");It's a bummer we need to free each ID, though, I don't like that much
@ -0,0 +1,140 @@const std = @import("std");relax. this happens once game load
@ -0,0 +1,140 @@const std = @import("std");How do you know the user would do it only once? Well you cant say it surely.
@ -0,0 +1,140 @@const std = @import("std");it's user fault and beyond of our control. user can save to an array and use it where needed
at least in
mach/src/audiowe surely do it once@ -0,0 +1,140 @@const std = @import("std");User cannot really store it since devices may change as the program is running, which is triggered by
flushEvents()in my understanding@ -0,0 +1,140 @@const std = @import("std");hmm right. but this seems the only way to keep id standalone. im almost ok with making it user job to save
is_rawandmodeby itself but it seems other backends provide a unique id.will be ready once this merged: https://github.com/hexops/soundio/pull/1
LGTM! Techincally Device and DeviceIterator should not be completely opaque but we can always fix that later along with that id allocation issue.
For now lets get something going atleast.
@ -0,0 +90,4 @@var iter = a.outputDeviceIterator();var device_desc = (try iter.next()) orelse return error.NoDeviceFound;const d = try a.requestDevice(device_desc);My thinking (let's chat about this in Matrix):
We should create a new descriptor here, passing just
.{.id = device_desc.id, .mode = .output}torequestDevice. Otherwise we're not sure if we are testing it looking up device by ID or by full descriptor info.Additionally, we should create another test which verifies what happens when the ID doesn't match any known device. My thinking here is that if you pass
.{.id = "does-not-match-any-existing-device-id", .mode = .output}for a reason like:Then
requestDevicecould see clearly that the device with that ID no longer exists, and instead give you one that you would get if you just passedrequestDevice(.{.mode = .output})without the ID field.i have a lot of improvements in mind but let's do it in next PRs