summaryrefslogtreecommitdiffstats
path: root/oggvorbis_artsplugin/oggPlayObject_impl.h
blob: 2f1b0c0c88533fdaa94dd331076f88b22ea83d56 (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
#ifndef OGGPLAYER_IMPL_H
#define OGGPLAYER_IMPL_H "$Id$"

#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) || defined(__DragonFly__)
/* union semun is defined by including <sys/sem.h> */
#else
/* according to X/OPEN we have to define it ourselves */
union semun {
	int val;                    /* value for SETVAL */
	struct semid_ds *buf;       /* buffer for IPC_STAT, IPC_SET */
	unsigned short int *array;  /* array for GETALL, SETALL */
	struct seminfo *__buf;      /* buffer for IPC_INFO */
};
#endif

int buf_pos;

namespace Arts {

class oggPlayObject_impl
	: public oggPlayObject_skel, public StdSynthModule
{
 public:
	oggPlayObject_impl();
	~oggPlayObject_impl();
	bool loadMedia(const std::string &filename);
	std::string description();
	poTime currentTime();
	poTime overallTime();
	poCapabilities capabilities();
	std::string mediaName();
	poState state();
	void play();
	void halt();
	void seek(const class poTime &t);
	void pause();
	void streamInit();
	void streamStart();
	void calculateBlock(unsigned long samples);
	void streamEnd();

 protected:

	static const int BACKBUFSIZ=4096;
	OggVorbis_File vf;
	std::string currentFile;

	inline float conv_16le_float(short x)
		{ return static_cast<float>(x) / 32768.0; }

	poState mState;
	struct buf_t{
		float left[BACKBUFSIZ];
		float right[BACKBUFSIZ];
	} *shm_buf;
	int shm_id, child_pid;
	int buflen_sem;
};

};

#endif