Fixed pipelistener lifecycle

This commit is contained in:
Niellune
2026-03-31 02:44:20 +03:00
parent 62e9ad7fa6
commit f483456318
3 changed files with 11 additions and 4 deletions
+9
View File
@@ -45,6 +45,7 @@ static constexpr size_t keyMapSize = sizeof(keyMap) / sizeof(keyMap[0]);
Application::Application(/* args */) : _window(nullptr),
_renderer(nullptr),
_keyListener(nullptr),
_active(true)
{
log_v("Creating");
@@ -76,6 +77,11 @@ Application::Application(/* args */) : _window(nullptr),
Application::~Application()
{
log_v("Destroying");
if (_keyListener != nullptr)
{
delete _keyListener;
_keyListener = nullptr;
}
if (_renderer != nullptr)
SDL_DestroyRenderer(_renderer);
if (_window != nullptr)
@@ -360,6 +366,9 @@ void Application::loop()
Decoder decoder;
PcmAudio audioMain("main"), audioAux("aux");
if (Settings::keyPipe.value.length() > 2)
_keyListener = new PipeListener(Settings::keyPipe.value.c_str());
decoder.start(&protocol.videoStream, AV_CODEC_ID_H264);
audioMain.start(&protocol.audioStreamMain);
audioAux.start(&protocol.audioStreamAux, &audioMain);
+2
View File
@@ -6,6 +6,7 @@
#include "protocol/protocol_const.h"
#include "protocol/connection.h"
#include "pipe_listener.h"
#include "renderer.h"
#define TOAST_TIME 3
@@ -41,6 +42,7 @@ private:
SDL_Window *_window;
SDL_Renderer *_renderer;
PipeListener *_keyListener;
bool _active;
SDL_DisplayMode _displayMode;
State _state;
-4
View File
@@ -6,7 +6,6 @@
#include "common/logger.h"
#include "application.h"
#include "pipe_listener.h"
#include "settings.h"
static const char *title = "Fast Car Play v0.9";
@@ -16,9 +15,6 @@ void start()
set_log_level(Settings::loglevel);
Settings::print();
if (Settings::keyPipe.value.length() > 2)
PipeListener pipeListener(Settings::keyPipe.value.c_str());
Application app;
app.start(title);
}