Commit Graph

566 Commits

Author SHA1 Message Date
Bill Currie 94db9c8ab1 [quakefs] Add a data parameter to gamedir callbacks
While this didn't fix the problem for which I needed the data pointer,
having data pointers in callbacks is far too useful to throw out the
change.
2022-06-04 16:06:04 +09:00
Bill Currie 18c64f7319 [sound] Fix some spelling errors in the mixer
Triple has only one p, not two :/
2022-06-04 12:28:16 +09:00
Bill Currie 5fd9098e05 [sound] Remove the next pointer and entity channel from channel_t
This is part of a process to shrink channel_t so it doesn't waste locked
memory when it gets moved there. Eventually, only the fields the mixer
needs will be in channel_t itself: those needed for spacialization will
be moved into a separate array.

In the process, I found that channels leak across level changes, but
this appears to be due to the cached sounds being removed during loading
and the mixer never marking them as done (it sees the null sfx pointer
and assumes the channel was never in use). Having the mixer mark the
channel as done seems to fix the leak, but cause a free channel list
overflow. Rather than fight with that, I'll leave the leak for now and
fix it at its root cause: the management of the sound samples
themselves.
2022-06-04 12:28:16 +09:00
Bill Currie cbc5654b5e [sound] Initialize snd_alive_time on connection to JACK
Sys_DoubleTime starts at 4Gs in order to keep its precision fixed for a
nice long time (about 120 years, iirc).

This fixes an instant watchdog trigger when first starting up in
testsound. I'm not sure why it didn't happen with nq, but I guess that
doesn't really matter
2022-06-03 20:01:34 +09:00
Bill Currie 56cd0f3f1d [sound] Rename sndbuffer objects from sc to sb
I don't know why I called them sc. Might be a holdover from before the
streamed sound support.
2022-06-03 19:11:25 +09:00
Bill Currie 5b38117689 [sound] Make all volumes 0-1 (float) instead of 0-255 (int)
The scaling up of the volumes when setting a channel's volume bothered
me. The biggest issue being it hasn't been necessary for over a decade
since the conversion to a float-mixer. Now the volume and attenuation
scaling from protocol bytes is entirely in the client's hands.
2022-06-03 16:54:57 +09:00
Bill Currie 1f16f875f6 [sound] Clean up the public API
sfx_t is now private, and cd_file no longer accesses channel_t's
internals. This is necessary for hiding the code needed to make mixing
and channel management *properly* lock-free (I've been getting away with
murder thanks to x86's strong memory model and just plain luck with
gcc).
2022-06-03 15:20:41 +09:00
Bill Currie e967724196 [audio] Handle multiple cue points in wav files
Sounds in Arcane Dimensions (at least those used by ad_tears) specify
start and end cue points. The code was using only the final point in the
list and thus breaking looped sounds. Now, the first cue point is used
as the loop start, and the second (if present), the sample length. Both
are bounds-checked against the wav's sample count. Fixes sound locking
up during the first seconds in ad_tears.
2022-05-22 11:59:53 +09:00
Bill Currie 5cfbafc176 [audio] Fix some minor issues
Just little niggles I spotted while sorting out cue points.
2022-05-22 11:59:53 +09:00
Bill Currie a1d8319b48 [sound] Don't free realname in the vorbis loader
Luckily, it was almost never hit (error condition), but the code doesn't
own the pointer.
2022-05-12 19:58:18 +09:00
Bill Currie bff0847761 [cvar] Clean up most misinterpreted cvar types
The misinterpretations were due to either the cvar not being accessed
directly by the engine, but via only the callback, or the cvars were
accesssed only by progs (in which case, they should be float). The
remainder are a potential enum (hud gravity) and a "too hard basket"
(rcon password: need to figure out how I want to handle secret strings).
2022-04-24 20:04:06 +09:00
Bill Currie 12c84046f3 [cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.

As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.

The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).

While not used yet (partly due to working out the design), cvars can
have a validation function.

Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.

nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-24 19:15:22 +09:00
Bill Currie 55f7886607 Remove some long dead cvars
The declarations were still around, but the creation and code using them
was removed long ago.
2022-04-24 17:23:46 +09:00
Bill Currie da42aaf423 [sound] Use vec4f_t for api functions
Fixes a few vec3_t/vec4f_t FIXMEs.
2022-03-30 23:42:38 +09:00
Bill Currie 457c73967b [sound] Correct "default" listener origin
Position vectors need to be homogeneous, I forgot that when doing the
change.
2022-03-01 01:02:11 +09:00
Bill Currie 57dd4494cc [renderer] Pass in a camera transform
More r_data cleanup. Things could be better still, but this is a start.
2022-02-28 16:59:38 +09:00
Bill Currie db8cf68ef3 [gamecode] Pass registered data pointer to builtins
This is the bulk of the work for recording the resource pointer with
with builtin data. I don't know how much of a difference it makes for
most things, but it's probably pretty big for qwaq-curses due to the
very high number of calls to the curses builtins.

