From 824a48f8d26cecad8d2130f024431d67fb76a92c Mon Sep 17 00:00:00 2001 From: faraphel Date: Tue, 22 Oct 2024 20:21:29 +0200 Subject: [PATCH] fixed the sampleFormat size used in the frames calculation --- source/Client.cpp | 4 +--- source/Server.cpp | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/source/Client.cpp b/source/Client.cpp index 20f4fb2..b55b306 100644 --- a/source/Client.cpp +++ b/source/Client.cpp @@ -171,12 +171,10 @@ void Client::loopPlayer() { throw std::runtime_error("[Client] Could not start the PortAudio stream: " + std::string(Pa_GetErrorText(error))); // write the new audio data into the audio buffer - // TODO(Faraphel) / 2 => / encoding size - // TODO(Faraphel): the number of frames could be improved const int error = Pa_WriteStream( this->stream, audioPacket.content.data(), - audioPacket.contentSize / 2 / this->streamChannels + audioPacket.contentSize / Pa_GetSampleSize(this->streamSampleFormat) / this->streamChannels ); switch (error) { // success diff --git a/source/Server.cpp b/source/Server.cpp index 1488ec2..4ca611e 100644 --- a/source/Server.cpp +++ b/source/Server.cpp @@ -114,7 +114,6 @@ void Server::loop() const { std::cout << "[Server] Sent: " << done << " bytes" << std::endl; - // TODO(Faraphel): should be extended to simulate live music streaming // wait for the duration of the audio chunk std::this_thread::sleep_for(std::chrono::milliseconds(static_cast( (1 / static_cast(this->sampleRate * this->channels * mpg123_encsize(this->encoding))) *