Commit graph

383 commits

Author SHA1 Message Date
sergystepanov
1e4e5b3c65 Clean media buffer 2025-12-14 22:15:28 +03:00
sergystepanov
7c8e74716d Disable mGBA low-pass filter 2025-12-14 22:14:55 +03:00
sergystepanov
46a5799079 Fix media tests 2025-12-14 18:54:06 +03:00
sergystepanov
9feb788108 Make speexdsp statically linked 2025-12-14 17:01:04 +03:00
sergystepanov
9d54ea4c49 Add and use Speex audio resampler 2025-12-14 16:24:35 +03:00
sergystepanov
671e875f12 Add input cache for retropad, keyboard and mouse 2025-12-14 13:53:21 +03:00
sergystepanov
f708fce112 Revert "Try atomic-based locks in the same thread execution loop instead of a bunch of mutexes."
This reverts commit 460c466053.
2025-12-14 13:30:45 +03:00
sergystepanov
460c466053 Try atomic-based locks in the same thread execution loop instead of a bunch of mutexes. 2025-12-14 13:18:34 +03:00
sergystepanov
84ad0a4cac Add audio resampling option
You can now select between linear interpolation and nearest-neighbor resampling algorithms.
2025-12-13 23:56:38 +03:00
sergystepanov
129690e901 Fix map test 2025-11-22 22:21:05 +03:00
sergystepanov
9191861cab Use iterators in the custom map implementation 2025-11-22 22:09:38 +03:00
sergystepanov
c05e42f597 Cleanup nanoarch.go 2025-11-22 21:20:16 +03:00
sergystepanov
09a0c9c3f2 Revert "Add user input caching"
This reverts commit 859d0c8f1a.
2025-11-22 17:46:07 +03:00
sergystepanov
859d0c8f1a Add user input caching 2025-11-22 17:22:40 +03:00
sergystepanov
baaeaf43b1 Add config option for logging dropped frames 2025-11-22 12:32:56 +03:00
sergystepanov
76b376aef7 Add config option for skipping late video frames 2025-11-22 11:59:08 +03:00
sergystepanov
3df6a24a0a Skip video frames when they are late 2025-11-21 22:35:33 +03:00
sergystepanov
5c6406c1e7 Implemented a busy loop for the emulation ticker.
This replaces the low-precision, OS-dependent time ticker with a CPU spin loop that performs continuous target frame time checks and corrections.
2025-11-21 20:13:27 +03:00
sergystepanov
bbad4539b1 Update libretro.h 2025-11-20 00:33:03 +03:00
sergystepanov
42b003db62 Verifies during startup if the system can run the emulator
This check can be disabled with the emulator.failFast = false config option. Right now it checks SDL2 video context creation.
2025-06-20 18:30:17 +03:00
sergystepanov
02210f1f8d Remove unnecessary C bridge functions 2025-05-18 12:46:32 +03:00
sergystepanov
36da07f277 Use the actual state size when loading ROMs 2025-05-03 16:35:21 +03:00
sergystepanov
37a4a80996 Use the save state size before each save/load call 2025-05-03 15:55:26 +03:00
sergystepanov
9d4256306e Add missing C function header for Go debugger 2025-05-02 10:34:22 +03:00
sergystepanov
ddfc9249ec Fix some user slot race conditions
In cases where HasSlot() and Reserve() operations are delayed, multiple users may incorrectly be granted a slot due to race conditions.
2025-05-02 10:06:23 +03:00
sergystepanov
3ac7a559df Skip YUV test
It is broken on Windows
2025-04-17 09:11:26 +03:00
Sergey Stepanov
0c768bb3d6
Add some notes on recording in regards to ffconcat 2024-12-21 01:37:42 +03:00
Sergey Stepanov
f78bcf3e4b
Allow config for the remote Libretro core repos 2024-12-20 01:32:20 +03:00
Sergey Stepanov
535e725618
Panic when dlib functions are missing 2024-12-19 21:40:14 +03:00
Sergey Stepanov
4aaeda3fbb
Move some RETRO_ENVIRONMENT vars into C 2024-12-16 23:28:14 +03:00
Sergey Stepanov
89ae98b035 Why do we need samples
In an ideal scenario, the emulator generates a video frame and an audio chunk with its internal frame rate. For example, if the emulator runs a game at 60 FPS, it will produce 16 ms worth of audio and a video frame with each tick (or call of the run function). Then we need to send all this data to the user's browser, which becomes tricky with WebRTC audio.

