2025-09-17 Fred Gleason <fredg@paravelsystems.com>

* Added a 'librdalsa' convenience library in 'rdalsa/'.
	* Moved the 'RDAlsaCard' class from 'utils/rdalsaconfig/' to
	'rdalsa/' to contain ALSA card quirk information.
	* Refactored the ALSA driver in caed(8) to use 'RDAlsaCard'.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2025-09-17 17:17:09 -04:00
parent 1d608b5321
commit e5340cfce8
13 changed files with 218 additions and 64 deletions

View File

@@ -1,6 +1,6 @@
## Makefile.am
##
## (C) Copyright 2009-2022 Fred Gleason <fredg@paravelsystems.com>
## (C) Copyright 2009-2025 Fred Gleason <fredg@paravelsystems.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License version 2 as
@@ -18,8 +18,8 @@
## Use automake to process this into a Makefile.in
##
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -Wno-strict-aliasing -std=c++11 -fPIC -I$(top_srcdir)/lib -I$(top_srcdir)/rdhpi @QT5_CFLAGS@ @MUSICBRAINZ_CFLAGS@ @IMAGEMAGICK_CFLAGS@
LIBS = -L$(top_srcdir)/lib -L$(top_srcdir)/rdhpi
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -Wno-strict-aliasing -std=c++11 -fPIC -I$(top_srcdir)/lib -I$(top_srcdir)/rdalsa @QT5_CFLAGS@ @MUSICBRAINZ_CFLAGS@ @IMAGEMAGICK_CFLAGS@
LIBS = -L$(top_srcdir)/lib -L$(top_srcdir)/rdalsa
MOC = @QT_MOC@
# The dependency for qt's Meta Object Compiler (moc)
@@ -29,7 +29,6 @@ moc_%.cpp: %.h
bin_PROGRAMS = rdalsaconfig
dist_rdalsaconfig_SOURCES = alsaitem.cpp alsaitem.h\
rdalsacard.cpp rdalsacard.h\
rdalsamodel.cpp rdalsamodel.h\
rdalsaconfig.cpp rdalsaconfig.h

View File

@@ -1,108 +0,0 @@
// rdalsacard.cpp
//
// Abstract ALSA 'card' information
//
// (C) Copyright 2019-2025 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include "rdalsacard.h"
RDAlsaCard::RDAlsaCard(snd_ctl_t *ctl,int index)
{
snd_ctl_card_info_t *card_info;
snd_pcm_info_t *pcm_info;
card_index=index;
snd_ctl_card_info_malloc(&card_info);
snd_pcm_info_malloc(&pcm_info);
snd_ctl_card_info(ctl,card_info);
card_id=QString(snd_ctl_card_info_get_id(card_info));
card_driver=QString(snd_ctl_card_info_get_driver(card_info));
card_name=QString(snd_ctl_card_info_get_name(card_info));
card_long_name=QString(snd_ctl_card_info_get_longname(card_info));
card_mixer_name=QString(snd_ctl_card_info_get_mixername(card_info));
if(card_name=="Loopback") { // Fix the opaque name assigned by Wheatstone
card_name.replace("Loopback","WheatNet");
card_long_name.replace("Loopback","WheatNet");
card_mixer_name.replace("Loopback","WheatNet");
}
card_enabled=false;
snd_pcm_info_free(pcm_info);
snd_ctl_card_info_free(card_info);
}
int RDAlsaCard::index() const
{
return card_index;
}
QString RDAlsaCard::id() const
{
return card_id;
}
QString RDAlsaCard::driver() const
{
return card_driver;
}
QString RDAlsaCard::name() const
{
return card_name;
}
QString RDAlsaCard::longName() const
{
return card_long_name;
}
QString RDAlsaCard::mixerName() const
{
return card_long_name;
}
bool RDAlsaCard::isEnabled() const
{
return card_enabled;
}
void RDAlsaCard::setEnabled(bool state)
{
card_enabled=state;
}
QString RDAlsaCard::dump() const
{
QString ret=QString::asprintf("Card %d\n",index());
ret+=" ID: "+id()+"\n";
ret+=" Name: "+name()+"\n";
ret+=" LongName: "+longName()+"\n";
ret+=" MixerName: "+mixerName()+"\n";
return ret;
}

View File

@@ -1,54 +0,0 @@
// rdalsacard.h
//
// Abstract ALSA 'card' information
//
// (C) Copyright 2019-2025 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDALSACARD_H
#define RDALSACARD_H
#include <alsa/asoundlib.h>
#include <qstring.h>
#include <qstringlist.h>
class RDAlsaCard
{
public:
RDAlsaCard(snd_ctl_t *ctl,int index);
int index() const;
QString id() const;
QString driver() const;
QString name() const;
QString longName() const;
QString mixerName() const;
bool isEnabled() const;
void setEnabled(bool state);
QString dump() const;
private:
int card_index;
QString card_id;
QString card_driver;
QString card_name;
QString card_long_name;
QString card_mixer_name;
bool card_enabled;
};
#endif // RDALSACARD_H

View File

@@ -55,7 +55,7 @@ QVariant RDAlsaModel::data(const QModelIndex &index,int role) const
switch((Qt::ItemDataRole)role) {
case Qt::DisplayRole:
return QVariant(model_alsa_cards.at(row)->longName());
return QVariant(model_alsa_cards.at(row)->prettyLongName());
break;
case Qt::DecorationRole:

View File

@@ -27,7 +27,7 @@
#include <rd.h>
#include "rdalsacard.h"
#include <rdalsacard.h>
#define START_MARKER "# *** Start of Rivendell configuration generated by rdalsaconfig(1) ***"
#define END_MARKER "# *** End of Rivendell configuration generated by rdalsaconfig(1) ***"