summaryrefslogtreecommitdiffstats
path: root/noatun/library/noatun/engine.h
blob: 3108ae8427e36b2af9f87bb5c37abaa277f817cb (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
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
#ifndef _ENGINE_H
#define _ENGINE_H

#include <tqobject.h>
#include <kurl.h>
#include <arts/kmedia2.h>
#include <noatun/playlist.h>
#include <kdemacros.h>
class Visualization;

namespace Arts
{
	class SoundServerV2;

	class Synth_AMAN_PLAY;
}

namespace Noatun
{
	class StereoEffectStack;
	class StereoVolumeControl;
	class Equalizer;
	class Session;
}

class NoatunApp;

/**
 * Handles all playing, connecting to aRts.
 * Does almost everything related to multimedia.
 * Most interfacing should be done with Player
 **/
class KDE_EXPORT Engine : public TQObject
{
Q_OBJECT
  TQ_OBJECT
friend class NoatunApp;
public:
	Engine(TQObject *tqparent=0);
	~Engine();
	void setInitialized();
	bool initialized() const;

public slots:
	/**
	 * opens the file, use play() to start playing
	 **/
	bool open(const PlaylistItem &file);
	/**
	 * Continues playing
	 **/
	bool play();
	/**
	 * Terminates playing, does not close the file
	 **/
	void pause();
	/**
	 * resets the engine
	 **/
	void stop();
	/**
	 * skips to a timecode
	 * unit is milliseconds
	 **/
	void seek(int msec);

	void setVolume(int percent);

	void connectPlayObject();
signals:
	void done();
	/**
	 * emitted when arts dies and noatun has to start
	 * it again. This is called when the new arts
	 * is already initialized
	 **/
	void artsError();

	void aboutToPlay();

	void receivedStreamMeta(
		const TQString &streamName, const TQString &streamGenre,
		const TQString &streamUrl, const TQString &streamBitrate,
		const TQString &trackTitle, const TQString &trackUrl
	);

	void playingFailed();

	private slots:
		void slotProxyError();
		void deleteProxy();

public:
	int state();
	int position(); // return position in milliseconds
	int length(); // return track-length in milliseconds
	int volume() const;

private:
	int openMixerFD();
	void closeMixerFD(int);
	void useHardwareMixer(bool);
	bool initArts();

public:
	Arts::SoundServerV2 *server() const;
	Arts::PlayObject playObject() const;
	Arts::SoundServerV2 *simpleSoundServer() const;
	Noatun::StereoEffectStack *effectStack() const;
	Noatun::Equalizer *equalizer() const;
	Noatun::StereoEffectStack *visualizationStack() const;
	Noatun::StereoEffectStack *globalEffectStack() const;
	Noatun::Session *session() const;

private:
	class EnginePrivate;
	EnginePrivate *d;
	bool mPlay;
};

#endif