The WebRTC standard supports only Opus-encoded audio for high-quality sound. The encoder and decoder (the audio player in the browser) have a limitation: they can only operate on fixed audio frames or predefined chunks of audio, which are 5, 10, 20, 40, or 60 ms in length.

Due to this limitation, we have to wait at least two ticks until the first whole audio chunk can be packed into predefined frames. If we have 16 ms of audio and one fixed buffer, we send 10 ms right away and have to wait for 4 ms to add to the remaining 6 ms. This will lead to a constant 6 ms delay between audio and video.

To mitigate this issue, we can set the smallest frame size as a buffer, i.e., 5 ms. This will decrease the latency to 1 ms, but we will send 3 packets of data in this manner for 16 ms.

A slightly better way is to create several buffers and dynamically select the next buffer so that the audio fits optimally, minimizing the number of network packets sent to users.

This frames thing essentially accomplishes that. In the options, we can select multiple (or one) Opus buffers to store audio and choose from. They should be defined from the largest to the smallest. And that's it.
2024-12-13 18:57:25 +03:00
sergystepanov
ed3b195b26
Dynamic audio buf
* Ugly audio buf

* Use dynamic Opus frames with config
2024-12-12 21:13:43 +03:00
Sergey Stepanov
f54089e072
Stretch samples a bit better with the GBA's 32768Hz 2024-12-07 00:47:27 +03:00
Sergey Stepanov
6bb82b2204 Allow 2.5ms Opus frame 2024-12-06 15:27:18 +03:00
Sergey Stepanov
d77d69a331 Remove pool from the audio stretcher 2024-12-05 13:50:39 +03:00
Sergey Stepanov
5649d4410a
Remove pools from YUV conv 2024-12-05 01:11:02 +03:00
Sergey Stepanov
db32479c4e
Destroy rooms when the coordinator was lost 2024-12-05 01:10:16 +03:00
Sergey Stepanov
a7acebc5d0
Try YUV without the mem pool 2024-12-04 22:09:51 +03:00
Sergey Stepanov
954bb23bb8
Add Reset with 0 key 2024-12-03 00:38:15 +03:00
Sergey Stepanov
7134782245
Enable frame duplication for Mupen64 2024-12-03 00:34:43 +03:00
Sergey Stepanov
5a42dc9857
Fail x2 on no coordinator connection 2024-12-01 20:26:29 +03:00
Sergey Stepanov
9caf45af78
Reset fail timer on success 2024-12-01 18:20:54 +03:00
Sergey Stepanov
b2e275a6cd
Don't crash the app on http2 garbage 2024-11-28 23:24:35 +03:00
Sergey Stepanov
45dba68b15
Faster CopyFile 2024-11-28 21:16:31 +03:00
Sergey Stepanov
1831e44eef Add new saveStateFs config param
Used when you need a copy of FS for new game sessions (i.e. DOSBox uniqueSaveDir=true).
2024-11-26 19:35:31 +03:00
Sergey Stepanov
88a0911f93
Avoid segfault with nil error handlers in ws 2024-11-17 22:27:34 +03:00
Sergey Stepanov
8686c4a6e5
Return workers by wids right away ;_; 2024-11-17 22:13:39 +03:00
Sergey Stepanov
2c50ae2290
Allow one game per a direct worker 2024-11-17 20:29:45 +03:00
Sergey Stepanov
f09500f289
Check slots for direct workers 2024-11-17 19:55:14 +03:00
Sergey Stepanov
1147aeda14 Track all worker saves to resume old games
Move library config to the top level
2024-11-17 12:59:43 +03:00