Skip to content

Commit

Permalink
Adding default audio buffer size to libopenshot settings, and setting…
Browse files Browse the repository at this point in the history
… default to 512. Also, adding some debugging output. This will allow users to override the default audio buffer size, to better customize for their system.
  • Loading branch information
jonoomph committed Dec 9, 2024
1 parent ad5a600 commit a25513b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/AudioReaderSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "AudioReaderSource.h"
#include "Exceptions.h"
#include "Frame.h"
#include "ZmqLogger.h"


using namespace std;
using namespace openshot;
Expand Down Expand Up @@ -44,8 +42,6 @@ void AudioReaderSource::getNextAudioBlock(const juce::AudioSourceChannelInfo& in
}

while (remaining_samples > 0) {
ZmqLogger::Instance()->AppendDebugMethod("AudioReaderSource::getNextAudioBlock", "remaining_samples", remaining_samples);

try {
// Get current frame object
if (reader) {
Expand Down
8 changes: 4 additions & 4 deletions src/Qt/AudioPlaybackThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ namespace openshot

std::stringstream constructor_title;
constructor_title << "AudioDeviceManagerSingleton::Instance (default audio device type: " <<
Settings::Instance()->PLAYBACK_AUDIO_DEVICE_TYPE << ", default audio device name: " <<
Settings::Instance()->PLAYBACK_AUDIO_DEVICE_NAME << ")";
ZmqLogger::Instance()->AppendDebugMethod(constructor_title.str(), "channels", channels);
Settings::Instance()->PLAYBACK_AUDIO_DEVICE_TYPE << ", default audio device name: " <<
Settings::Instance()->PLAYBACK_AUDIO_DEVICE_NAME << ")";
ZmqLogger::Instance()->AppendDebugMethod(constructor_title.str(), "channels", channels, "buffer", Settings::Instance()->PLAYBACK_AUDIO_BUFFER_SIZE);

// Get preferred audio device type and name (if any - these can be blank)
openshot::AudioDeviceInfo requested_device = {Settings::Instance()->PLAYBACK_AUDIO_DEVICE_TYPE,
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace openshot
AudioDeviceManager::AudioDeviceSetup deviceSetup = AudioDeviceManager::AudioDeviceSetup();
deviceSetup.inputChannels = 0;
deviceSetup.outputChannels = channels;
deviceSetup.bufferSize = 512;
deviceSetup.bufferSize = Settings::Instance()->PLAYBACK_AUDIO_BUFFER_SIZE;

// Loop through common sample rates, starting with the user's requested rate
// Not all sample rates are supported by audio devices, for example, many VMs
Expand Down
3 changes: 3 additions & 0 deletions src/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ namespace openshot {
/// The device type for the playback audio devices
std::string PLAYBACK_AUDIO_DEVICE_TYPE = "";

/// Size of playback buffer before audio playback starts
int PLAYBACK_AUDIO_BUFFER_SIZE = 512;

/// The current install path of OpenShot (needs to be set when using Timeline(path), since certain
/// paths depend on the location of OpenShot transitions and files)
std::string PATH_OPENSHOT_INSTALL = "";
Expand Down

0 comments on commit a25513b

Please sign in to comment.