Rework audio setup pulseaudio / system interaction

This commit is contained in:
hawkeyexp 2018-07-18 16:44:40 +02:00
parent 093e79cd7a
commit 2feff5396e
4 changed files with 184 additions and 226 deletions

View File

@ -55,26 +55,6 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi
QLabel { color: #ffffff; font-weight: bold;} \ QLabel { color: #ffffff; font-weight: bold;} \
"); ");
// restore audio vol on startup if file exists
QFileInfo volFile("/boot/crankshaft/volume");
QFileInfo capvolFile("/boot/crankshaft/capvolume");
if (volFile.exists() + capvolFile.exists()) {
QFile volumeFile(QString("/boot/crankshaft/volume"));
volumeFile.open(QIODevice::ReadOnly);
QTextStream data_volume(&volumeFile);
QString linevolume = data_volume.readAll();
volumeFile.close();
QFile capvolumeFile(QString("/boot/crankshaft/capvolume"));
capvolumeFile.open(QIODevice::ReadOnly);
QTextStream data_capvolume(&capvolumeFile);
QString linecapvolume = data_capvolume.readAll();
capvolumeFile.close();
system( (std::string("/usr/local/bin/autoapp_helper setvolume ") + std::string(linevolume.toStdString()) ).c_str());
system( (std::string("/usr/local/bin/autoapp_helper setcapvolume ") + std::string(linecapvolume.toStdString()) ).c_str());
}
// Set default font and size // Set default font and size
int id = QFontDatabase::addApplicationFont(":/Roboto-Regular.ttf"); int id = QFontDatabase::addApplicationFont(":/Roboto-Regular.ttf");
QString family = QFontDatabase::applicationFontFamilies(id).at(0); QString family = QFontDatabase::applicationFontFamilies(id).at(0);
@ -222,6 +202,8 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi
ui_->pushButtonRearcam->hide(); ui_->pushButtonRearcam->hide();
ui_->pushButtonRearcamBack->hide(); ui_->pushButtonRearcamBack->hide();
ui_->systemConfigInProgress->hide();
if (!this->wifiButtonForce) { if (!this->wifiButtonForce) {
ui_->pushButtonWirelessConnection->hide(); ui_->pushButtonWirelessConnection->hide();
} }
@ -476,6 +458,18 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime()
} }
} }
QFileInfo configInProgressFile("/tmp/config_in_progress");
if (configInProgressFile.exists()) {
if (ui_->systemConfigInProgress->isVisible() == false) {
ui_->systemConfigInProgress->setText("System config in progress - please wait ...");
ui_->systemConfigInProgress->show();
}
} else {
if (ui_->systemConfigInProgress->isVisible() == true) {
ui_->systemConfigInProgress->hide();
}
}
QFileInfo nightModeFile("/tmp/night_mode_enabled"); QFileInfo nightModeFile("/tmp/night_mode_enabled");
this->nightModeEnabled = nightModeFile.exists(); this->nightModeEnabled = nightModeFile.exists();

View File

