KVIrc  4.9.2
DeveloperAPIs
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 
37 class KviSoundPlayer;
38 
39 class KviSoundThread : public KviThread
40 {
41 public:
42  KviSoundThread(const QString & szFileName);
43  virtual ~KviSoundThread();
44 
45 protected:
47  QString m_szFileName;
48 
49 public:
50  void terminate();
51 
52 protected:
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
59 class KviOssSoundThread : public KviSoundThread
60 {
61 public:
62  KviOssSoundThread(const QString & szFileName);
63  virtual ~KviOssSoundThread();
64 
65 protected:
66  virtual void play();
67 };
68 
69 #ifdef COMPILE_AUDIOFILE_SUPPORT
70 class KviOssAudiofileSoundThread : public KviSoundThread
71 {
72 public:
73  KviOssAudiofileSoundThread(const QString & szFileName);
74  virtual ~KviOssAudiofileSoundThread();
75 
76 protected:
77  virtual void play();
78 };
79 #endif //COMPILE_AUDIOFILE_SUPPORT
80 #endif //COMPILE_OSS_SUPPORT
81 
82 #ifdef COMPILE_ESD_SUPPORT
83 class KviEsdSoundThread : public KviSoundThread
84 {
85 public:
86  KviEsdSoundThread(const QString & szFileName);
87  virtual ~KviEsdSoundThread();
88 
89 protected:
90  virtual void play();
91 };
92 #endif //COMPILE_ESD_SUPPORT
93 
94 #ifdef COMPILE_ARTS_SUPPORT
95 class KviArtsSoundThread : public KviSoundThread
96 {
97 public:
98  KviArtsSoundThread(const QString & szFileName);
99  virtual ~KviArtsSoundThread();
100 
101 protected:
102  virtual void play();
103 };
104 #endif //COMPILE_ARTS_SUPPORT
105 #endif
106 
107 #ifdef COMPILE_PHONON_SUPPORT
108 namespace Phonon
109 {
110  class MediaObject;
111 }
112 #endif
113 
114 typedef bool (KviSoundPlayer::*SoundSystemPlayRoutine)(const QString & szFileName);
116 
118 {
119 private:
122 
123 public:
125  : m_pPlayRoutine(pPlayRoutine), m_pCleanupRoutine(pCleanupRoutine)
126  {
127  }
128 
130  {
131  return m_pPlayRoutine;
132  }
133 
135  {
136  return m_pCleanupRoutine;
137  }
138 };
139 
140 class KviSoundPlayer : public QObject
141 {
142  friend class KviSoundThread;
143  Q_OBJECT
144 public:
145  KviSoundPlayer();
146  virtual ~KviSoundPlayer();
147 
148 public:
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 
162 protected:
165 #ifdef COMPILE_PHONON_SUPPORT
166  Phonon::MediaObject * m_pPhononPlayer;
167 #endif
168  KviSoundPlayerEntry * m_pLastUsedSoundPlayerEntry;
169 
170 protected:
173  virtual bool event(QEvent * e);
174 
175 protected:
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_
KviPointerHashTable< QString, KviSoundPlayerEntry > * m_pSoundSystemDict
Definition: libkvisnd.h:164
void cleanupQt()
Definition: libkvisnd.cpp:364
SoundSystemCleanupRoutine cleanupRoutine() const
Definition: libkvisnd.h:134
SoundSystemPlayRoutine playRoutine() const
Definition: libkvisnd.h:129
void registerSoundThread(KviSoundThread *t)
Definition: libkvisnd.cpp:188
virtual bool event(QEvent *e)
Definition: libkvisnd.cpp:198
#define l
Definition: detector.cpp:76
#define KVI_OPTION_BOOL(_idx)
Definition: KviOptions.h:653
Definition: libkvisnd.h:39
Definition: libkvisnd.h:117
void cleanupNull()
Definition: libkvisnd.cpp:376
bool(KviSoundPlayer::* SoundSystemPlayRoutine)(const QString &szFileName)
COMPILE_ON_WINDOWS.
Definition: libkvisnd.h:114
#define e
Definition: detector.cpp:69
virtual ~KviSoundThread()
Definition: libkvisnd.cpp:426
void unregisterSoundThread(KviSoundThread *t)
Definition: libkvisnd.cpp:193
virtual ~KviSoundPlayer()
Definition: libkvisnd.cpp:123
Pointer Hash Table.
void detectSoundSystem()
Definition: libkvisnd.cpp:211
virtual void play()
Definition: libkvisnd.cpp:437
void(KviSoundPlayer::* SoundSystemCleanupRoutine)()
Definition: libkvisnd.h:115
Definition: KviThread.h:182
KviSoundThread(const QString &szFileName)
Definition: libkvisnd.cpp:418
bool isMuted()
Definition: libkvisnd.h:153
bool playNull(const QString &szFileName)
Definition: libkvisnd.cpp:370
void setMuted(bool muted)
Definition: libkvisnd.h:157
void cleanupAfterLastPlayerEntry()
Definition: libkvisnd.cpp:154
KviSoundPlayer()
Definition: libkvisnd.cpp:83
#define KviOption_boolMuteAllSounds
Definition: KviOptions.h:299
KviPointerList< KviSoundThread > * m_pThreadList
Definition: libkvisnd.h:163
QHashIterator< int, QFile * > t(getDict)
C++ Template based double linked pointer list class.
virtual void run()
Definition: libkvisnd.cpp:441
bool play(const QString &szFileName)
Definition: libkvisnd.cpp:380
void getAvailableSoundSystems(QStringList *l)
Definition: libkvisnd.cpp:165
QString m_szFileName
Definition: libkvisnd.h:47
SoundSystemPlayRoutine m_pPlayRoutine
Definition: libkvisnd.h:120
KviSoundPlayerEntry(SoundSystemPlayRoutine pPlayRoutine, SoundSystemCleanupRoutine pCleanupRoutine)
Definition: libkvisnd.h:124
bool m_bTerminate
Definition: libkvisnd.h:46
bool havePlayingSounds()
Definition: libkvisnd.cpp:175
SoundSystemCleanupRoutine m_pCleanupRoutine
Definition: libkvisnd.h:121
Definition: libkvisnd.h:140
This file contains compile time settings.
void stopAllSoundThreads()
Definition: libkvisnd.cpp:143
void terminate()
Definition: libkvisnd.cpp:432