|
Lines 6-11
Link Here
|
| 6 |
* |
6 |
* |
| 7 |
* Copyright (C) 2002 Helio Chissini de Castro <helio@conectiva.com.br> |
7 |
* Copyright (C) 2002 Helio Chissini de Castro <helio@conectiva.com.br> |
| 8 |
* 2004 Christian Esken <esken@kde.org> |
8 |
* 2004 Christian Esken <esken@kde.org> |
|
|
9 |
* Copyright (C) 2020 Roman Savochenko <roman@oscada.org> |
| 9 |
* |
10 |
* |
| 10 |
* This program is free software; you can redistribute it and/or |
11 |
* This program is free software; you can redistribute it and/or |
| 11 |
* modify it under the terms of the GNU Library General Public |
12 |
* modify it under the terms of the GNU Library General Public |
|
Lines 107-117
Link Here
|
| 107 |
|
108 |
|
| 108 |
snd_ctl_t *ctl_handle; |
109 |
snd_ctl_t *ctl_handle; |
| 109 |
snd_ctl_card_info_t *hw_info; |
110 |
snd_ctl_card_info_t *hw_info; |
| 110 |
snd_ctl_card_info_alloca(&hw_info); |
111 |
snd_ctl_card_info_malloc(&hw_info); |
| 111 |
|
|
|
| 112 |
snd_mixer_elem_t *elem; |
| 113 |
snd_mixer_selem_id_t *sid; |
| 114 |
snd_mixer_selem_id_alloca( &sid ); |
| 115 |
|
112 |
|
| 116 |
// Card information |
113 |
// Card information |
| 117 |
if ((unsigned)m_devnum > 31) m_devnum = -1; |
114 |
if ((unsigned)m_devnum > 31) m_devnum = -1; |
|
Lines 126-131
Link Here
|
| 126 |
{ |
123 |
{ |
| 127 |
kdDebug(67100) << probeMessage << "not found: snd_ctl_open err=" << snd_strerror(err) << endl; |
124 |
kdDebug(67100) << probeMessage << "not found: snd_ctl_open err=" << snd_strerror(err) << endl; |
| 128 |
//_stateMessage = errorText( Mixer::ERR_NODEV ); |
125 |
//_stateMessage = errorText( Mixer::ERR_NODEV ); |
|
|
126 |
snd_ctl_card_info_free(hw_info); |
| 129 |
return Mixer::ERR_OPEN; |
127 |
return Mixer::ERR_OPEN; |
| 130 |
} |
128 |
} |
| 131 |
|
129 |
|
|
Lines 134-139
Link Here
|
| 134 |
kdDebug(67100) << probeMessage << "not found: snd_ctl_card_info err=" << snd_strerror(err) << endl; |
132 |
kdDebug(67100) << probeMessage << "not found: snd_ctl_card_info err=" << snd_strerror(err) << endl; |
| 135 |
//_stateMessage = errorText( Mixer::ERR_READ ); |
133 |
//_stateMessage = errorText( Mixer::ERR_READ ); |
| 136 |
snd_ctl_close( ctl_handle ); |
134 |
snd_ctl_close( ctl_handle ); |
|
|
135 |
snd_ctl_card_info_free(hw_info); |
| 137 |
return Mixer::ERR_READ; |
136 |
return Mixer::ERR_READ; |
| 138 |
} |
137 |
} |
| 139 |
|
138 |
|
|
Lines 155-160
Link Here
|
| 155 |
kdDebug(67100) << probeMessage << "not found: snd_mixer_open err=" << snd_strerror(err) << endl; |
154 |
kdDebug(67100) << probeMessage << "not found: snd_mixer_open err=" << snd_strerror(err) << endl; |
| 156 |
//errormsg( Mixer::ERR_NODEV ); |
155 |
//errormsg( Mixer::ERR_NODEV ); |
| 157 |
_handle = 0; |
156 |
_handle = 0; |
|
|
157 |
snd_ctl_card_info_free(hw_info); |
| 158 |
return Mixer::ERR_NODEV; // if we cannot open the mixer, we have no devices |
158 |
return Mixer::ERR_NODEV; // if we cannot open the mixer, we have no devices |
| 159 |
} |
159 |
} |
| 160 |
//kdDebug(67100) << "OUT Mixer_ALSA snd_mixer_open()" << endl; |
160 |
//kdDebug(67100) << "OUT Mixer_ALSA snd_mixer_open()" << endl; |
|
Lines 163-168
Link Here
|
| 163 |
{ |
163 |
{ |
| 164 |
kdDebug(67100) << probeMessage << "not found: snd_mixer_attach err=" << snd_strerror(err) << endl; |
164 |
kdDebug(67100) << probeMessage << "not found: snd_mixer_attach err=" << snd_strerror(err) << endl; |
| 165 |
//errormsg( Mixer::ERR_PERM ); |
165 |
//errormsg( Mixer::ERR_PERM ); |
|
|
166 |
close(); |
| 167 |
snd_ctl_card_info_free(hw_info); |
| 166 |
return Mixer::ERR_OPEN; |
168 |
return Mixer::ERR_OPEN; |
| 167 |
} |
169 |
} |
| 168 |
|
170 |
|
|
Lines 170-175
Link Here
|
| 170 |
{ |
172 |
{ |
| 171 |
kdDebug(67100) << probeMessage << "not found: snd_mixer_selem_register err=" << snd_strerror(err) << endl; |
173 |
kdDebug(67100) << probeMessage << "not found: snd_mixer_selem_register err=" << snd_strerror(err) << endl; |
| 172 |
//errormsg( Mixer::ERR_READ ); |
174 |
//errormsg( Mixer::ERR_READ ); |
|
|
175 |
close(); |
| 176 |
snd_ctl_card_info_free(hw_info); |
| 173 |
return Mixer::ERR_READ; |
177 |
return Mixer::ERR_READ; |
| 174 |
} |
178 |
} |
| 175 |
|
179 |
|
|
Lines 178-188
Link Here
|
| 178 |
kdDebug(67100) << probeMessage << "not found: snd_mixer_load err=" << snd_strerror(err) << endl; |
182 |
kdDebug(67100) << probeMessage << "not found: snd_mixer_load err=" << snd_strerror(err) << endl; |
| 179 |
//errormsg( Mixer::ERR_READ ); |
183 |
//errormsg( Mixer::ERR_READ ); |
| 180 |
close(); |
184 |
close(); |
|
|
185 |
snd_ctl_card_info_free(hw_info); |
| 181 |
return Mixer::ERR_READ; |
186 |
return Mixer::ERR_READ; |
| 182 |
} |
187 |
} |
| 183 |
|
188 |
|
| 184 |
kdDebug(67100) << probeMessage << "found" << endl; |
189 |
kdDebug(67100) << probeMessage << "found" << endl; |
| 185 |
|
190 |
|
|
|
191 |
snd_mixer_elem_t *elem; |
| 192 |
snd_mixer_selem_id_t *sid; |
| 193 |
|
| 186 |
unsigned int mixerIdx = 0; |
194 |
unsigned int mixerIdx = 0; |
| 187 |
for ( elem = snd_mixer_first_elem( _handle ); elem; elem = snd_mixer_elem_next( elem ), mixerIdx++ ) |
195 |
for ( elem = snd_mixer_first_elem( _handle ); elem; elem = snd_mixer_elem_next( elem ), mixerIdx++ ) |
| 188 |
{ |
196 |
{ |
|
Lines 195-202
Link Here
|
| 195 |
continue; |
203 |
continue; |
| 196 |
} |
204 |
} |
| 197 |
|
205 |
|
| 198 |
|
206 |
snd_mixer_selem_id_malloc( &sid ); |
| 199 |
sid = (snd_mixer_selem_id_t*)malloc(snd_mixer_selem_id_sizeof()); // I believe *we* must malloc it for ourself |
|
|
| 200 |
snd_mixer_selem_get_id( elem, sid ); |
207 |
snd_mixer_selem_get_id( elem, sid ); |
| 201 |
|
208 |
|
| 202 |
bool canRecord = false; |
209 |
bool canRecord = false; |
|
Lines 346-351
Link Here
|
| 346 |
} |
353 |
} |
| 347 |
if( !found ) |
354 |
if( !found ) |
| 348 |
{ |
355 |
{ |
|
|
356 |
close(); |
| 357 |
snd_ctl_card_info_free(hw_info); |
| 349 |
return Mixer::ERR_INCOMPATIBLESET; |
358 |
return Mixer::ERR_INCOMPATIBLESET; |
| 350 |
} |
359 |
} |
| 351 |
} // !virginOpen |
360 |
} // !virginOpen |
|
Lines 359-364
Link Here
|
| 359 |
***************************************************************************************/ |
368 |
***************************************************************************************/ |
| 360 |
if ( !validDevice ) |
369 |
if ( !validDevice ) |
| 361 |
{ |
370 |
{ |
|
|
371 |
close(); |
| 372 |
snd_ctl_card_info_free(hw_info); |
| 362 |
return Mixer::ERR_NODEV; |
373 |
return Mixer::ERR_NODEV; |
| 363 |
} |
374 |
} |
| 364 |
|
375 |
|
|
Lines 372-377
Link Here
|
| 372 |
/* setup for select on stdin and the mixer fd */ |
383 |
/* setup for select on stdin and the mixer fd */ |
| 373 |
if ((m_count = snd_mixer_poll_descriptors_count(_handle)) < 0) { |
384 |
if ((m_count = snd_mixer_poll_descriptors_count(_handle)) < 0) { |
| 374 |
kdDebug(67100) << "Mixer_ALSA::poll() , snd_mixer_poll_descriptors_count() err=" << m_count << "\n"; |
385 |
kdDebug(67100) << "Mixer_ALSA::poll() , snd_mixer_poll_descriptors_count() err=" << m_count << "\n"; |
|
|
386 |
close(); |
| 387 |
snd_ctl_card_info_free(hw_info); |
| 375 |
return Mixer::ERR_OPEN; |
388 |
return Mixer::ERR_OPEN; |
| 376 |
} |
389 |
} |
| 377 |
|
390 |
|
|
Lines 380-398
Link Here
|
| 380 |
m_fds = (struct pollfd*)calloc(m_count, sizeof(struct pollfd)); |
393 |
m_fds = (struct pollfd*)calloc(m_count, sizeof(struct pollfd)); |
| 381 |
if (m_fds == NULL) { |
394 |
if (m_fds == NULL) { |
| 382 |
kdDebug(67100) << "Mixer_ALSA::poll() , calloc() = null" << "\n"; |
395 |
kdDebug(67100) << "Mixer_ALSA::poll() , calloc() = null" << "\n"; |
|
|
396 |
close(); |
| 397 |
snd_ctl_card_info_free(hw_info); |
| 383 |
return Mixer::ERR_OPEN; |
398 |
return Mixer::ERR_OPEN; |
| 384 |
} |
399 |
} |
| 385 |
|
400 |
|
| 386 |
m_fds->events = POLLIN; |
401 |
m_fds->events = POLLIN; |
| 387 |
if ((err = snd_mixer_poll_descriptors(_handle, m_fds, m_count)) < 0) { |
402 |
if ((err = snd_mixer_poll_descriptors(_handle, m_fds, m_count)) < 0) { |
| 388 |
kdDebug(67100) << "Mixer_ALSA::poll() , snd_mixer_poll_descriptors_count() err=" << err << "\n"; |
403 |
kdDebug(67100) << "Mixer_ALSA::poll() , snd_mixer_poll_descriptors_count() err=" << err << "\n"; |
|
|
404 |
close(); |
| 405 |
snd_ctl_card_info_free(hw_info); |
| 389 |
return Mixer::ERR_OPEN; |
406 |
return Mixer::ERR_OPEN; |
| 390 |
} |
407 |
} |
| 391 |
if (err != m_count) { |
408 |
if (err != m_count) { |
| 392 |
kdDebug(67100) << "Mixer_ALSA::poll() , snd_mixer_poll_descriptors_count() err=" << err << " m_count=" << m_count << "\n"; |
409 |
kdDebug(67100) << "Mixer_ALSA::poll() , snd_mixer_poll_descriptors_count() err=" << err << " m_count=" << m_count << "\n"; |
|
|
410 |
close(); |
| 411 |
snd_ctl_card_info_free(hw_info); |
| 393 |
return Mixer::ERR_OPEN; |
412 |
return Mixer::ERR_OPEN; |
| 394 |
} |
413 |
} |
| 395 |
|
414 |
|
|
|
415 |
snd_ctl_card_info_free(hw_info); |
| 416 |
|
| 396 |
return 0; |
417 |
return 0; |
| 397 |
} |
418 |
} |
| 398 |
|
419 |
|
|
Lines 449-454
Link Here
|
| 449 |
|
470 |
|
| 450 |
} |
471 |
} |
| 451 |
|
472 |
|
|
|
473 |
for(int iMS = 0; iMS < mixer_sid_list.count(); iMS++) |
| 474 |
if(mixer_sid_list[iMS]) |
| 475 |
snd_mixer_selem_id_free(mixer_sid_list[iMS]); |
| 476 |
|
| 452 |
mixer_elem_list.clear(); |
477 |
mixer_elem_list.clear(); |
| 453 |
mixer_sid_list.clear(); |
478 |
mixer_sid_list.clear(); |
| 454 |
m_mixDevices.clear(); |
479 |
m_mixDevices.clear(); |