mirror of
https://github.com/niellun/FastCarPlay.git
synced 2026-06-07 09:38:25 +02:00
Fixed pipelistener lifecycle
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user