The filter_audio API is not working for qTox/Tox and thus disabled by default via compiler switch. In current qTox UI, it is not configurable, even when this switch is enabled. According to issue #3194 the library is no longer maintained as well. I don't see any reason to keep it in qTox.
We now subscribe to an event and wait for frames when capturing audio
input, the big avdantage is that we only have to fetch the frames from
the hardware once, and we don't need to cache anything.
The frames are simply dispatched to the client's callbacks immediately.
Also removes some outdated ifdefs that did not apply anymore.
qTox will automatically import the old history on startup.
This new database code is much more robust.
It is very resilient and will not corrupt or disappear after a crash or
power failure, unlike the old code.
The on-disk database format is also much more compact now.
The database sync option in the advanced settings has been removed,
we know run many database operations asynchronously so performance
should not be a problem anymore, but we always ensure resiliency
in case of abrupt termination, so there is no tradeoff anymore.
Double the allowed bitrate, this is especially noticeable on desktop streaming. Desktop streaming is still completely broken, with what looks like iframes silently getting dropped on a regular basis.
Retry 5 times to send a frame when there's an internal toxav lock sync error, this allows us to drop way less frames.
For some users on poor connections, toxav would suggest lower and lower bitratres until reaching zero and disabling audio/video entirely, toxav would then not raise the bitrate back and the only way to re-enable audio/video would have been to change A/V sources or restart the call
We now log toxav's recommendation, but ignore it
Could only be hit by pausing at a key point in a debugger until the call timed-out.
Having one thread going up the call stack and acquiring locks (toxcore callbacks), while another thread goes down taking locks in the other order (CoreAV calling toxav functions) creates some pretty freezy situations.
The deadlock was caused by the GUI thread calling the CoreAV thread, acquiring the CoreAV callback, then right before calling a toxav function, not schedule the thread until the call times out. At this point the toxcore thread fires its state callback to tell us the call is over, locking internal toxcore/toxav mutexes, it reaches our callback function which tries to switch to the CoreAV thread to clean up the call data structures, but has to wait since the CoreAV thread holds its own lock. At this point if we resume the CoreAV thread, it'll be busy calling into a toxav function, which tries to acquire internal toxav locks, those locks are held by the toxcore callback so we deadlock.
Our solution is that when getting a toxcore callback, we immediately switch to a temporary thread, allowing toxcore to release the locks it held, and that temporary thread tries to switch to do work on call data structures. Meanwhile if the CoreAV thread needs internal toxcore locks, it can get them.
A call cancel/accepted race was locking up both UI and AV threads, while the stream thread was shoveling more and more video frames on the AV thread's event queue
This error condition only happens when a peer cancels its outgoing call in the middle of us answering it. We can simply ignore the error and things should nicely fall back into place. Since this race should be pretty rare in normal usage, it's nice to leave a log message, as it might mean we're being fuzzed.
We can prograssively replace more of those asserts by fallbacks and log messages now that everything has been shown to work fine, and the race conditions are harmless.
I feel like writing a novel today. Good thing nobody looks at these!
And properly handle toxav happily delivering things out of order,
like firing a video frame callback right after a callback setting the bitrate to 0,
when the peer sent these commands in the right order
A race condition would result in trying to remove an element that didn't exist, and thus erasing end (undefined behavior) instead of erasing [end, end) (no-op)
That pull request made qTox crash in a number of ways, with no quick fix
available.
Hopefully there will be a way to fix crash, so that this commit could be
reverted, and fix applied.
And make it saner by not having one global password that has to be set before encrypting/decrypting, which is as racy and poorly designed as it gets
Fixes#1917 's immediate symtoms, which some potential for other regressions due to the mess that is encrypted persistence currently
There can now only be one CameraSource running.
Video frames are decoded in their own thread, and then converted by users in the user's threads.
The CameraSource API is entirely thread-safe and controls the video decoding thread.
The video device only stays open as long as there are users subscribed to the CameraSource.
We use a dangerous combination of spinlocks and memory fences to keep things synchronized.