summaryrefslogtreecommitdiff
path: root/Userland/Applications/SoundPlayer
diff options
context:
space:
mode:
authorCesar Torres <shortanemoia@protonmail.com>2021-03-21 13:43:27 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-27 10:20:55 +0100
commitf9e4bff487ed8f9571bd9a598d2f4b7c84f50897 (patch)
tree456b01f8967ce20093324729efc69533bde87649 /Userland/Applications/SoundPlayer
parent7aa52978359c721cb283bab786a36943dc5b3e20 (diff)
downloadserenity-f9e4bff487ed8f9571bd9a598d2f4b7c84f50897.zip
SoundPlayer: Reduce sample buffer size and add a sample load event
Diffstat (limited to 'Userland/Applications/SoundPlayer')
-rw-r--r--Userland/Applications/SoundPlayer/CMakeLists.txt4
-rw-r--r--Userland/Applications/SoundPlayer/PlaybackManager.cpp6
-rw-r--r--Userland/Applications/SoundPlayer/PlaybackManager.h3
3 files changed, 10 insertions, 3 deletions
diff --git a/Userland/Applications/SoundPlayer/CMakeLists.txt b/Userland/Applications/SoundPlayer/CMakeLists.txt
index 99e1da4653..70c3d79965 100644
--- a/Userland/Applications/SoundPlayer/CMakeLists.txt
+++ b/Userland/Applications/SoundPlayer/CMakeLists.txt
@@ -3,6 +3,10 @@ set(SOURCES
PlaybackManager.cpp
SampleWidget.cpp
SoundPlayerWidget.cpp
+ SoundPlayerWidgetAdvancedView.cpp
+ BarsVisualizationWidget.cpp
+ AudioAlgorithms.cpp
+ NoVisualizationWidget.cpp
)
serenity_app(SoundPlayer ICON app-sound-player)
diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.cpp b/Userland/Applications/SoundPlayer/PlaybackManager.cpp
index f301df0acb..4e1c9c6fbb 100644
--- a/Userland/Applications/SoundPlayer/PlaybackManager.cpp
+++ b/Userland/Applications/SoundPlayer/PlaybackManager.cpp
@@ -128,13 +128,16 @@ void PlaybackManager::load_next_buffer()
if (m_buffers.size() < 10) {
for (int i = 0; i < 20 && m_loader->loaded_samples() < m_loader->total_samples(); i++) {
auto buffer = m_loader->get_more_samples(PLAYBACK_MANAGER_BUFFER_SIZE);
- if (buffer)
+ if (buffer) {
m_buffers.append(buffer);
+ }
}
}
if (m_next_ptr < m_buffers.size()) {
m_next_buffer = m_buffers.at(m_next_ptr++);
+ if (on_load_sample_buffer)
+ on_load_sample_buffer(*m_next_buffer);
} else {
m_next_buffer = nullptr;
}
@@ -163,7 +166,6 @@ void PlaybackManager::next_buffer()
{
if (on_update)
on_update();
-
if (m_paused)
return;
diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.h b/Userland/Applications/SoundPlayer/PlaybackManager.h
index 35be78fe9d..8c851b093f 100644
--- a/Userland/Applications/SoundPlayer/PlaybackManager.h
+++ b/Userland/Applications/SoundPlayer/PlaybackManager.h
@@ -32,7 +32,7 @@
#include <LibAudio/Loader.h>
#include <LibCore/Timer.h>
-#define PLAYBACK_MANAGER_BUFFER_SIZE 64 * KiB
+#define PLAYBACK_MANAGER_BUFFER_SIZE 48 * KiB
#define PLAYBACK_MANAGER_RATE 44100
class PlaybackManager final {
@@ -56,6 +56,7 @@ public:
NonnullRefPtr<Audio::ClientConnection> connection() const { return m_connection; }
Function<void()> on_update;
+ Function<void(Audio::Buffer&)> on_load_sample_buffer;
private:
void next_buffer();