@ -107,29 +107,52 @@ void SettingsWindow::onSave()
configuration_->save(); configuration_->save();
system((std::string("/usr/local/bin/autoapp_helper setvolumes ") + std::to_string(ui_->horizontalSliderSystemVolume->value()) + std::string(" ") + std::to_string(ui_->horizontalSliderSystemCapture->value()) ).c_str()); // generate param string for autoapp_helper
system((std::string("/usr/local/bin/autoapp_helper setdisconnect ") + std::to_string(ui_->spinBoxDisconnect->value())).c_str()); std::string params;
system((std::string("/usr/local/bin/autoapp_helper setshutdown ") + std::to_string(ui_->spinBoxShutdown->value())).c_str()); params.append( std::to_string(ui_->horizontalSliderSystemVolume->value()) );
system((std::string("/usr/local/bin/autoapp_helper setdaynight ") + std::to_string(ui_->spinBoxDay->value()) + std::string(" ") + std::to_string(ui_->spinBoxNight->value()) ).c_str()); params.append("#");
params.append( std::to_string(ui_->horizontalSliderSystemCapture->value()) );
params.append("#");
params.append( std::to_string(ui_->spinBoxDisconnect->value()) );
params.append("#");
params.append( std::to_string(ui_->spinBoxShutdown->value()) );
params.append("#");
params.append( std::to_string(ui_->spinBoxDay->value()) );
params.append("#");
params.append( std::to_string(ui_->spinBoxNight->value()) );
params.append("#");
if (ui_->checkBoxGPIO->isChecked()) { if (ui_->checkBoxGPIO->isChecked()) {
system((std::string("/usr/local/bin/autoapp_helper setgpios ") + std::string("1 ") + std::string(ui_->comboBoxDevMode->currentText().toStdString() + " ") + std::string(ui_->comboBoxInvert->currentText().toStdString() + " ") + std::string(ui_->comboBoxX11->currentText().toStdString() + " ") + std::string(ui_->comboBoxRearcam->currentText().toStdString() + " ") + std::string(ui_->comboBoxAndroid->currentText().toStdString()) ).c_str()); params.append("1");
} else { } else {
system((std::string("/usr/local/bin/autoapp_helper setgpios ") + std::string("0 ") + std::string(ui_->comboBoxDevMode->currentText().toStdString() + " ") + std::string(ui_->comboBoxInvert->currentText().toStdString() + " ") + std::string(ui_->comboBoxX11->currentText().toStdString() + " ") + std::string(ui_->comboBoxRearcam->currentText().toStdString() + " ") + std::string(ui_->comboBoxAndroid->currentText().toStdString()) ).c_str()); params.append("0");
} }
params.append("#");
params.append( std::string(ui_->comboBoxDevMode->currentText().toStdString()) );
params.append("#");
params.append( std::string(ui_->comboBoxInvert->currentText().toStdString()) );
params.append("#");
params.append( std::string(ui_->comboBoxX11->currentText().toStdString()) );
params.append("#");
params.append( std::string(ui_->comboBoxRearcam->currentText().toStdString()) );
params.append("#");
params.append( std::string(ui_->comboBoxAndroid->currentText().toStdString()) );
params.append("#");
if (ui_->radioButtonX11->isChecked()) { if (ui_->radioButtonX11->isChecked()) {
system((std::string("/usr/local/bin/autoapp_helper setmode 1")).c_str()); params.append("1");
} else { } else {
system((std::string("/usr/local/bin/autoapp_helper setmode 0")).c_str()); params.append("0");
} }
params.append("#");
if (ui_->radioButtonScreenRotated->isChecked()) { if (ui_->radioButtonScreenRotated->isChecked()) {
system((std::string("/usr/local/bin/autoapp_helper setflip 1")).c_str()); params.append("1");
} else { } else {
system((std::string("/usr/local/bin/autoapp_helper setflip 0")).c_str()); params.append("0");
} }
system((std::string("/usr/local/bin/autoapp_helper setoutput ") + std::string("'") + std::string(ui_->comboBoxPulseOutput->currentText().toStdString()) + std::string("'") ).c_str()); params.append("#");
system((std::string("/usr/local/bin/autoapp_helper setinput ") + std::string("'") + std::string(ui_->comboBoxPulseInput->currentText().toStdString()) + std::string("'") ).c_str()); params.append( std::string("'") + std::string(ui_->comboBoxPulseOutput->currentText().toStdString()) + std::string("'") );
params.append("#");
params.append( std::string("'") + std::string(ui_->comboBoxPulseInput->currentText().toStdString()) + std::string("'") );
system((std::string("/usr/local/bin/autoapp_helper setparams#") + std::string(params) + std::string(" &") ).c_str());
this->close(); this->close();
} }
@ -274,217 +297,127 @@ void SettingsWindow::onUpdateSystemCapture(int value)
void SettingsWindow::loadSystemValues() void SettingsWindow::loadSystemValues()
{ {
// Get version string // Generate param file
QFileInfo vFile("/etc/crankshaft.build"); system("/usr/local/bin/autoapp_helper getparams");
if (vFile.exists()) {
QFile versionFile(QString("/etc/crankshaft.build"));
versionFile.open(QIODevice::ReadOnly);
QTextStream data_version(&versionFile);
QString valueversion = data_version.readAll();
versionFile.close();
ui_->valueSystemVersion->setText(valueversion);
} else {
ui_->valueSystemVersion->setText("");
}
// Get date string // read param file
QFileInfo dFile("/etc/crankshaft.date"); QFileInfo paramFile("/tmp/return_value");
if (dFile.exists()) { if (paramFile.exists()) {
QFile dateFile(QString("/etc/crankshaft.date")); QFile paramFile(QString("/tmp/return_value"));
dateFile.open(QIODevice::ReadOnly); paramFile.open(QIODevice::ReadOnly);
QTextStream data_date(&dateFile); QTextStream data_param(&paramFile);
QString valuedate = data_date.readAll(); QStringList getparams = data_param.readAll().split("#");
dateFile.close(); paramFile.close();
ui_->valueSystemBuildDate->setText(valuedate); // version string
} else { ui_->valueSystemVersion->setText(getparams[0]);
ui_->valueSystemBuildDate->setText(""); // date string
} ui_->valueSystemBuildDate->setText(getparams[1]);
// set volume
system("/usr/local/bin/autoapp_helper getvolume"); ui_->labelSystemVolumeValue->setText(getparams[2]);
QFileInfo rFile("/tmp/return_value"); ui_->horizontalSliderSystemVolume->setValue(getparams[2].toInt());
if (rFile.exists()) { // set cap volume
QFile returnFile(QString("/tmp/return_value")); ui_->labelSystemCaptureValue->setText(getparams[3]);
returnFile.open(QIODevice::ReadOnly); ui_->horizontalSliderSystemCapture->setValue(getparams[3].toInt());
QTextStream data_return(&returnFile); // set shutdown
QString currentvol = data_return.readAll(); ui_->valueShutdownTimer->setText(getparams[4]);
returnFile.close(); ui_->spinBoxShutdown->setValue(getparams[5].toInt());
ui_->labelSystemVolumeValue->setText(currentvol); // set disconnect
ui_->horizontalSliderSystemVolume->setValue(currentvol.toInt()); ui_->valueDisconnectTimer->setText(getparams[6]);
} ui_->spinBoxDisconnect->setValue(getparams[7].toInt());
// set day/night
system("/usr/local/bin/autoapp_helper getcapvolume"); ui_->spinBoxDay->setValue(getparams[8].toInt());
if (rFile.exists()) { ui_->spinBoxNight->setValue(getparams[9].toInt());
QFile returnFile(QString("/tmp/return_value")); // set gpios
returnFile.open(QIODevice::ReadOnly); if (getparams[10] == "1") {
QTextStream data_return(&returnFile);
QString currentcapvol = data_return.readAll();
returnFile.close();
ui_->labelSystemCaptureValue->setText(currentcapvol);
ui_->horizontalSliderSystemCapture->setValue(currentcapvol.toInt());
}
system("/usr/local/bin/autoapp_helper getfreemem");
if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly);
QTextStream data_return(&returnFile);
QString currentmem = data_return.readAll();
returnFile.close();
ui_->valueSystemFreeMem->setText(currentmem);
}
system("/usr/local/bin/autoapp_helper getcpufreq");
if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly);
QTextStream data_return(&returnFile);
QString currentfreq = data_return.readAll();
returnFile.close();
ui_->valueSystemCPUFreq->setText(currentfreq);
}
system("/usr/local/bin/autoapp_helper getcputemp");
if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly);
QTextStream data_return(&returnFile);
QString cputemp = data_return.readAll();
returnFile.close();
ui_->valueSystemCPUTemp->setText(cputemp);
}
system("/usr/local/bin/autoapp_helper getshutdown");
if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly);
QTextStream data_return(&returnFile);
QStringList shutdowntimer = data_return.readAll().split("-");;
returnFile.close();
ui_->spinBoxShutdown->setValue(shutdowntimer[0].toInt());
ui_->valueShutdownTimer->setText(shutdowntimer[1]);
}
system("/usr/local/bin/autoapp_helper getdisconnect");
if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly);
QTextStream data_return(&returnFile);
QStringList disconnecttimer = data_return.readAll().split("-");;
returnFile.close();
ui_->spinBoxDisconnect->setValue(disconnecttimer[0].toInt());
ui_->valueDisconnectTimer->setText(disconnecttimer[1]);
}
system("/usr/local/bin/autoapp_helper getgpios");
if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly);
QTextStream data_return(&returnFile);
QStringList gpiosetup = data_return.readAll().split(" ");
returnFile.close();
if (gpiosetup[0] == "1") {
ui_->checkBoxGPIO->setChecked(true); ui_->checkBoxGPIO->setChecked(true);
} else { } else {
ui_->checkBoxGPIO->setChecked(false); ui_->checkBoxGPIO->setChecked(false);
} }
ui_->comboBoxDevMode->setCurrentText(gpiosetup[1]); ui_->comboBoxDevMode->setCurrentText(getparams[11]);
ui_->comboBoxInvert->setCurrentText(gpiosetup[2]); ui_->comboBoxInvert->setCurrentText(getparams[12]);
ui_->comboBoxX11->setCurrentText(gpiosetup[3]); ui_->comboBoxX11->setCurrentText(getparams[13]);
ui_->comboBoxRearcam->setCurrentText(gpiosetup[4]); ui_->comboBoxRearcam->setCurrentText(getparams[14]);
ui_->comboBoxAndroid->setCurrentText(gpiosetup[5]); ui_->comboBoxAndroid->setCurrentText(getparams[15]);
} // set mode
if (getparams[16] == "0") {
system("/usr/local/bin/autoapp_helper getmodeflip");
if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly);
QTextStream data_return(&returnFile);
QStringList modeflip = data_return.readAll().split(" ");
returnFile.close();
if (modeflip[0] == "0") {
ui_->radioButtonEGL->setChecked(true); ui_->radioButtonEGL->setChecked(true);
} else { } else {
ui_->radioButtonX11->setChecked(true); ui_->radioButtonX11->setChecked(true);
} }
if (modeflip[1] == "0") { // set rotation
if (getparams[17] == "0") {
ui_->radioButtonScreenNormal->setChecked(true); ui_->radioButtonScreenNormal->setChecked(true);
} else { } else {
ui_->radioButtonScreenRotated->setChecked(true); ui_->radioButtonScreenRotated->setChecked(true);
} }
// set free mem
ui_->valueSystemFreeMem->setText(getparams[18]);
// set cpu freq
ui_->valueSystemCPUFreq->setText(getparams[19] + "MHz");
// set cpu temp
ui_->valueSystemCPUTemp->setText(getparams[20]);
} QFileInfo inputsFile("/tmp/get_inputs");
if (inputsFile.exists()) {
system("/usr/local/bin/autoapp_helper getdaynight"); QFile inputsFile(QString("/tmp/get_inputs"));
if (rFile.exists()) { inputsFile.open(QIODevice::ReadOnly);
QFile returnFile(QString("/tmp/return_value")); QTextStream data_return(&inputsFile);
returnFile.open(QIODevice::ReadOnly); QStringList inputs = data_return.readAll().split("\n");
QTextStream data_return(&returnFile); inputsFile.close();
QStringList daynight = data_return.readAll().split(" "); int cleaner = ui_->comboBoxPulseInput->count();
returnFile.close(); while (cleaner > 0) {
ui_->spinBoxDay->setValue(daynight[0].toInt()); ui_->comboBoxPulseInput->removeItem(cleaner);
ui_->spinBoxNight->setValue(daynight[1].toInt()); cleaner--;
} }
int indexin = inputs.count();
system("/usr/local/bin/autoapp_helper getoutputs"); int countin = 0;
if (rFile.exists()) { while (countin < indexin-1) {
QFile returnFile(QString("/tmp/return_value")); ui_->comboBoxPulseInput->addItem(inputs[countin]);
returnFile.open(QIODevice::ReadOnly); countin++;
QTextStream data_return(&returnFile); }
QStringList outputs = data_return.readAll().split("\n");
returnFile.close();
int cleaner = ui_->comboBoxPulseOutput->count();
while (cleaner > 0) {
ui_->comboBoxPulseOutput->removeItem(cleaner);
cleaner--;
} }
int indexout = outputs.count();
int countout = 0; QFileInfo outputsFile("/tmp/get_outputs");
while (countout < indexout-1) { if (outputsFile.exists()) {
ui_->comboBoxPulseOutput->addItem(outputs[countout]); QFile outputsFile(QString("/tmp/get_outputs"));
countout++; outputsFile.open(QIODevice::ReadOnly);
QTextStream data_return(&outputsFile);
QStringList outputs = data_return.readAll().split("\n");
outputsFile.close();
int cleaner = ui_->comboBoxPulseOutput->count();
while (cleaner > 0) {
ui_->comboBoxPulseOutput->removeItem(cleaner);
cleaner--;
}
int indexout = outputs.count();
int countout = 0;
while (countout < indexout-1) {
ui_->comboBoxPulseOutput->addItem(outputs[countout]);
countout++;
}
} }
}
system("/usr/local/bin/autoapp_helper getdefaultoutput"); QFileInfo defaultoutputFile("/tmp/get_default_output");
if (rFile.exists()) { if (defaultoutputFile.exists()) {
QFile returnFile(QString("/tmp/return_value")); QFile defaultoutputFile(QString("/tmp/get_default_output"));
returnFile.open(QIODevice::ReadOnly); defaultoutputFile.open(QIODevice::ReadOnly);
QTextStream data_return(&returnFile); QTextStream data_return(&defaultoutputFile);
QStringList defoutput = data_return.readAll().split("\n"); QStringList defoutput = data_return.readAll().split("\n");
returnFile.close(); defaultoutputFile.close();
ui_->comboBoxPulseOutput->setCurrentText(defoutput[0]); ui_->comboBoxPulseOutput->setCurrentText(defoutput[0]);
}
system("/usr/local/bin/autoapp_helper getinputs");
if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly);
QTextStream data_return(&returnFile);
QStringList inputs = data_return.readAll().split("\n");
returnFile.close();
int cleaner = ui_->comboBoxPulseInput->count();
while (cleaner > 0) {
ui_->comboBoxPulseInput->removeItem(cleaner);
cleaner--;
} }
int indexin = inputs.count();
int countin = 0; QFileInfo defaultinputFile("/tmp/get_default_input");
while (countin < indexin-1) { if (defaultinputFile.exists()) {
ui_->comboBoxPulseInput->addItem(inputs[countin]); QFile defaultinputFile(QString("/tmp/get_default_input"));
countin++; defaultinputFile.open(QIODevice::ReadOnly);
QTextStream data_return(&defaultinputFile);
QStringList definput = data_return.readAll().split("\n");
defaultinputFile.close();
ui_->comboBoxPulseInput->setCurrentText(definput[0]);
} }
}
system("/usr/local/bin/autoapp_helper getdefaultinput");
if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly);
QTextStream data_return(&returnFile);
QStringList definput = data_return.readAll().split("\n");
returnFile.close();
ui_->comboBoxPulseInput->setCurrentText(definput[0]);
} }
} }
void SettingsWindow::onShowBindings() void SettingsWindow::onShowBindings()

View File

@ -641,6 +641,37 @@
<number>25</number> <number>25</number>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="systemConfigInProgress">
<property name="geometry">
<rect>
<x>200</x>
<y>368</y>
<width>400</width>
<height>24</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>210</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<family>Roboto</family>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string>System config in progress - please wait ...</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing</set>
</property>
</widget>
</widget> </widget>
</widget> </widget>
<tabstops> <tabstops>

View File

@ -1289,7 +1289,7 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;}</string>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
<string>Master System Playback Volume</string> <string>Playback Volume Selected Hardware</string>
</property> </property>
<widget class="QLabel" name="labelSystemVolumeValue"> <widget class="QLabel" name="labelSystemVolumeValue">
<property name="geometry"> <property name="geometry">
@ -1335,7 +1335,7 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;}</string>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
<string>Master System Capture Volume</string> <string>Capture Volume Selected Hardware</string>
</property> </property>
<widget class="QLabel" name="labelSystemCaptureValue"> <widget class="QLabel" name="labelSystemCaptureValue">
<property name="geometry"> <property name="geometry">