summaryrefslogtreecommitdiff
path: root/thread.cpp
blob: df6580ceffb83936d467ac8c2c7902d0b8db06ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include <tnt/tntnet.h>
#include <vdr/plugin.h>
#include "thread.h"
#include "tntconfig.h"

namespace vdrlive {

using namespace std;
using namespace tnt;

ServerThread::ServerThread():
		m_configPath( 0 )
{
}

ServerThread::~ServerThread()
{
	free( m_configPath );
}

void ServerThread::Action()
{
	try {
		m_configPath = strdup( TntConfig::Get().GetConfigPath().c_str() );

		char* argv[] = { "tntnet", "-c", m_configPath };
		int argc = sizeof( argv ) / sizeof( argv[0] );
		Tntnet app( argc, argv );
		app.run();
	} catch ( exception const& ex ) {
		// XXX move initial error handling to live.cpp
		esyslog( "ERROR: live httpd server crashed: %s", ex.what() );
		cerr << "HTTPD FATAL ERROR: " << ex.what() << endl;
	}
}

} // namespace vdrlive