Closes #26
2022-02-14 12:28:38 +09:00
Bill Currie 9c51c3d2e1 [gamecode] Add a data pointer passed to builtin functions
This is part of the work for #26 (Record resource pointer with builtin
function data). Currently, the data pointer gets as far as the
per-instance VM function table (I don't feel like tackling the job of
converting all the builtin functions tonight). All the builtin modules
that register a resources data block pass that block on to
PR_RegisterBuiltins.
2022-01-24 00:20:05 +09:00
Bill Currie a6b932025c [gamecode] Provide builtins with information about their parameters
This will make it possible for the engine to set up their parameter
pointers when running Ruamoko progs. At this stage, it doesn't matter
*too* much, except for varargs functions, because no builtin yet takes
anything larger than a float quaternion, but it will be critical when
double or long vec3 and vec4 values are passed.
2022-01-23 22:27:27 +09:00
Bill Currie 2086125e0b [quakefs] Take in the pointer to the global hunk
This is needed for cleaning up excess memsets when loading files because
Hunk_RawAllocName has nonnull on its hunk pointer (as the rest of the
hunk functions really should, but not just yet).
2021-12-24 06:45:13 +09:00
Bill Currie 6db6f8f0e2 [win] Fix a pile of bitrot
Man, those bits rot quickly. Must be stored with a rotfish.
2021-07-11 13:30:52 +09:00
Bill Currie d9e7730d91 [audio] Add a cvar for jack port names
Fixes #2
2021-06-29 20:03:13 +09:00
Bill Currie f8ffb12713 [audio] Clean up jack and alsa dependencies
I had forgotten to test with shared libs and it turns out jack and alsa
were directly accessing symbols in the renderer (and in jack's case,
linking in a duplicate of the renderer).

Fixes #16.
2021-06-27 01:57:59 +09:00
Bill Currie 0be609e0fd [util] Make PI_LoadPlugin always call general init function
As the root cause for #16 was something else, this fixes only the basic
cvar initialization, but does fix #19 (for now, at least).
2021-06-26 16:18:05 +09:00
Bill Currie a66e6ad262 [sudio] Fix the SDL audio target
I forgot about SDL in my testing for #16. I do still need to fix the
windows targets.
2021-06-26 14:25:02 +09:00
Bill Currie 53a7fbfe95 [audio] Move jack from renderer to targets
The JACK Audio Connection Kit support is now just an output target
rather than a full duplicate of the renderer (in pull mode). This is
what I wanted to to back when I first added jack support, but I needed
to get the renderer working asynchronously without affecting any of the
other outputs.

