Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play bootSound.btsnd while shaders/pipelines are compiling #1047

Merged
merged 43 commits into from
Dec 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a7a116a
proof of concept
goeiecool9999 Dec 17, 2023
9354db6
fix bugs and clean up
goeiecool9999 Dec 17, 2023
312ecbc
attempt to implement looping
goeiecool9999 Dec 17, 2023
04ed1c4
simplify deinit
goeiecool9999 Dec 17, 2023
363fe59
add some more error handling, whitespace in cmake file
goeiecool9999 Dec 17, 2023
dc127e5
fix mistake while refactoring Settings code
goeiecool9999 Dec 17, 2023
cab8a1f
add config option to enable/disable boot sound, don't play during OSS…
goeiecool9999 Dec 17, 2023
5033318
move audio playback code to a more reasonable place
goeiecool9999 Dec 17, 2023
57ee241
fix indentation mistake
goeiecool9999 Dec 17, 2023
c8b4e48
fix loop
goeiecool9999 Dec 17, 2023
49b28c1
adjust assert
goeiecool9999 Dec 17, 2023
9c2b8a0
fix sm3dw loop point
goeiecool9999 Dec 17, 2023
4ac7cb9
make globals static
goeiecool9999 Dec 17, 2023
91c5a01
stuttering observed, move to jthread
goeiecool9999 Dec 17, 2023
adc988e
fix macOS build (?)
goeiecool9999 Dec 17, 2023
4468e7a
substitute jthread for thread
goeiecool9999 Dec 17, 2023
da9c3c8
Fix no audio on zero latency bug. make Xaudio consistent with other APIs
goeiecool9999 Dec 23, 2023
2223860
fix encoding error present since the repo was opened
goeiecool9999 Dec 23, 2023
2cd6dbd
Merge branch 'main' into loadaudio
goeiecool9999 Jan 15, 2024
a5aba28
disable by default
goeiecool9999 Jan 15, 2024
a143556
name the magic values
goeiecool9999 Jan 15, 2024
e0f5a9f
Merge branch 'main' into loadaudio
goeiecool9999 Jan 22, 2024
f1d4c39
more explicit and sensible error handling
goeiecool9999 Feb 12, 2024
f928eee
add log message to indicate file open failed
goeiecool9999 Feb 12, 2024
f633113
Merge branch 'main' into loadaudio
goeiecool9999 Mar 18, 2024
925e853
Merge branch 'main' into loadaudio
goeiecool9999 Mar 28, 2024
09f32d0
Merge branch 'main' into loadaudio
goeiecool9999 Apr 3, 2024
da3144a
Merge branch 'refs/heads/main' into loadaudio
goeiecool9999 May 14, 2024
c796527
don't print error when file doesn't exist
goeiecool9999 May 14, 2024
ac5c44d
Merge branch 'refs/heads/main' into loadaudio
goeiecool9999 Sep 15, 2024
da8c035
fix General Settings layout
goeiecool9999 Sep 15, 2024
8ee9554
Merge branch 'refs/heads/main' into loadaudio
goeiecool9999 Oct 14, 2024
372bbd0
Merge branch 'refs/heads/main' into loadaudio
goeiecool9999 Dec 9, 2024
92721a0
Add fadeout and handle thread lifetime with class
goeiecool9999 Dec 9, 2024
aec4462
make fade out and stop separate actions
goeiecool9999 Dec 9, 2024
307e166
fade from 0dB to -100dB in 1.5 seconds
goeiecool9999 Dec 9, 2024
a8ef8b8
only increase fadeout sample counter on odd samples
goeiecool9999 Dec 9, 2024
bafaad2
don't use magic number
goeiecool9999 Dec 9, 2024
d3c0bac
adjust parameters
goeiecool9999 Dec 9, 2024
6b057ae
make variable non-member
goeiecool9999 Dec 9, 2024
4b78f35
clean up fadeout loop
goeiecool9999 Dec 9, 2024
13f3d91
Add thread name, remove forward declarations for removed functions
goeiecool9999 Dec 14, 2024
94b140f
fix edge case where sound could stop prematurely
goeiecool9999 Dec 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more explicit and sensible error handling
goeiecool9999 committed Feb 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit f1d4c399a274001d024e1720ef0f9fcb1746944b
10 changes: 9 additions & 1 deletion src/Cafe/HW/Latte/Core/LatteShaderCache.cpp
Original file line number Diff line number Diff line change
@@ -862,7 +862,15 @@ void LatteShaderCache_StreamBootSound()
while(audiothread_keeprunning)
{
while (bootSndAudioDev->NeedAdditionalBlocks())
bootSndAudioDev->FeedBlock(bootSndFileReader->getSamples());
{
sint16* data = bootSndFileReader->getSamples();
if(data == nullptr)
{
audiothread_keeprunning = false;
break;
}
bootSndAudioDev->FeedBlock(data);
}
// sleep for the duration of a single block
std::this_thread::sleep_for(std::chrono::milliseconds(samplesPerBlock / (sampleRate/ 1'000)));
}
16 changes: 13 additions & 3 deletions src/util/bootSound/BootSoundReader.cpp
Original file line number Diff line number Diff line change
@@ -3,13 +3,15 @@

BootSoundReader::BootSoundReader(FSCVirtualFile* bootsndFile, sint32 blockSize) : bootsndFile(bootsndFile), blockSize(blockSize)
{
// crash if this constructor is invoked with a blockSize that has a different number of samples per channel
cemu_assert(blockSize % (sizeof(sint16be) * 2) == 0);

fsc_setFileSeek(bootsndFile, 0);
fsc_readFile(bootsndFile, &muteBits, 4);
fsc_readFile(bootsndFile, &loopPoint, 4);

buffer.resize(blockSize / sizeof(sint16));
bufferBE.resize(blockSize / sizeof(sint16be));
if(blockSize % (sizeof(sint16be) * 2) != 0)
cemu_assert_suspicious();

// workaround: SM3DW has incorrect loop point
const auto titleId = CafeSystem::GetForegroundTitleId();
@@ -23,8 +25,16 @@ sint16* BootSoundReader::getSamples()
while(totalRead < blockSize)
{
auto read = fsc_readFile(bootsndFile, bufferBE.data(), blockSize - totalRead);
if (read == 0)
{
cemuLog_log(LogType::Force, "failed to read PCM samples from bootSound.btsnd");
return nullptr;
}
if (read % (sizeof(sint16be) * 2) != 0)
cemu_assert_suspicious();
{
cemuLog_log(LogType::Force, "failed to play bootSound.btsnd: reading PCM data stopped at an odd number of samples (is the file corrupt?)");
return nullptr;
}

std::copy_n(bufferBE.begin(), read / sizeof(sint16be), buffer.begin() + (totalRead / sizeof(sint16)));
totalRead += read;