KVIrc 5.2.0
Developer APIs
libkvisnd.h
Go to the documentation of this file.
1#ifndef _LIBKVISND_H_
2#define _LIBKVISND_H_
3//=============================================================================
4//
5// File : libkvisnd.h
6// Creation date : Thu Dec 27 2002 17:13:12 GMT by Juanjo Alvarez
7//
8// This file is part of the KVIrc IRC client distribution
9// Copyright (C) 2002 Juanjo Alvarez (juanjux at yahoo dot es)
10// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net)
11//
12// This program is FREE software. You can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation; either version 2
15// of the License, or (at your option) any later version.
16//
17// This program is distributed in the HOPE that it will be USEFUL,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20// See the GNU General Public License for more details.
21//
22// You should have received a copy of the GNU General Public License
23// along with this program. If not, write to the Free Software Foundation,
24// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25//
26//=============================================================================
27
28#include "kvi_settings.h"
29#include "KviPointerList.h"
30#include "KviPointerHashTable.h"
31#include "KviOptions.h"
32#include "KviThread.h"
33#include "KviCString.h"
34
35#include <QObject>
36
37class KviSoundPlayer;
38
40{
41public:
42 KviSoundThread(const QString & szFileName);
43 virtual ~KviSoundThread();
44
45protected:
47 QString m_szFileName;
48
49public:
50 void terminate();
51
52protected:
53 virtual void play();
54 virtual void run();
55};
56
57#if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)
58#ifdef COMPILE_OSS_SUPPORT
59class KviOssSoundThread : public KviSoundThread
60{
61public:
62 KviOssSoundThread(const QString & szFileName);
63 virtual ~KviOssSoundThread();
64
65protected:
66 virtual void play();
67};
68
69#ifdef COMPILE_AUDIOFILE_SUPPORT
70class KviOssAudiofileSoundThread : public KviSoundThread
71{
72public:
73 KviOssAudiofileSoundThread(const QString & szFileName);
74 virtual ~KviOssAudiofileSoundThread();
75
76protected:
77 virtual void play();
78};
79#endif //COMPILE_AUDIOFILE_SUPPORT
80#endif //COMPILE_OSS_SUPPORT
81
82#ifdef COMPILE_ESD_SUPPORT
83class KviEsdSoundThread : public KviSoundThread
84{
85public:
86 KviEsdSoundThread(const QString & szFileName);
87 virtual ~KviEsdSoundThread();
88
89protected:
90 virtual void play();
91};
92#endif //COMPILE_ESD_SUPPORT
93
94#ifdef COMPILE_ARTS_SUPPORT
95class KviArtsSoundThread : public KviSoundThread
96{
97public:
98 KviArtsSoundThread(const QString & szFileName);
99 virtual ~KviArtsSoundThread();
100
101protected:
102 virtual void play();
103};
104#endif //COMPILE_ARTS_SUPPORT
105#endif
106
107#ifdef COMPILE_PHONON_SUPPORT
108namespace Phonon
109{
110 class MediaObject;
111}
112#endif
113
114typedef bool (KviSoundPlayer::*SoundSystemPlayRoutine)(const QString & szFileName);
116
118{
119private:
122
123public:
125 : m_pPlayRoutine(pPlayRoutine), m_pCleanupRoutine(pCleanupRoutine)
126 {
127 }
128
130 {
131 return m_pPlayRoutine;
132 }
133
138};
139
140class KviSoundPlayer : public QObject
141{
142 friend class KviSoundThread;
143 Q_OBJECT
144public:
146 virtual ~KviSoundPlayer();
147
148public:
149 bool play(const QString & szFileName);
150 void detectSoundSystem();
151 bool havePlayingSounds();
152 void getAvailableSoundSystems(QStringList * l);
153 bool isMuted()
154 {
156 }
157 void setMuted(bool muted)
158 {
160 }
161
162protected:
165#ifdef COMPILE_PHONON_SUPPORT
166 Phonon::MediaObject * m_pPhononPlayer;
167#endif
169
170protected:
173 bool event(QEvent * e) override;
174
175protected:
176 void stopAllSoundThreads();
178#ifdef COMPILE_PHONON_SUPPORT
179 bool playPhonon(const QString & szFileName);
180 void cleanupPhonon();
181#endif
182#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
183 bool playWinmm(const QString & szFileName);
184 void cleanupWinmm();
185#else
186#ifdef COMPILE_OSS_SUPPORT
187 bool playOss(const QString & szFileName);
188 void cleanupOss();
189#ifdef COMPILE_AUDIOFILE_SUPPORT
190 bool playOssAudiofile(const QString & szFileName);
191 void cleanupOssAudiofile();
192#endif //COMPILE_AUDIOFILE_SUPPORT
193#endif //COMPILE_OSS_SUPPORT
194#ifdef COMPILE_ARTS_SUPPORT
195 bool playArts(const QString & szFileName);
196 void cleanupArts();
197#endif //COMPILE_ARTS_SUPPORT
198#ifdef COMPILE_ESD_SUPPORT
199 bool playEsd(const QString & szFileName);
200 void cleanupEsd();
201#endif //COMPILE_ESD_SUPPORT
202#endif
203 bool playQt(const QString & szFileName);
204 void cleanupQt();
205 bool playNull(const QString & szFileName);
206 void cleanupNull();
207};
208
209#endif // _KVISND_H_
#define KviOption_boolMuteAllSounds
Definition KviOptions.h:301
#define KVI_OPTION_BOOL(_idx)
Definition KviOptions.h:659
Pointer Hash Table.
C++ Template based double linked pointer list class.
A fast pointer hash table implementation.
Definition KviPointerHashTable.h:450
A template double linked list of pointers.
Definition KviPointerList.h:371
Definition libkvisnd.h:118
KviSoundPlayerEntry(SoundSystemPlayRoutine pPlayRoutine, SoundSystemCleanupRoutine pCleanupRoutine)
Definition libkvisnd.h:124
SoundSystemPlayRoutine m_pPlayRoutine
Definition libkvisnd.h:120
SoundSystemCleanupRoutine cleanupRoutine() const
Definition libkvisnd.h:134
SoundSystemPlayRoutine playRoutine() const
Definition libkvisnd.h:129
SoundSystemCleanupRoutine m_pCleanupRoutine
Definition libkvisnd.h:121
Definition libkvisnd.h:141
bool havePlayingSounds()
Definition libkvisnd.cpp:179
void unregisterSoundThread(KviSoundThread *t)
Definition libkvisnd.cpp:197
void setMuted(bool muted)
Definition libkvisnd.h:157
void cleanupAfterLastPlayerEntry()
Definition libkvisnd.cpp:158
void getAvailableSoundSystems(QStringList *l)
Definition libkvisnd.cpp:169
KviPointerList< KviSoundThread > * m_pThreadList
Definition libkvisnd.h:163
void detectSoundSystem()
Definition libkvisnd.cpp:215
bool playQt(const QString &szFileName)
COMPILE_PHONON_SUPPORT.
Definition libkvisnd.cpp:350
bool event(QEvent *e) override
Definition libkvisnd.cpp:202
void cleanupQt()
Definition libkvisnd.cpp:364
void stopAllSoundThreads()
Definition libkvisnd.cpp:147
KviSoundPlayerEntry * m_pLastUsedSoundPlayerEntry
COMPILE_PHONON_SUPPORT.
Definition libkvisnd.h:168
virtual ~KviSoundPlayer()
Definition libkvisnd.cpp:127
bool play(const QString &szFileName)
Definition libkvisnd.cpp:380
void registerSoundThread(KviSoundThread *t)
Definition libkvisnd.cpp:192
KviPointerHashTable< QString, KviSoundPlayerEntry > * m_pSoundSystemDict
Definition libkvisnd.h:164
void cleanupNull()
Definition libkvisnd.cpp:376
bool isMuted()
Definition libkvisnd.h:153
KviSoundPlayer()
Definition libkvisnd.cpp:87
bool playNull(const QString &szFileName)
Definition libkvisnd.cpp:370
Definition libkvisnd.h:40
virtual void run()
Definition libkvisnd.cpp:441
virtual ~KviSoundThread()
Definition libkvisnd.cpp:426
bool m_bTerminate
Definition libkvisnd.h:46
void terminate()
Definition libkvisnd.cpp:432
QString m_szFileName
Definition libkvisnd.h:47
virtual void play()
Definition libkvisnd.cpp:437
Definition KviThread.h:183
#define t
Definition detector.cpp:85
#define e
Definition detector.cpp:70
#define l
Definition detector.cpp:77
This file contains compile time settings.
void(KviSoundPlayer::* SoundSystemCleanupRoutine)()
Definition libkvisnd.h:115
bool(KviSoundPlayer::* SoundSystemPlayRoutine)(const QString &szFileName)
COMPILE_ON_WINDOWS.
Definition libkvisnd.h:114