blob: fb5993e418e7d49f3446d867c140f54bf2b7ed1b (
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
|
#include <lib/base/eerror.h>
#include <lib/base/object.h>
#include <string>
#include <lib/service/servicemp3.h>
#include <lib/service/service.h>
#include <lib/base/init_num.h>
#include <lib/base/init.h>
// eServiceFactoryMP3
eServiceFactoryMP3::eServiceFactoryMP3(): ref(0)
{
ePtr<eServiceCenter> sc;
eServiceCenter::getInstance(sc);
if (sc)
sc->addServiceFactory(eServiceFactoryMP3::id, this);
}
eServiceFactoryMP3::~eServiceFactoryMP3()
{
ePtr<eServiceCenter> sc;
eServiceCenter::getInstance(sc);
if (sc)
sc->removeServiceFactory(eServiceFactoryMP3::id);
}
DEFINE_REF(eServiceFactoryMP3)
// iServiceHandler
RESULT eServiceFactoryMP3::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
{
RESULT res;
// check resources...
ptr = new eServiceMP3(ref.path.c_str());
res = ptr->start();
if (res)
{
ptr = 0;
return res;
}
return 0;
}
RESULT eServiceFactoryMP3::record(const eServiceReference &ref, ePtr<iRecordableService> &ptr)
{
ptr=0;
return -1;
}
RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr<iListableService> &ptr)
{
ptr=0;
return -1;
}
// eServiceMP3
eServiceMP3::eServiceMP3(const char *filename): filename(filename), ref(0)
{
printf("MP3: %s start\n", filename);
}
eServiceMP3::~eServiceMP3()
{
printf("MP3: %s stop\n", filename.c_str());
}
void eServiceMP3::AddRef()
{
++ref;
}
void eServiceMP3::Release()
{
if (!--ref)
delete this;
}
RESULT eServiceMP3::start() { printf("mp3 starts\n"); return 0; }
RESULT eServiceMP3::getIPausableService(ePtr<iPauseableService> &ptr) { ptr=this; return 0; }
// iPausableService
RESULT eServiceMP3::pause() { printf("mp3 pauses!\n"); return 0; }
RESULT eServiceMP3::unpause() { printf("mp3 unpauses!\n"); return 0; }
eAutoInitP0<eServiceFactoryMP3> init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3");
|