First stab at sound threading

This commit is contained in:
2024-09-05 11:02:36 -04:00
parent 84eefedd6c
commit 966d5ee6fd
2 changed files with 15 additions and 8 deletions

View File

@@ -81,6 +81,7 @@ namespace ReMixer {
/// Returns the samples-per-second of this sound.
uint SampleRate() const { return sample_rate;}
/// Returns a pointer to the beginning of the audio data
char* ptr() { return audio_data.data();}
[[nodiscard]] const char* ptr() const { return audio_data.data();}

View File

@@ -21,6 +21,8 @@
[[noreturn]] int main() {
using namespace ReMixer;
using namespace std::chrono_literals;
@@ -31,17 +33,21 @@
PulseStream test_stream = test.CreateStream("Test Stream");
PulseStream test_stream2 = test.CreateStream("Another Test Stream");
Sound test_sound = Sound::FromPCMFile("output.raw");
Sound ogg_test_sound = Sound::FromOGGVorbisFile("song.ogg");
Sound test_sound = Sound::FromPCMFile("wind.raw");
Sound ogg_test_sound = Sound::FromOGGVorbisFile("wind.ogg");
std::thread playback_thread([](PulseAudioSubsystem system, PulseStream stream, Sound sound){
system.Play(stream, sound);
}, test, test_stream, ogg_test_sound);
playback_thread.join();
playback_thread.detach();
test.Play(test_stream, test_sound);
//test.Play(test_stream2, ogg_test_sound);
std::cout << "This text will print after the sound plays>" << std::endl;
while(true)
{
//std::this_thread::sleep_for(25ms);
}
std::cout << "This text will print after the sound plays." << std::endl;
return 0;
}