make the camera settings dialog not suck balls

This commit is contained in:
Arisotura 2022-09-26 19:20:30 +02:00
parent d102f63686
commit 5f365afb9c
6 changed files with 38 additions and 11 deletions

View File

@ -169,9 +169,9 @@ void CameraManager::deInit()
}
void CameraManager::start()
{printf("[%d] [%d] START\n", num, startNum);
startNum++;
if (startNum > 1) return;
{
if (startNum == 1) return;
startNum = 1;
if (inputType == 2)
{
@ -180,9 +180,9 @@ void CameraManager::start()
}
void CameraManager::stop()
{printf("[%d] [%d] STOP\n", num, startNum-1);
startNum--;
if (startNum > 0) return;
{
if (startNum == 0) return;
startNum = 0;
if (inputType == 2)
{
@ -190,6 +190,11 @@ void CameraManager::stop()
}
}
bool CameraManager::isStarted()
{
return startNum != 0;
}
void CameraManager::camStart()
{
camDevice->start();

View File

@ -56,6 +56,7 @@ public:
void start();
void stop();
bool isStarted();
void captureFrame(u32* frame, int width, int height, bool yuv);

View File

@ -154,8 +154,10 @@ void CameraSettingsDialog::on_cbCameraSel_currentIndexChanged(int id)
currentId = id;
currentCfg = &Config::Camera[id];
currentCam = camManager[id];
//currentCam = camManager[id];
currentCam = nullptr;
populateCamControls(id);
currentCam = camManager[id];
previewPanel->setCurrentCam(currentCam);
currentCam->start();

View File

@ -71,7 +71,7 @@ public:
}
currentDlg = new CameraSettingsDialog(parent);
currentDlg->show();
currentDlg->open();
return currentDlg;
}
static void closeDlg()

View File

@ -118,6 +118,7 @@ u32 micWavLength;
s16* micWavBuffer;
CameraManager* camManager[2];
bool camStarted[2];
const struct { int id; float ratio; const char* label; } aspectRatios[] =
{
@ -2805,8 +2806,23 @@ void MainWindow::onOpenVideoSettings()
void MainWindow::onOpenCameraSettings()
{
emuThread->emuPause();
camStarted[0] = camManager[0]->isStarted();
camStarted[1] = camManager[1]->isStarted();
if (camStarted[0]) camManager[0]->stop();
if (camStarted[1]) camManager[1]->stop();
CameraSettingsDialog* dlg = CameraSettingsDialog::openDlg(this);
//connect(dlg, &CameraSettingsDialog::updateCameraSettings, this, &MainWindow::onUpdateCameraSettings);
connect(dlg, &CameraSettingsDialog::finished, this, &MainWindow::onCameraSettingsFinished);
}
void MainWindow::onCameraSettingsFinished(int res)
{
if (camStarted[0]) camManager[0]->start();
if (camStarted[1]) camManager[1]->start();
emuThread->emuUnpause();
}
void MainWindow::onOpenAudioSettings()
@ -3257,6 +3273,8 @@ int main(int argc, char** argv)
micExtBufferWritePos = 0;
micWavBuffer = nullptr;
camStarted[0] = false;
camStarted[1] = false;
camManager[0] = new CameraManager(0, 640, 480, true);
camManager[1] = new CameraManager(1, 640, 480, true);

View File

@ -267,11 +267,12 @@ private slots:
void onInputConfigFinished(int res);
void onOpenVideoSettings();
void onOpenCameraSettings();
void onCameraSettingsFinished(int res);
void onOpenAudioSettings();
void onOpenFirmwareSettings();
void onOpenPathSettings();
void onUpdateAudioSettings();
void onAudioSettingsFinished(int res);
void onOpenFirmwareSettings();
void onOpenPathSettings();
void onOpenMPSettings();
void onMPSettingsFinished(int res);
void onOpenWifiSettings();