View | Details | Raw Unified | Return to bug 15259
Collapse All | Expand All

(-)a/kmix/kmix-platforms.cpp (-8 / +10 lines)
Lines 109-150 Link Here
109
109
110
typedef Mixer_Backend *getMixerFunc( int device );
110
typedef Mixer_Backend *getMixerFunc( int device );
111
typedef QString getDriverNameFunc( );
111
typedef QString getDriverNameFunc( );
112
typedef DevIterator* getDevIteratorFunc( );
112
113
113
struct MixerFactory {
114
struct MixerFactory {
114
    getMixerFunc *getMixer;
115
    getMixerFunc *getMixer;
115
    getDriverNameFunc *getDriverName;
116
    getDriverNameFunc *getDriverName;
117
    getDevIteratorFunc *getDevIterator;
116
};
118
};
117
119
118
MixerFactory g_mixerFactories[] = {
120
MixerFactory g_mixerFactories[] = {
119
121
120
#if defined(NAS_MIXER)
122
#if defined(NAS_MIXER)
121
    { NAS_getMixer, 0 },
123
    { NAS_getMixer, NULL, NULL },
122
#endif
124
#endif
123
125
124
#if defined(SUN_MIXER)
126
#if defined(SUN_MIXER)
125
    { SUN_getMixer, SUN_getDriverName },
127
    { SUN_getMixer, SUN_getDriverName, NULL },
126
#endif
128
#endif
127
129
128
#if defined(IRIX_MIXER)
130
#if defined(IRIX_MIXER)
129
    { IRIX_getMixer, IRIX_getDriverName },
131
    { IRIX_getMixer, IRIX_getDriverName, NULL },
130
#endif
132
#endif
131
133
132
#if defined(ALSA_MIXER)
134
#if defined(ALSA_MIXER)
133
    { ALSA_getMixer, ALSA_getDriverName },
135
    { ALSA_getMixer, ALSA_getDriverName, ALSA_getDevIterator },
134
#endif
136
#endif
135
137
136
#if defined(OSS4_MIXER)
138
#if defined(OSS4_MIXER)
137
    { OSS4_getMixer, OSS4_getDriverName },
139
    { OSS4_getMixer, OSS4_getDriverName, NULL },
138
#endif
140
#endif
139
141
140
#if defined(OSS_MIXER)
142
#if defined(OSS_MIXER)
141
    { OSS_getMixer, OSS_getDriverName },
143
    { OSS_getMixer, OSS_getDriverName, NULL },
142
#endif
144
#endif
143
145
144
#if defined(HPUX_MIXER)
146
#if defined(HPUX_MIXER)
145
    { HPUX_getMixer, HPUX_getDriverName },
147
    { HPUX_getMixer, HPUX_getDriverName, NULL },
146
#endif
148
#endif
147
149
148
    { 0, 0 }
150
    { NULL, NULL, NULL }
149
};
151
};
150
152
(-)a/kmix/mixer.cpp (+5 lines)
Lines 347-352 QString Mixer::mixerName() Link Here
347
  return _mixerBackend->m_mixerName;
347
  return _mixerBackend->m_mixerName;
348
}
348
}
349
349
350
int Mixer::devnum()
351
{
352
  return _mixerBackend->m_devnum;
353
}
354
350
QString Mixer::driverName( int driver )
355
QString Mixer::driverName( int driver )
351
{
356
{
352
    getDriverNameFunc *f = g_mixerFactories[driver].getDriverName;
357
    getDriverNameFunc *f = g_mixerFactories[driver].getDriverName;
(-)a/kmix/mixer.h (+1 lines)
Lines 82-87 class Mixer : public QObject, virtual public MixerIface Link Here
82
      QString& stateMessage() const;
82
      QString& stateMessage() const;
83
83
84
      virtual QString mixerName();
84
      virtual QString mixerName();
85
      virtual int devnum();
85
86
86
      // Returns the name of the driver, e.g. "OSS" or "ALSA0.9"
87
      // Returns the name of the driver, e.g. "OSS" or "ALSA0.9"
87
      static QString driverName(int num);
88
      static QString driverName(int num);
(-)a/kmix/mixer_alsa.h (+7 lines)
Lines 50-53 class Mixer_ALSA : public Mixer_Backend Link Here
50
50
51
};
51
};
52
52
53
class ALSA_DevIterator : public DevIterator
54
{
55
	public:
56
		ALSA_DevIterator();
57
		virtual void next();
58
};
59
53
#endif
60
#endif
(-)a/kmix/mixer_alsa9.cpp (-6 / +24 lines)
Lines 114-125 Mixer_ALSA::open() Link Here
114
    snd_mixer_selem_id_alloca( &sid );
114
    snd_mixer_selem_id_alloca( &sid );
115
115
116
    // Card information
116
    // Card information
117
    if( m_devnum == -1 )
117
    if ((unsigned)m_devnum > 31) m_devnum = -1;
118
        m_devnum = 0;
118
    devName = m_devnum == -1 ? "default" : QString("hw:%1").arg(m_devnum);
119
    if ( (unsigned)m_devnum > 31 )
120
	devName = "default";
121
    else
122
	devName = QString( "hw:%1" ).arg( m_devnum );
123
119
124
    QString probeMessage;
120
    QString probeMessage;
125
121
Lines 146-151 Mixer_ALSA::open() Link Here
146
    //mixer_device_name = snd_ctl_card_info_get_mixername( hw_info );