Fixes #16.
2021-06-25 18:32:48 +09:00
Bill Currie a1a89bdb7e [audio] Clean up a few minor style issues 2021-06-25 16:52:09 +09:00
Bill Currie 580464d6be [audio] Disable extra update for pull targets
This fixes a segfault that snuck in due to testsound not using
S_ExgraUpdate.
2021-06-25 14:24:24 +09:00
Bill Currie 02ff875cd6 [audio] Add optional on_update output function
on_update is for pull-model outpput targets to do periodic synchronous
checks (eg, checking that the connection to the actual output device is
still alive and reviving it if necessary)
2021-06-25 13:52:50 +09:00
Bill Currie db7e99d842 [audio] Allow output plugins to specify model
Output plugins can use either a push model (synchronous) or a pull
model (asynchronous). The ALSA plugin now uses the pull model. This
paves the way for making jack output a simple output plugin rather than
the combined render/output plugin it currently is (for #16) as now
snd_dma works with both models.
2021-06-25 11:41:42 +09:00
Bill Currie 79825db539 [audio] Clean up alsa init and add error checking
This gets the alsa target working nicely for mmapped outout. I'm not
certain, but I think it will even deal with NPOT buffer sizes (I copied
the code from libasound's sample pcm.c, thus the uncertainty).
Non-mmapped output isn't supported yet, but the alsa target now works
nicely for pull rendering.

However, some work still needs to be done for recovery failure: either
disable the sound system, or restart the driver entirely (preferable).
2021-06-25 09:50:31 +09:00
Bill Currie 54bc7a83ba [audio] Fix missed compile issues
Due to not having wildmidi on my eeepc.
2021-06-24 00:14:33 +09:00
Bill Currie fc907e232f [audio] Rework alsa to use a pull model
This brings the alsa driver in line with the jack render (progress
towards #16), but breaks most of the other drivers (for now: one step at
a time). The idea is that once the pull model is working for at least
one other target, the jack renderer can become just another target like
it should have been in the first place (but I needed to get the pull
model working first, then forgot about it).

Correct state checking is not done yet, but testsound does produce what
seems to be fairly good sound when it starts up correctly (part of the
state checking (or lack thereof), I imagine).
2021-06-24 00:08:05 +09:00
Bill Currie c9319966ce [plugin] Clean up the rest of the plugin structs 2021-06-22 19:47:20 +09:00
Bill Currie db322ce88b [audio] Clean up snd_render.h namespace polution
There's no need for the function typedefs and the warts on the member
names were... warty.

Also, group the members logically.
2021-06-22 16:38:17 +09:00
Bill Currie 421421e038 [audio] Correct alsa period size calculation
and rename the variable since it's not the size of the frame (may be
from the very early days of ALSA development, and I suspect the
terminology changed a bit).

The calculation was including the bits per sample, which makes no sense
as the period size determines the number of samples in a submission
chunk (and thus latency). For now, set it to around 5.5ms (will probably
need a cvar).
2021-06-22 16:38:17 +09:00
Bill Currie 770187372d [audio] Get testsound working again 2021-06-21 16:40:40 +09:00
Bill Currie 81a837da0f [win] Clean up a pile of messy externs 2021-03-31 10:36:30 +09:00
Bill Currie 5f93c115ff [util] Make developer flag names easier to manage
They're now an enum, and the flag part of the name is all lowercase, but
now the flag definitions and names list will never get out of sync.
2021-03-29 22:38:47 +09:00
Bill Currie 88ff254f42 Get QF cross-compiling using MXE/mingw32
This includes -win clients (no clue if anything actually works yet).
2021-03-27 20:09:37 +09:00
Bill Currie a0d47de439 [vulkan] Suppress all the debug output
silence is golden
2021-03-23 13:04:22 +09:00
Bill Currie cc4167668c Fix a pile of leaks and uninit errors
Still "some" more to go: a pile to do with transforms and temporary
entities, and a nasty one with host_cbuf. There's also all the static
block-alloc lists :/
2021-03-21 19:56:17 +09:00
Bill Currie a3c1b2e992 [util] Rename qfplist.[ch]
The name is a hold-over from before the current quakeforge tree and the
QF include directory.
2021-03-21 16:13:03 +09:00
Bill Currie dfa7af03c6 [util] Plug a thread-safety hole in plists 2021-02-09 09:57:07 +09:00
Bill Currie 0bfb60775e [util] Ensure hunk allocs are cache alligned
This doesn't seem to make much difference in the vulkan renderer, but it
certainly doesn't hurt.
2021-02-03 13:19:19 +09:00
Bill Currie 7970525ef4 [util] Make va thread-safe
It now takes a context pointer (opaque data) that holds the buffers it
uses for the temporary strings. If the context pointer is null, a static
context is used (making those uses of va NOT thread-safe). Most calls to
va use the static context, but all such calls have been formatted
consistently so they are easy to find when it comes time to do a full
audit.
2021-01-31 16:05:48 +09:00
Bill Currie 86b5b30b45 Merge branch 'master' into vulkan 2020-06-25 14:03:52 +09:00
Bill Currie 6d5ffa9f8e [build] Move to non-recursive make
There's still some cleanup to do, but everything seems to be working
nicely: `make -j` works, `make distcheck` passes. There is probably
plenty of bitrot in the package directories (RPM, debian), though.

The vc project files have been removed since those versions are way out
of date and quakeforge is pretty much dependent on gcc now anyway.

Most of the old Makefile.am files  are now Makemodule.am.  This should
allow for new Makefile.am files that allow local building (to be added
on an as-needed bases).  The current remaining Makefile.am files are for
standalone sub-projects.a

The installable bins are currently built in the top-level build
directory. This may change if the clutter gets to be too much.

While this does make a noticeable difference in build times, the main
reason for the switch was to take care of the growing dependency issues:
now it's possible to build tools for code generation (eg, using qfcc and
ruamoko programs for code-gen).
2020-06-25 11:35:37 +09:00
Bill Currie 4cef9792f4 [util] Make hash-tables semi-thread-safe
They take a pointer to a free-list used for hashlinks so the hashlink
pools can be per-thread. However, hash tables that are not updated are
always thread-safe, so this affects only updates. progs_t has been set
up such that it is easy for multiple progs within one thread can share
hashlinks.
2020-03-25 15:43:16 +09:00
Bill Currie d0c8d75e92 Clean up unnecessary includes of signal.h 2020-03-23 16:18:08 +09:00