aboutsummaryrefslogtreecommitdiff
path: root/lib/nav/core.cpp
blob: edc63c1881d9fa84f96ea3777a586509fc8053e5 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <lib/nav/core.h>
#include <lib/base/eerror.h>

void eNavigation::serviceEvent(iPlayableService* service, int event)
{
	if (service != m_runningService)
	{
		eDebug("nav: event for other service");
		return;
	}

	m_event(this, event);
}

RESULT eNavigation::playService(const eServiceReference &service)
{
	stopService();
	
	assert(m_servicehandler);
	RESULT res = m_servicehandler->play(service, m_runningService);
	if (m_runningService)
	{
		m_runningService->connectEvent(slot(*this, &eNavigation::serviceEvent), m_service_event_conn);
		res = m_runningService->start();
	}
	return res;
}

RESULT eNavigation::connectEvent(const Slot2<void,eNavigation*,int> &event, ePtr<eConnection> &connection)
{
	connection = new eConnection(this, m_event.connect(event));
	return 0;
}

RESULT eNavigation::getCurrentService(ePtr<iPlayableService> &service)
{
	service = m_runningService;
	return 0;
}

RESULT eNavigation::stopService(void)
{
		/* check if there is a running service... */
	if (!m_runningService)
		return 1;
			/* send stop event */
	m_event(this, iPlayableService::evEnd);

	m_runningService->stop();
		/* kill service. */
	m_runningService = 0;
	m_service_event_conn = 0;
	return 0;
}

RESULT eNavigation::recordService(const eServiceReference &ref, ePtr<iRecordableService> &service)
{
	assert(m_servicehandler);
	RESULT res = m_servicehandler->record(ref, service);
	eDebug("record: %d", res);
	if (res)
		service = 0;
	return res;
}

RESULT eNavigation::pause(int dop)
{
	if (!m_runningService)
		return -1;
	ePtr<iPauseableService> p;
	if (m_runningService->pause(p))
		return -2;
	if (dop)
		return p->pause();
	else
		return p->unpause();
}

eNavigation::eNavigation(iServiceHandler *serviceHandler)
{
	assert(serviceHandler);
	m_servicehandler = serviceHandler;
}

eNavigation::~eNavigation()
{
	stopService();
}

DEFINE_REF(eNavigation);