aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Input/in_cdda/VeritasPlay.h
blob: 30b16f382bb85a3ed88317cf3fb287f842f4375c (plain) (blame)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#ifndef NULLSOFT_VERITASPLAYH
#define NULLSOFT_VERITASPLAYH

#include "CDPlay.h"
#include <windows.h>
#include "SpeedLimiter.h"
#include "main.h"

using namespace Nullsoft::Utility;
class VeritasBuffer
{
public:
	VeritasBuffer() : buffer(0), readSize(0), sector(0), offset(0)
	{
	}
	~VeritasBuffer()
	{
		Destroy();
	}
	void Create(int numBuffers)
	{
		buffer = new BYTE[numBuffers * 2352];
		Clear();
	}
	void Destroy()
	{
		if (buffer)
			delete buffer;
		buffer = 0;
		Clear();
	}
	void Clear()
	{
		readSize = 0;
		sector = 0;
	}
	BYTE *buffer;
	BYTE *internal;
	DWORD readSize;
	DWORD sector;
	int offset;
};

class VeritasPlay : public C_CDPlay
{
public:
	VeritasPlay(bool _ripping = false);
	~VeritasPlay();
	//void Delete() 	{if (primo)		delete primo;		primo = 0;	}
	void CreateBuffers();
	void DestroyBuffers();
	int open(char drive, int track); //called by winampGetExtendedRead
	int play(char drive, int track); //called by winamp2
	int openVeritasTrack(DWORD start, DWORD length);

	static DWORD WINAPI threadProc(LPVOID lpParameter)
	{
		VeritasPlay *wp = (VeritasPlay *)lpParameter;
		return wp->threadProc2();
	}

	void OutputBuffer(VeritasBuffer &buffer);
	int read(char *dest, int len, int *killswitch);
	void Abort();
	void Seek();
	void SeekAndFlush();
	void Output(char *buffer, int len);
	void OutputOverflow();
	int CopyOverflow(char *sample_buffer, int len);

	size_t CopyBuffer(VeritasBuffer &buffer, char *&sample_buffer, int &bytes);
	int threadProc2();
	void stop();
	void pause()
	{
		line.outMod->Pause(1);
	}
	void unpause()
	{
		line.outMod->Pause(0);
	}
	int getlength()
	{
		return g_playlength;
	}
	int getoutputtime()
	{
		return line.outMod->GetOutputTime();
	}
	void setoutputtime(int time_in_ms);
	void setvolume(int a_v, int a_p);
	
	void *submitHandle;
private:
	void Close();
	void AbortAsync();
	
	void WaitForAbort(int time);
	int killswitch;
	HANDLE hThread;
	int decode_pos_ms;
	int need_seek;
	
	DWORD unit, start_sector, end_sector, lastseek, sec_length;
	int end;
	int total_extract_len;
	DWORD extract_start_time;
	BYTE *overflowBuffer;
	long overflow;
	VeritasBuffer *buffers;
	int buf_size, currentBuffer, nb_veritas_buf;
	int g_nch;
	bool ripping, opened;
	SpeedLimiter speedLimiter;
	bool padStart, padEnd;

	#ifndef IGNORE_PRIMO
	obj_primo *primo;
	#endif
};

#endif