142
    //mixer_device_name = snd_ctl_card_info_get_mixername( hw_info );
147
    // Copy the name of kmix mixer from card name (mixername is rumoured to be not that good)
143
    // Copy the name of kmix mixer from card name (mixername is rumoured to be not that good)
148
    m_mixerName = mixer_card_name;
144
    m_mixerName = mixer_card_name;
145
    if (m_devnum == -1) m_devnum = snd_card_get_index(snd_ctl_card_info_get_id(hw_info));
146
    if (m_devnum < 0) m_devnum = -1;
149
147
150
    snd_ctl_close( ctl_handle );
148
    snd_ctl_close( ctl_handle );
151
149
Lines 826-828 ALSA_getDriverName() Link Here
826
}
824
}
827
825
828
826
827
ALSA_DevIterator::ALSA_DevIterator()
828
{
829
	N = -1;
830
	NMax = 31;
831
}
832
833
void ALSA_DevIterator::next()
834
{
835
#if 0
836
	int rc = snd_card_next(&N);
837
	if (rc || (N == -1)) N = NMax + 1;
838
#else
839
	if ((snd_card_next(&N) != 0) || (N == -1)) N = NMax + 1;
840
#endif
841
}
842
843
DevIterator* ALSA_getDevIterator()
844
{
845
	return new ALSA_DevIterator();
846
}
(-)a/kmix/mixer_backend.cpp (+25 lines)
Lines 145-147 QString Mixer_Backend::errorText(int mixer_error) Link Here
145
  return l_s_errmsg;
145
  return l_s_errmsg;
146
}
146
}
147
147
148
149
DevIterator::DevIterator()
150
{
151
  N = 0;
152
  NMax = 19;
153
}
154
155
void DevIterator::next()
156
{
157
  N++;
158
}
159
160
int DevIterator::getdev()
161
{
162
  return N;
163
}
164
165
bool DevIterator::end()
166
{
167
  return N > NMax;
168
}
169
170
DevIterator::~DevIterator()
171
{
172
}
(-)a/kmix/mixer_backend.h (+12 lines)
Lines 101-104 protected: Link Here
101
  MixDevice* m_recommendedMaster;
101
  MixDevice* m_recommendedMaster;
102
};
102
};
103
103
104
class DevIterator
105
{
106
public:
107
    DevIterator();
108
    virtual ~DevIterator();
109
    virtual void next();
110
    virtual int getdev();
111
    virtual bool end();
112
protected:
113
    int N, NMax;
114
};
115
104
#endif
116
#endif
(-)a/kmix/mixer_oss.cpp (-1 / +1 lines)
Lines 133-139 int Mixer_OSS::open() Link Here
133
                  readVolumeFromHW( idx, vol );
133
                  readVolumeFromHW( idx, vol );
134
                  MixDevice* md =
134
                  MixDevice* md =
135
                    new MixDevice( idx, vol, recmask & ( 1 << idx ), true,
135
                    new MixDevice( idx, vol, recmask & ( 1 << idx ), true,
136
                                   i18n(MixerDevNames[idx]),
136
                                   MixerDevNames[idx],
137
                                   MixerChannelTypes[idx]);
137
                                   MixerChannelTypes[idx]);
138
                  md->setRecSource( isRecsrcHW( idx ) );
138
                  md->setRecSource( isRecsrcHW( idx ) );
139
                  m_mixDevices.append( md );
139
                  m_mixDevices.append( md );
(-)a/kmix/mixertoolbox.cpp (-1 / +15 lines)
Lines 99-109 void MixerToolBox::initMixer(QPtrList<Mixer> &mixers, bool multiDriverMode, QStr Link Here
99
	    // New: We don't try be that clever anymore. We now blindly scan 20 cards, as the clever
99
	    // New: We don't try be that clever anymore. We now blindly scan 20 cards, as the clever
100
	    // approach doesn't work for the one or other user.
100
	    // approach doesn't work for the one or other user.
101
	    int devNumMax = 19;
101
	    int devNumMax = 19;
102
	    for( int dev=0; dev<=devNumMax; dev++ )
102
	    getDevIteratorFunc* f = g_mixerFactories[drv].getDevIterator;
103
	    for( DevIterator* I = f ? f() : new DevIterator(); !I->end(); I->next())
103
	    {
104
	    {
105
		int dev = I->getdev();
104
		Mixer *mixer = new Mixer( drv, dev );
106
		Mixer *mixer = new Mixer( drv, dev );
105
		if ( mixer->isValid() ) {
107
		if ( mixer->isValid() ) {
106
			mixer->open();
108
			mixer->open();
109
			Mixer* m;
110
			if (dev >= 0) {
111
				for (m = mixers.first(); m; m = mixers.next())
112
#if 0
113
					if ((mixer->devnum() == m->devnum()) &&
114
					    m->id().startsWith(mixer->driverName(drv) + "::", true))
115
#else
116
					if (mixer->devnum() == m->devnum())
117
#endif
118
						break;
119
				if (m) continue;
120
			}
107
			mixers.append( mixer );
121
			mixers.append( mixer );
108
			// Count mixer nums for every mixer name to identify mixers with equal names.
122
			// Count mixer nums for every mixer name to identify mixers with equal names.
109
			// This is for creating persistent (reusable) primary keys, which can safely
123
			// This is for creating persistent (reusable) primary keys, which can safely

Return to bug 15259