-
Notifications
You must be signed in to change notification settings - Fork 0
/
DecodeMP3.h
62 lines (45 loc) · 941 Bytes
/
DecodeMP3.h
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
#pragma once
extern "C"
{
#include "mp3dec/minimp3.h"
}
class DecodeMP3
{
public:
DecodeMP3();
~DecodeMP3();
bool Open(LPCTSTR pszPathname);
void Close();
void FillBuffer(int32_t* pLeft, int32_t* pRight, int nWords);
private:
static void ThreadProc(DecodeMP3* pThis);
void PushDecoded(signed short* pDecodedMP3, int cbDecoded);
struct BufferItem
{
BufferItem()
{
pAudioData = NULL;
cbAllocated = 0;
}
~BufferItem()
{
free(pAudioData);
}
int32_t* pAudioData; // L,R interleaved
int cbAllocated;
int nFilled;
int nUsed; // audio word (int32) count
};
bool DecodeMore(bool isFirst, mp3_info_t* pInfoOut);
LONG m_nQueueItemCount;
std::mutex m_mutex;
std::thread* m_pThread;
std::queue<BufferItem*> m_queue;
std::vector<BufferItem*> m_freeItems;
bool m_bStopThread;
BYTE* m_pRawFile;
long m_cbFileSize;
BYTE* m_pNextDecodePos;
int m_cbLeftMP3Size;
mp3_decoder_t* m_pDecoder;
};