libTAS icon indicating copy to clipboard operation
libTAS copied to clipboard

Support for the Cubeb audio library?

Open thegamingrestoration opened this issue 4 years ago • 2 comments

More and more I see emulators using Cubeb, a cross-platform and low-latency audio library that Mozilla created back in 2017 for the Firefox browser. The library is capable of using various backends like Pulse, Alsa, Jack and Sndio; so I made a quick test with libTAS and the Yuzu emulator. I disabled Pulseaudio so that Cubeb would use ALSA instead, but unfortunately libTAS didn't recognize the audio library:

Video support: SDL 2 (OpenGL 4.3 Core profile) Audio support: unknown Keyboard support: yes (SDL 2) Mouse support: yes (SDL 2) Joystick support: yes (SDL 2)

And after a few seconds the emulator crashed (it works perfectly outside of libTAS, or with the audio disabled). Here's the log:

Attempt 1: Connected.
[libTAS f:0] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:0] Thread 1031 (main) Init audio player
[libTAS f:0] Thread 1031 (main)   Buffer size is 1600
[libTAS f:0] Thread 1031 (main)   new buffer size is 1600
[libTAS f:0] Thread 1031 (main) Play an audio frame
[libTAS f:1] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:1] Thread 1031 (main) Play an audio frame
[libTAS f:2] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:2] Thread 1031 (main) Play an audio frame
[libTAS f:3] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:3] Thread 1031 (main) Play an audio frame
(...)
[libTAS f:177] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:177] Thread 1031 (main) Play an audio frame
[libTAS f:178] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:178] Thread 1031 (main) Play an audio frame
[libTAS f:179] Thread 1031 (main) OpenGL vendor: NVIDIA Corporation
[libTAS f:179] Thread 1031 (main) OpenGL renderer: GeForce GT 1030/PCIe/SSE2
[libTAS f:179] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:179] Thread 1031 (main) Play an audio frame
[libTAS f:179] Thread 1031 (main)   Underrun
[libTAS f:180] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:180] Thread 1031 (main) Play an audio frame
[libTAS f:181] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:181] Thread 1031 (main) Play an audio frame
[libTAS f:182] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:182] Thread 1031 (main) Play an audio frame
[libTAS f:183] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:183] Thread 1031 (main) Play an audio frame
[libTAS f:184] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:184] Thread 1031 (main) Play an audio frame
[libTAS f:185] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:185] Thread 1031 (main) Play an audio frame
[libTAS f:186] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:186] Thread 1031 (main) Play an audio frame
[libTAS f:187] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:187] Thread 1031 (main) Play an audio frame
[libTAS f:188] Thread 1031 (main) Start mixing about 800 samples
[libTAS f:188] Thread 1040        Switching main thread from 140737328508416 to 140732642223872
[libTAS f:188] Thread 1031 (main) Play an audio frame
[libTAS f:189] Thread 1040 (main) Start mixing about 800 samples
[libTAS f:189] Thread 1040 (main) Play an audio frame
(...)
[libTAS f:470] Thread 1040 (main) Start mixing about 800 samples
[libTAS f:470] Thread 1040 (main) Play an audio frame
[libTAS f:471] Thread 1040 (main) Start mixing about 800 samples
[libTAS f:471] Thread 1040 (main) Play an audio frame
[libTAS f:472] Thread 1039        snd_pcm_open call.
[libTAS f:472] Thread 1039        snd_pcm_close call.
[libTAS f:472] Thread 1039        snd_pcm_open call.
[libTAS f:472] Thread 1039        snd_pcm_nonblock call with nonblock mode
dynarmic: POSIX SigHandler: Exception was not in registered code blocks (rip 0x007ffff73cb0a0)
Got unknown message!!!

Is it possible to add support for Cubeb on libTAS?

thegamingrestoration avatar Aug 17 '20 12:08 thegamingrestoration

Which version of libTAS did you test? It is working for me but I may have fix it recently:

[libTAS f:180] Thread 7860  snd_pcm_open call.
[libTAS f:180] Thread 7860  snd_pcm_close call.
[libTAS f:180] Thread 7860  snd_pcm_open call.
[libTAS f:180] Thread 7860  snd_pcm_nonblock call with nonblock mode
[libTAS f:180] Thread 7860  snd_pcm_set_params call.
[libTAS f:180] Thread 7860  snd_pcm_get_params call.
[libTAS f:180] Thread 7860  snd_pcm_frames_to_bytes called with frames 3840
[libTAS f:180] Thread 7860  snd_pcm_poll_descriptors_count call.
[libTAS f:180] Thread 7860  snd_pcm_poll_descriptors call.
[libTAS f:180] Thread 7860  snd_pcm_pause call.
[libTAS f:180] Thread 7865  snd_pcm_wait called with timeout 1000
[libTAS f:180] Thread 7865  snd_pcm_poll_descriptors_revents call.
[libTAS f:180] Thread 7865  snd_pcm_avail_update call.
[libTAS f:180] Thread 7865     return 1920
[libTAS f:180] Thread 7865  snd_pcm_frames_to_bytes called with frames 0
[libTAS f:180] Thread 7865  snd_pcm_writei call with 1920 frames and pcm 0x1
[libTAS f:180] Thread 7865  snd_pcm_frames_to_bytes called with frames 1920
[libTAS f:180] Thread 7865  snd_pcm_frames_to_bytes called with frames 0
[libTAS f:180] Thread 7865  snd_pcm_wait called with timeout 1000

Anyway, I can add support for cubeb as well.

clementgallet avatar Sep 29 '20 09:09 clementgallet

I added support in 2229f8d99bc02e6abff217a624dcf55425f58a5a, but it seems that cubeb is integrated into Yuzu binary, so libTAS cannot hook into it.

clementgallet avatar Nov 20 '20 10:11 clementgallet