This is a temporary commit to save WIP done on this topic.

Development of this feature will only resume after the release of R14.1.0.
Relates to bug 3159.

NOTE: this commit needs to be completed/reworked. It should not be
merged to master as is.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
feat/kmix/mixer-detection
Michele Calgaro 4 years ago
parent f0e311f71b
commit 00105125e3
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -26,7 +26,7 @@
KMixApp::KMixApp() KMixApp::KMixApp()
: KUniqueApplication(), m_kmix( 0 ) : KUniqueApplication(), m_kmix(NULL), m_updateMixersTimer(NULL)
{ {
// We handle autostart via standard autostart-enabled .desktop file instead of the session manager // We handle autostart via standard autostart-enabled .desktop file instead of the session manager
disableSessionManagement(); disableSessionManagement();
@ -35,6 +35,10 @@ KMixApp::KMixApp()
KMixApp::~KMixApp() KMixApp::~KMixApp()
{ {
if (m_updateMixersTimer)
{
delete m_updateMixersTimer;
}
if (m_kmix) if (m_kmix)
{ {
delete m_kmix; delete m_kmix;
@ -52,6 +56,9 @@ KMixApp::newInstance()
else else
{ {
m_kmix = new KMixWindow; m_kmix = new KMixWindow;
m_updateMixersTimer = new TQTimer();
connect(m_updateMixersTimer, TQT_SIGNAL(timeout()), m_kmix, TQT_SLOT(updateMixers()));
m_updateMixersTimer->start(5000);
connect(this, TQT_SIGNAL(stopUpdatesOnVisibility()), m_kmix, TQT_SLOT(stopVisibilityUpdates())); connect(this, TQT_SIGNAL(stopUpdatesOnVisibility()), m_kmix, TQT_SLOT(stopVisibilityUpdates()));
if ( isRestored() && TDEMainWindow::canBeRestored(0) ) if ( isRestored() && TDEMainWindow::canBeRestored(0) )
{ {

@ -2,6 +2,7 @@
#define KMixApp_h #define KMixApp_h
#include <kuniqueapplication.h> #include <kuniqueapplication.h>
#include <tqtimer.h>
class KMixWindow; class KMixWindow;
@ -22,6 +23,7 @@ Q_OBJECT
private: private:
KMixWindow *m_kmix; KMixWindow *m_kmix;
TQTimer *m_updateMixersTimer;
}; };
#endif #endif

@ -20,8 +20,6 @@
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
/* This code is being #include'd from mixer.cpp */
#ifndef KMIX_PLATFORMS_CPP #ifndef KMIX_PLATFORMS_CPP
#define KMIX_PLATFORMS_CPP #define KMIX_PLATFORMS_CPP

@ -546,8 +546,16 @@ void KMixWindow::stopVisibilityUpdates()
m_visibilityUpdateAllowed = false; m_visibilityUpdateAllowed = false;
} }
void void KMixWindow::updateMixers()
KMixWindow::slotHWInfo() { {
tqWarning("MIKE <KMixWindow> update mixers ENTER");
if (MixerToolBox::updateMixer(Mixer::mixers(), m_multiDriverMode, m_hwInfoString))
{
initMixerWidgets();
}
}
void KMixWindow::slotHWInfo() {
KMessageBox::information( 0, m_hwInfoString, i18n("Mixer Hardware Information") ); KMessageBox::information( 0, m_hwInfoString, i18n("Mixer Hardware Information") );
} }

@ -109,6 +109,7 @@ KMixWindow : public TDEMainWindow, virtual public KMixIface
void saveVolumes(); void saveVolumes();
virtual void applyPrefs( KMixPrefDlg *prefDlg ); virtual void applyPrefs( KMixPrefDlg *prefDlg );
void stopVisibilityUpdates(); void stopVisibilityUpdates();
void updateMixers();
private: private:
TDEAccel *m_keyAccel; TDEAccel *m_keyAccel;

@ -249,7 +249,6 @@ void MixerToolBox::initMixer(TQPtrList<Mixer> &mixers, bool multiDriverMode, TQS
} }
/* /*
* Clean up and free all resources of all found Mixers, which were found in the initMixer() call * Clean up and free all resources of all found Mixers, which were found in the initMixer() call
*/ */
@ -278,10 +277,6 @@ void MixerToolBox::deinitMixer(TQPtrList<Mixer> &mixers)
// kdDebug(67100) << "OUT MixerToolBox::deinitMixer(TQPtrList<Mixer> &mixers)" << endl; // kdDebug(67100) << "OUT MixerToolBox::deinitMixer(TQPtrList<Mixer> &mixers)" << endl;
} }
/**
* Clean up and free all resources of the given mixers
* @par mixers The list of mixers to deinitialize.
*/
/** /**
* Scan for Mixers in the System and update the given list. No longer existing mixers * Scan for Mixers in the System and update the given list. No longer existing mixers
* will be deinitialized. * will be deinitialized.
@ -291,12 +286,15 @@ void MixerToolBox::deinitMixer(TQPtrList<Mixer> &mixers)
* @par multiDriverMode Whether the Mixer scan should try more all backendends. * @par multiDriverMode Whether the Mixer scan should try more all backendends.
* 'true' means to scan all backends. 'false' means: After scanning the * 'true' means to scan all backends. 'false' means: After scanning the
* current backend the next backend is only scanned if no Mixers were found yet. * current backend the next backend is only scanned if no Mixers were found yet.
* @return true if any change in the mixers list has been detected.
*/ */
void MixerToolBox::updateMixer(TQPtrList<Mixer> &mixers, bool multiDriverMode, TQString& ref_hwInfoString) bool MixerToolBox::updateMixer(TQPtrList<Mixer> &mixers, bool multiDriverMode, TQString& ref_hwInfoString)
{ {
bool changesDetected = false;
TQPtrList<Mixer> newMixers; TQPtrList<Mixer> newMixers;
// Scan for new mixers // Scan for new mixers
initMixer(newMixers, multiDriverMode, ref_hwInfoString); initMixer(newMixers, multiDriverMode, ref_hwInfoString);
tqWarning("MIKE <updateMixer> OLD mixer=%d NEW=%d",mixers.count(),newMixers.count());
// Remove no longer existing mixers // Remove no longer existing mixers
TQPtrList<Mixer> mixersToDeinit; TQPtrList<Mixer> mixersToDeinit;
Mixer *searchMixer = NULL; Mixer *searchMixer = NULL;
@ -314,13 +312,16 @@ void MixerToolBox::updateMixer(TQPtrList<Mixer> &mixers, bool multiDriverMode, T
} }
if (!searchMixer) if (!searchMixer)
{ {
changesDetected = true;
mixers.take(); mixers.take();
mixersToDeinit.append(currMixer); mixersToDeinit.append(currMixer);
tqWarning("MIKE <updateMixer> remove mixer=("+currMixer->id()+")="+currMixer->mixerName());
} }
currMixer = mixers.next(); currMixer = mixers.next();
} }
deinitMixer(mixersToDeinit); deinitMixer(mixersToDeinit);
// Add newly found mixers // Add newly found mixers
int insertLocation = 0;
searchMixer = newMixers.first(); searchMixer = newMixers.first();
while (searchMixer) while (searchMixer)
{ {
@ -336,11 +337,16 @@ void MixerToolBox::updateMixer(TQPtrList<Mixer> &mixers, bool multiDriverMode, T
if (!currMixer) if (!currMixer)
{ {
// New mixer, append to existing list // New mixer, append to existing list
changesDetected = true;
newMixers.take(); newMixers.take();
mixers.append(searchMixer); mixers.insert(insertLocation, searchMixer);
tqWarning("MIKE <updateMixer> add new mixer=("+searchMixer->id()+")="+searchMixer->mixerName());
} }
searchMixer = newMixers.next(); searchMixer = newMixers.next();
++insertLocation;
} }
// Deallocate duplicated mixers // Deallocate duplicated mixers
deinitMixer(newMixers); deinitMixer(newMixers);
return changesDetected;
} }

@ -12,12 +12,13 @@ class Mixer;
* The reason, why it is not put in a common base class is, that the classes are * The reason, why it is not put in a common base class is, that the classes are
* very different and cannot be changed (e.g. KPanelApplet) without major headache. * very different and cannot be changed (e.g. KPanelApplet) without major headache.
*/ */
class MixerToolBox { class MixerToolBox
{
public: public:
static void initMixer(TQPtrList<Mixer> &mixers, bool multiDriverMode, TQString& ref_hwInfoString); static void initMixer(TQPtrList<Mixer> &mixers, bool multiDriverMode, TQString& ref_hwInfoString);
static void deinitMixer(); static void deinitMixer();
static void deinitMixer(TQPtrList<Mixer>&); static void deinitMixer(TQPtrList<Mixer>&);
static void updateMixer(TQPtrList<Mixer> &mixers, bool multiDriverMode, TQString& ref_hwInfoString); static bool updateMixer(TQPtrList<Mixer> &mixers, bool multiDriverMode, TQString& ref_hwInfoString);
}; };

Loading…
Cancel
Save