|
|
|
@ -6,6 +6,7 @@
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 Helio Chissini de Castro <helio@conectiva.com.br>
|
|
|
|
|
* 2004 Christian Esken <esken@kde.org>
|
|
|
|
|
* Copyright (C) 2020 Roman Savochenko <roman@oscada.org>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
@ -107,11 +108,7 @@ Mixer_ALSA::open()
|
|
|
|
|
|
|
|
|
|
snd_ctl_t *ctl_handle;
|
|
|
|
|
snd_ctl_card_info_t *hw_info;
|
|
|
|
|
snd_ctl_card_info_alloca(&hw_info);
|
|
|
|
|
|
|
|
|
|
snd_mixer_elem_t *elem;
|
|
|
|
|
snd_mixer_selem_id_t *sid;
|
|
|
|
|
snd_mixer_selem_id_alloca( &sid );
|
|
|
|
|
snd_ctl_card_info_malloc(&hw_info);
|
|
|
|
|
|
|
|
|
|
// Card information
|
|
|
|
|
if ((unsigned)m_devnum > 31) m_devnum = -1;
|
|
|
|
@ -126,6 +123,7 @@ Mixer_ALSA::open()
|
|
|
|
|
{
|
|
|
|
|
kdDebug(67100) << probeMessage << "not found: snd_ctl_open err=" << snd_strerror(err) << endl;
|
|
|
|
|
//_stateMessage = errorText( Mixer::ERR_NODEV );
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_OPEN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -134,6 +132,7 @@ Mixer_ALSA::open()
|
|
|
|
|
kdDebug(67100) << probeMessage << "not found: snd_ctl_card_info err=" << snd_strerror(err) << endl;
|
|
|
|
|
//_stateMessage = errorText( Mixer::ERR_READ );
|
|
|
|
|
snd_ctl_close( ctl_handle );
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_READ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -155,6 +154,7 @@ Mixer_ALSA::open()
|
|
|
|
|
kdDebug(67100) << probeMessage << "not found: snd_mixer_open err=" << snd_strerror(err) << endl;
|
|
|
|
|
//errormsg( Mixer::ERR_NODEV );
|
|
|
|
|
_handle = 0;
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_NODEV; // if we cannot open the mixer, we have no devices
|
|
|
|
|
}
|
|
|
|
|
//kdDebug(67100) << "OUT Mixer_ALSA snd_mixer_open()" << endl;
|
|
|
|
@ -163,6 +163,8 @@ Mixer_ALSA::open()
|
|
|
|
|
{
|
|
|
|
|
kdDebug(67100) << probeMessage << "not found: snd_mixer_attach err=" << snd_strerror(err) << endl;
|
|
|
|
|
//errormsg( Mixer::ERR_PERM );
|
|
|
|
|
close();
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_OPEN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -170,6 +172,8 @@ Mixer_ALSA::open()
|
|
|
|
|
{
|
|
|
|
|
kdDebug(67100) << probeMessage << "not found: snd_mixer_selem_register err=" << snd_strerror(err) << endl;
|
|
|
|
|
//errormsg( Mixer::ERR_READ );
|
|
|
|
|
close();
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_READ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -178,11 +182,15 @@ Mixer_ALSA::open()
|
|
|
|
|
kdDebug(67100) << probeMessage << "not found: snd_mixer_load err=" << snd_strerror(err) << endl;
|
|
|
|
|
//errormsg( Mixer::ERR_READ );
|
|
|
|
|
close();
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_READ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kdDebug(67100) << probeMessage << "found" << endl;
|
|
|
|
|
|
|
|
|
|
snd_mixer_elem_t *elem;
|
|
|
|
|
snd_mixer_selem_id_t *sid;
|
|
|
|
|
|
|
|
|
|
unsigned int mixerIdx = 0;
|
|
|
|
|
for ( elem = snd_mixer_first_elem( _handle ); elem; elem = snd_mixer_elem_next( elem ), mixerIdx++ )
|
|
|
|
|
{
|
|
|
|
@ -195,8 +203,7 @@ Mixer_ALSA::open()
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sid = (snd_mixer_selem_id_t*)malloc(snd_mixer_selem_id_sizeof()); // I believe *we* must malloc it for ourself
|
|
|
|
|
snd_mixer_selem_id_malloc( &sid );
|
|
|
|
|
snd_mixer_selem_get_id( elem, sid );
|
|
|
|
|
|
|
|
|
|
bool canPlay = false;
|
|
|
|
@ -359,6 +366,8 @@ Mixer_ALSA::open()
|
|
|
|
|
}
|
|
|
|
|
if( !found )
|
|
|
|
|
{
|
|
|
|
|
close();
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_INCOMPATIBLESET;
|
|
|
|
|
}
|
|
|
|
|
} // !virginOpen
|
|
|
|
@ -372,6 +381,8 @@ Mixer_ALSA::open()
|
|
|
|
|
***************************************************************************************/
|
|
|
|
|
if ( !validDevice )
|
|
|
|
|
{
|
|
|
|
|
close();
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_NODEV;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -385,6 +396,8 @@ Mixer_ALSA::open()
|
|
|
|
|
/* setup for select on stdin and the mixer fd */
|
|
|
|
|
if ((m_count = snd_mixer_poll_descriptors_count(_handle)) < 0) {
|
|
|
|
|
kdDebug(67100) << "Mixer_ALSA::poll() , snd_mixer_poll_descriptors_count() err=" << m_count << "\n";
|
|
|
|
|
close();
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_OPEN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -393,19 +406,27 @@ Mixer_ALSA::open()
|
|
|
|
|
m_fds = (struct pollfd*)calloc(m_count, sizeof(struct pollfd));
|
|
|
|
|
if (m_fds == NULL) {
|
|
|
|
|
kdDebug(67100) << "Mixer_ALSA::poll() , calloc() = null" << "\n";
|
|
|
|
|
close();
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_OPEN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_fds->events = POLLIN;
|
|
|
|
|
if ((err = snd_mixer_poll_descriptors(_handle, m_fds, m_count)) < 0) {
|
|
|
|
|
kdDebug(67100) << "Mixer_ALSA::poll() , snd_mixer_poll_descriptors_count() err=" << err << "\n";
|
|
|
|
|
close();
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_OPEN;
|
|
|
|
|
}
|
|
|
|
|
if (err != m_count) {
|
|
|
|
|
kdDebug(67100) << "Mixer_ALSA::poll() , snd_mixer_poll_descriptors_count() err=" << err << " m_count=" << m_count << "\n";
|
|
|
|
|
close();
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
return Mixer::ERR_OPEN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snd_ctl_card_info_free(hw_info);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -462,6 +483,10 @@ Mixer_ALSA::close()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int iMS = 0; iMS < mixer_sid_list.count(); iMS++)
|
|
|
|
|
if(mixer_sid_list[iMS])
|
|
|
|
|
snd_mixer_selem_id_free(mixer_sid_list[iMS]);
|
|
|
|
|
|
|
|
|
|
mixer_elem_list.clear();
|
|
|
|
|
mixer_sid_list.clear();
|
|
|
|
|
m_mixDevices.clear();
|
|
|
|
|