KVIrc 5.2.6
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#endif
82
83#ifdef COMPILE_PHONON_SUPPORT
84namespace Phonon
85{
86 class MediaObject;
87}
88#endif
89
90#ifdef COMPILE_QTMULTIMEDIA_SUPPORT
91 class QMediaPlayer;
92#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
93 class QAudioOutput;
94#endif
95#endif
96
97typedef bool (KviSoundPlayer::*SoundSystemPlayRoutine)(const QString & szFileName);
99
101{
102private:
105
106public:
108 : m_pPlayRoutine(pPlayRoutine), m_pCleanupRoutine(pCleanupRoutine)
109 {
110 }
111
113 {
114 return m_pPlayRoutine;
115 }
116
121};
122
123class KviSoundPlayer : public QObject
124{
125 friend class KviSoundThread;
126 Q_OBJECT
127public:
129 virtual ~KviSoundPlayer();
130
131public:
132 bool play(const QString & szFileName);
133 bool detectSoundSystem(QString & szSoundSystem);
134 bool havePlayingSounds();
135 void getAvailableSoundSystems(QStringList * l);
136 bool isMuted()
137 {
139 }
140 void setMuted(bool muted)
141 {
143 }
144
145protected:
148#ifdef COMPILE_PHONON_SUPPORT
149 std::unique_ptr<Phonon::MediaObject> m_pPhononPlayer;
150#endif
151#ifdef COMPILE_QTMULTIMEDIA_SUPPORT
152 std::unique_ptr<QMediaPlayer> m_pMediaPlayer;
153#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
154 std::unique_ptr<QAudioOutput> m_pAudioOutput;
155#endif
156#endif
158
159protected:
162 bool event(QEvent * e) override;
163
164protected:
165 void stopAllSoundThreads();
167#ifdef COMPILE_PHONON_SUPPORT
168 bool playPhonon(const QString & szFileName);
169 void cleanupPhonon();
170#endif
171#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
172 bool playWinmm(const QString & szFileName);
173 void cleanupWinmm();
174#else
175#ifdef COMPILE_OSS_SUPPORT
176 bool playOss(const QString & szFileName);
177 void cleanupOss();
178#ifdef COMPILE_AUDIOFILE_SUPPORT
179 bool playOssAudiofile(const QString & szFileName);
180 void cleanupOssAudiofile();
181#endif //COMPILE_AUDIOFILE_SUPPORT
182#endif //COMPILE_OSS_SUPPORT
183#endif
184#ifdef COMPILE_QTMULTIMEDIA_SUPPORT
185 bool playQt(const QString & szFileName);
186 void cleanupQt();
187#endif
188 bool playNull(const QString & szFileName);
189 void cleanupNull();
190};
191
192#endif // _KVISND_H_
#define KviOption_boolMuteAllSounds
Definition KviOptions.h:301
#define KVI_OPTION_BOOL(_idx)
Definition KviOptions.h:661
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:101
KviSoundPlayerEntry(SoundSystemPlayRoutine pPlayRoutine, SoundSystemCleanupRoutine pCleanupRoutine)
Definition libkvisnd.h:107
SoundSystemPlayRoutine m_pPlayRoutine
Definition libkvisnd.h:103
SoundSystemCleanupRoutine cleanupRoutine() const
Definition libkvisnd.h:117
SoundSystemPlayRoutine playRoutine() const
Definition libkvisnd.h:112
SoundSystemCleanupRoutine m_pCleanupRoutine
Definition libkvisnd.h:104
Definition libkvisnd.h:124
bool havePlayingSounds()
Definition libkvisnd.cpp:165
void unregisterSoundThread(KviSoundThread *t)
Definition libkvisnd.cpp:194
void setMuted(bool muted)
Definition libkvisnd.h:140
void cleanupAfterLastPlayerEntry()
Definition libkvisnd.cpp:144
void getAvailableSoundSystems(QStringList *l)
Definition libkvisnd.cpp:155
KviPointerList< KviSoundThread > * m_pThreadList
Definition libkvisnd.h:146
bool event(QEvent *e) override
Definition libkvisnd.cpp:199
void stopAllSoundThreads()
Definition libkvisnd.cpp:133
KviSoundPlayerEntry * m_pLastUsedSoundPlayerEntry
COMPILE_PHONON_SUPPORT.
Definition libkvisnd.h:157
virtual ~KviSoundPlayer()
Definition libkvisnd.cpp:118
bool play(const QString &szFileName)
Definition libkvisnd.cpp:368
void registerSoundThread(KviSoundThread *t)
Definition libkvisnd.cpp:189
KviPointerHashTable< QString, KviSoundPlayerEntry > * m_pSoundSystemDict
Definition libkvisnd.h:147
bool detectSoundSystem(QString &szSoundSystem)
Definition libkvisnd.cpp:212
void cleanupNull()
Definition libkvisnd.cpp:364
bool isMuted()
Definition libkvisnd.h:136
KviSoundPlayer()
Definition libkvisnd.cpp:84
bool playNull(const QString &szFileName)
COMPILE_PHONON_SUPPORT.
Definition libkvisnd.cpp:358
Definition libkvisnd.h:40
virtual void run()
Definition libkvisnd.cpp:436
virtual ~KviSoundThread()
Definition libkvisnd.cpp:421
bool m_bTerminate
Definition libkvisnd.h:46
KviSoundThread(const QString &szFileName)
Definition libkvisnd.cpp:413
void terminate()
Definition libkvisnd.cpp:427
QString m_szFileName
Definition libkvisnd.h:47
virtual void play()
Definition libkvisnd.cpp:432
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:98
bool(KviSoundPlayer::* SoundSystemPlayRoutine)(const QString &szFileName)
COMPILE_ON_WINDOWS.
Definition libkvisnd.h:97