mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 13:33:13 -07:00
Add Audio Buffer Size Setting
This commit is contained in:
parent
88db8c8840
commit
69f7c385c7
6 changed files with 54 additions and 1 deletions
|
@ -63,6 +63,19 @@ class Settings : public QObject
|
||||||
unsigned int GetBitrate() const;
|
unsigned int GetBitrate() const;
|
||||||
void SetBitrate(unsigned int bitrate);
|
void SetBitrate(unsigned int bitrate);
|
||||||
|
|
||||||
|
unsigned int GetAudioBufferSizeDefault() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 0 if set to "automatic"
|
||||||
|
*/
|
||||||
|
unsigned int GetAudioBufferSizeRaw() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return actual size to be used, default value if GetAudioBufferSizeRaw() would return 0
|
||||||
|
*/
|
||||||
|
unsigned int GetAudioBufferSize() const;
|
||||||
|
void SetAudioBufferSize(unsigned int size);
|
||||||
|
|
||||||
ChiakiConnectVideoProfile GetVideoProfile();
|
ChiakiConnectVideoProfile GetVideoProfile();
|
||||||
|
|
||||||
QList<RegisteredHost> GetRegisteredHosts() const { return registered_hosts.values(); }
|
QList<RegisteredHost> GetRegisteredHosts() const { return registered_hosts.values(); }
|
||||||
|
|
|
@ -38,6 +38,7 @@ class SettingsDialog : public QDialog
|
||||||
QComboBox *resolution_combo_box;
|
QComboBox *resolution_combo_box;
|
||||||
QComboBox *fps_combo_box;
|
QComboBox *fps_combo_box;
|
||||||
QLineEdit *bitrate_edit;
|
QLineEdit *bitrate_edit;
|
||||||
|
QLineEdit *audio_buffer_size_edit;
|
||||||
|
|
||||||
QListWidget *registered_hosts_list_widget;
|
QListWidget *registered_hosts_list_widget;
|
||||||
QPushButton *delete_registered_host_button;
|
QPushButton *delete_registered_host_button;
|
||||||
|
@ -50,6 +51,7 @@ class SettingsDialog : public QDialog
|
||||||
void ResolutionSelected();
|
void ResolutionSelected();
|
||||||
void FPSSelected();
|
void FPSSelected();
|
||||||
void BitrateEdited();
|
void BitrateEdited();
|
||||||
|
void AudioBufferSizeEdited();
|
||||||
|
|
||||||
void UpdateRegisteredHosts();
|
void UpdateRegisteredHosts();
|
||||||
void UpdateRegisteredHostsButtons();
|
void UpdateRegisteredHostsButtons();
|
||||||
|
|
|
@ -52,6 +52,7 @@ struct StreamSessionConnectInfo
|
||||||
QByteArray regist_key;
|
QByteArray regist_key;
|
||||||
QByteArray morning;
|
QByteArray morning;
|
||||||
ChiakiConnectVideoProfile video_profile;
|
ChiakiConnectVideoProfile video_profile;
|
||||||
|
unsigned int audio_buffer_size;
|
||||||
|
|
||||||
StreamSessionConnectInfo();
|
StreamSessionConnectInfo();
|
||||||
StreamSessionConnectInfo(Settings *settings, QString host, QByteArray regist_key, QByteArray morning);
|
StreamSessionConnectInfo(Settings *settings, QString host, QByteArray regist_key, QByteArray morning);
|
||||||
|
@ -77,6 +78,7 @@ class StreamSession : public QObject
|
||||||
|
|
||||||
VideoDecoder video_decoder;
|
VideoDecoder video_decoder;
|
||||||
|
|
||||||
|
unsigned int audio_buffer_size;
|
||||||
QAudioOutput *audio_output;
|
QAudioOutput *audio_output;
|
||||||
QIODevice *audio_io;
|
QIODevice *audio_io;
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,27 @@ void Settings::SetBitrate(unsigned int bitrate)
|
||||||
settings.setValue("settings/bitrate", bitrate);
|
settings.setValue("settings/bitrate", bitrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Settings::GetAudioBufferSizeDefault() const
|
||||||
|
{
|
||||||
|
return 9600;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int Settings::GetAudioBufferSizeRaw() const
|
||||||
|
{
|
||||||
|
return settings.value("settings/audio_buffer_size", 0).toUInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int Settings::GetAudioBufferSize() const
|
||||||
|
{
|
||||||
|
unsigned int v = GetAudioBufferSizeRaw();
|
||||||
|
return v ? v : GetAudioBufferSizeDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetAudioBufferSize(unsigned int size)
|
||||||
|
{
|
||||||
|
settings.setValue("settings/audio_buffer_size", size);
|
||||||
|
}
|
||||||
|
|
||||||
ChiakiConnectVideoProfile Settings::GetVideoProfile()
|
ChiakiConnectVideoProfile Settings::GetVideoProfile()
|
||||||
{
|
{
|
||||||
ChiakiConnectVideoProfile profile;
|
ChiakiConnectVideoProfile profile;
|
||||||
|
|
|
@ -130,6 +130,13 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
|
||||||
connect(bitrate_edit, &QLineEdit::textEdited, this, &SettingsDialog::BitrateEdited);
|
connect(bitrate_edit, &QLineEdit::textEdited, this, &SettingsDialog::BitrateEdited);
|
||||||
UpdateBitratePlaceholder();
|
UpdateBitratePlaceholder();
|
||||||
|
|
||||||
|
audio_buffer_size_edit = new QLineEdit(this);
|
||||||
|
audio_buffer_size_edit->setValidator(new QIntValidator(1024, 0x20000));
|
||||||
|
unsigned int audio_buffer_size = settings->GetAudioBufferSizeRaw();
|
||||||
|
audio_buffer_size_edit->setText(audio_buffer_size ? QString::number(audio_buffer_size) : "");
|
||||||
|
stream_settings_layout->addRow(tr("Audio Buffer Size:"), audio_buffer_size_edit);
|
||||||
|
audio_buffer_size_edit->setPlaceholderText(tr("Default (%1)").arg(settings->GetAudioBufferSizeDefault()));
|
||||||
|
connect(audio_buffer_size_edit, &QLineEdit::textEdited, this, &SettingsDialog::AudioBufferSizeEdited);
|
||||||
|
|
||||||
// Registered Consoles
|
// Registered Consoles
|
||||||
|
|
||||||
|
@ -188,6 +195,11 @@ void SettingsDialog::BitrateEdited()
|
||||||
settings->SetBitrate(bitrate_edit->text().toUInt());
|
settings->SetBitrate(bitrate_edit->text().toUInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::AudioBufferSizeEdited()
|
||||||
|
{
|
||||||
|
settings->SetAudioBufferSize(audio_buffer_size_edit->text().toUInt());
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsDialog::UpdateBitratePlaceholder()
|
void SettingsDialog::UpdateBitratePlaceholder()
|
||||||
{
|
{
|
||||||
bitrate_edit->setPlaceholderText(tr("Automatic (%1)").arg(settings->GetVideoProfile().bitrate));
|
bitrate_edit->setPlaceholderText(tr("Automatic (%1)").arg(settings->GetVideoProfile().bitrate));
|
||||||
|
|
|
@ -36,6 +36,7 @@ StreamSessionConnectInfo::StreamSessionConnectInfo()
|
||||||
{
|
{
|
||||||
log_level_mask = CHIAKI_LOG_ALL;
|
log_level_mask = CHIAKI_LOG_ALL;
|
||||||
std::memset(&video_profile, 0, sizeof(video_profile));
|
std::memset(&video_profile, 0, sizeof(video_profile));
|
||||||
|
audio_buffer_size = 9600;
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamSessionConnectInfo::StreamSessionConnectInfo(Settings *settings, QString host, QByteArray regist_key, QByteArray morning)
|
StreamSessionConnectInfo::StreamSessionConnectInfo(Settings *settings, QString host, QByteArray regist_key, QByteArray morning)
|
||||||
|
@ -46,6 +47,7 @@ StreamSessionConnectInfo::StreamSessionConnectInfo(Settings *settings, QString h
|
||||||
this->host = host;
|
this->host = host;
|
||||||
this->regist_key = regist_key;
|
this->regist_key = regist_key;
|
||||||
this->morning = morning;
|
this->morning = morning;
|
||||||
|
audio_buffer_size = settings->GetAudioBufferSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AudioSettingsCb(uint32_t channels, uint32_t rate, void *user);
|
static void AudioSettingsCb(uint32_t channels, uint32_t rate, void *user);
|
||||||
|
@ -65,6 +67,7 @@ StreamSession::StreamSession(const StreamSessionConnectInfo &connect_info, QObje
|
||||||
audio_io(nullptr)
|
audio_io(nullptr)
|
||||||
{
|
{
|
||||||
chiaki_opus_decoder_init(&opus_decoder, log.GetChiakiLog());
|
chiaki_opus_decoder_init(&opus_decoder, log.GetChiakiLog());
|
||||||
|
audio_buffer_size = connect_info.audio_buffer_size;
|
||||||
|
|
||||||
QByteArray host_str = connect_info.host.toUtf8();
|
QByteArray host_str = connect_info.host.toUtf8();
|
||||||
|
|
||||||
|
@ -312,7 +315,7 @@ void StreamSession::InitAudio(unsigned int channels, unsigned int rate)
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_output = new QAudioOutput(audio_format, this);
|
audio_output = new QAudioOutput(audio_format, this);
|
||||||
audio_output->setBufferSize(48000);
|
audio_output->setBufferSize(audio_buffer_size);
|
||||||
audio_io = audio_output->start();
|
audio_io = audio_output->start();
|
||||||
|
|
||||||
CHIAKI_LOGI(log.GetChiakiLog(), "Audio Device %s opened with %u channels @ %u Hz, buffer size %u",
|
CHIAKI_LOGI(log.GetChiakiLog(), "Audio Device %s opened with %u channels @ %u Hz, buffer size %u",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue