-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecoder_optimfrog.cpp
73 lines (61 loc) · 1.45 KB
/
decoder_optimfrog.cpp
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
#include "decoder_optimfrog.h"
#include "optimfroghelper.h"
DecoderOptimFROG::DecoderOptimFROG(QIODevice *input)
: Decoder(input)
{
}
DecoderOptimFROG::~DecoderOptimFROG()
{
delete m_helper;
}
bool DecoderOptimFROG::initialize()
{
if(!input())
return false;
if(!input()->isOpen() && !input()->open(QIODevice::ReadOnly))
return false;
m_helper = new OptimFROGHelper(input());
if(!m_helper->initialize())
{
qWarning("DecoderOptimFROG: initialize failed");
return false;
}
enum Qmmp::AudioFormat format;
switch(m_helper->depth())
{
case 8:
format = Qmmp::PCM_S8;
break;
case 16:
format = Qmmp::PCM_S16LE;
break;
default:
return false;
}
const int rate = m_helper->sampleRate();
const int channels = m_helper->channels();
if(rate == 0 || channels == 0)
{
qWarning("DecoderOptimFROG: rate or channel invalid");
return false;
}
configure(rate, channels, format);
qDebug("DecoderOptimFROG: initialize success");
return true;
}
qint64 DecoderOptimFROG::totalTime() const
{
return m_helper->totalTime();
}
int DecoderOptimFROG::bitrate() const
{
return m_helper->bitrate();
}
qint64 DecoderOptimFROG::read(unsigned char *data, qint64 maxSize)
{
return m_helper->read(data, maxSize);
}
void DecoderOptimFROG::seek(qint64 time)
{
m_helper->seek(time);
}