added more funcionality to salsa (save/load sound settings), moved volume
settings to /etc/alsa/
This commit is contained in:
parent
db08b0e5b6
commit
5e20f4bdf5
@ -4,7 +4,7 @@
|
|||||||
Summary: Advanced Linux Sound Architecture (ALSA) utilities
|
Summary: Advanced Linux Sound Architecture (ALSA) utilities
|
||||||
Name: alsa-utils
|
Name: alsa-utils
|
||||||
Version: 1.0.14
|
Version: 1.0.14
|
||||||
Release: 0.4%{?prever_dot}%{?dist}
|
Release: 0.5%{?prever_dot}%{?dist}
|
||||||
License: GPL
|
License: GPL
|
||||||
Group: Applications/Multimedia
|
Group: Applications/Multimedia
|
||||||
URL: http://www.alsa-project.org/
|
URL: http://www.alsa-project.org/
|
||||||
@ -39,15 +39,19 @@ Architecture (ALSA).
|
|||||||
%{__rm} -rf ${RPM_BUILD_ROOT}
|
%{__rm} -rf ${RPM_BUILD_ROOT}
|
||||||
make install DESTDIR=$RPM_BUILD_ROOT
|
make install DESTDIR=$RPM_BUILD_ROOT
|
||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT/%{_sbindir}
|
# Install ALSA udev rules
|
||||||
ln -s ../../sbin/alsactl $RPM_BUILD_ROOT/%{_sbindir}/alsactl
|
|
||||||
|
|
||||||
install -m 755 salsa $RPM_BUILD_ROOT/sbin
|
|
||||||
mkdir -p -m755 $RPM_BUILD_ROOT/etc/udev/rules.d/
|
mkdir -p -m755 $RPM_BUILD_ROOT/etc/udev/rules.d/
|
||||||
install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/etc/udev/rules.d/90-alsa.rules
|
install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/etc/udev/rules.d/90-alsa.rules
|
||||||
|
|
||||||
|
# Install support utilities
|
||||||
mkdir -p -m755 $RPM_BUILD_ROOT/bin
|
mkdir -p -m755 $RPM_BUILD_ROOT/bin
|
||||||
install -m 755 alsaunmute %{buildroot}/bin
|
install -m 755 alsaunmute %{buildroot}/bin
|
||||||
install -m 755 alsacard %{buildroot}/bin
|
install -m 755 alsacard %{buildroot}/bin
|
||||||
|
install -m 755 salsa %{buildroot}/sbin
|
||||||
|
|
||||||
|
# Link alsactl to /usr/sbin
|
||||||
|
mkdir -p $RPM_BUILD_ROOT/%{_sbindir}
|
||||||
|
ln -s ../../sbin/alsactl $RPM_BUILD_ROOT/%{_sbindir}/alsactl
|
||||||
|
|
||||||
%clean
|
%clean
|
||||||
%{__rm} -rf $RPM_BUILD_ROOT
|
%{__rm} -rf $RPM_BUILD_ROOT
|
||||||
@ -57,9 +61,9 @@ install -m 755 alsacard %{buildroot}/bin
|
|||||||
%doc COPYING ChangeLog README TODO
|
%doc COPYING ChangeLog README TODO
|
||||||
/etc/udev/rules.d/*
|
/etc/udev/rules.d/*
|
||||||
/bin/*
|
/bin/*
|
||||||
|
/sbin/*
|
||||||
%{_bindir}/*
|
%{_bindir}/*
|
||||||
%{_sbindir}/*
|
%{_sbindir}/*
|
||||||
/sbin/*
|
|
||||||
%{_mandir}/man?/*
|
%{_mandir}/man?/*
|
||||||
%dir %{_datadir}/sounds
|
%dir %{_datadir}/sounds
|
||||||
%dir %{_datadir}/sounds/alsa
|
%dir %{_datadir}/sounds/alsa
|
||||||
@ -70,6 +74,10 @@ install -m 755 alsacard %{buildroot}/bin
|
|||||||
/usr/share/locale/*
|
/usr/share/locale/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Apr 18 2007 Martin Stransky <stransky@redhat.com> 1.0.14-0.5.rc2
|
||||||
|
- added more funcionality to salsa (save/load sound settings),
|
||||||
|
moved volume settings to /etc/alsa/
|
||||||
|
|
||||||
* Thu Apr 10 2007 Martin Stransky <stransky@redhat.com> 1.0.14-0.4.rc2
|
* Thu Apr 10 2007 Martin Stransky <stransky@redhat.com> 1.0.14-0.4.rc2
|
||||||
- added support for large files
|
- added support for large files
|
||||||
- minor fix in alsaunmute
|
- minor fix in alsaunmute
|
||||||
|
86
salsa.c
86
salsa.c
@ -1,4 +1,4 @@
|
|||||||
/* Copyright 2005 Red Hat, Inc.
|
/* Copyright 2007 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* Portions extraced from various ALSA code:
|
* Portions extraced from various ALSA code:
|
||||||
* Copyright (c) by Abramo Bagnara <abramo@alsa-project.org>
|
* Copyright (c) by Abramo Bagnara <abramo@alsa-project.org>
|
||||||
@ -16,10 +16,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
|
|
||||||
#define ALSA_CONFIG_PATH "/etc/asound.state"
|
#define ALSA_CONFIG_PATH "/etc/alsa/asound.state"
|
||||||
|
#define ALL_CARDS (-1)
|
||||||
|
|
||||||
|
|
||||||
int get_card_number()
|
int get_card_number()
|
||||||
{
|
{
|
||||||
@ -75,15 +78,30 @@ out:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int run_alsactl(int index)
|
void load_volume_settings(int index)
|
||||||
{
|
{
|
||||||
char *args[] = { "/sbin/alsactl", "restore", NULL, NULL };
|
char *args[] = { "/sbin/alsactl", "-f", ALSA_CONFIG_PATH, "restore", NULL, NULL };
|
||||||
char num[10];
|
char num[10];
|
||||||
|
|
||||||
|
if(index != ALL_CARDS) {
|
||||||
|
snprintf(num, 10, "%d", index);
|
||||||
|
args[4] = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
execv(args[0], args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void save_volume_settings(int index)
|
||||||
|
{
|
||||||
|
char *args[] = { "/sbin/alsactl", "-f", ALSA_CONFIG_PATH, "store", NULL, NULL };
|
||||||
|
char num[10];
|
||||||
|
|
||||||
|
if(index != ALL_CARDS) {
|
||||||
|
snprintf(num, 10, "%d", index);
|
||||||
|
args[4] = num;
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(num, "%d", index);
|
|
||||||
args[2] = num;
|
|
||||||
execv(args[0], args);
|
execv(args[0], args);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void frob_mixer(int index)
|
void frob_mixer(int index)
|
||||||
@ -94,17 +112,55 @@ void frob_mixer(int index)
|
|||||||
execl("/bin/alsaunmute","/bin/alsaunmute", tmp, "-v", NULL);
|
execl("/bin/alsaunmute","/bin/alsaunmute", tmp, "-v", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void banner(void)
|
||||||
|
{
|
||||||
|
printf("ALSA volume settings handler, Copyright 2007 Red Hat, Inc.\n");
|
||||||
|
printf("This software may be freely redistributed under\nthe terms of the GNU public license.\n\n");
|
||||||
|
|
||||||
|
printf("Usage: salsa [options] [card number]\n\n");
|
||||||
|
printf(" Options:\n");
|
||||||
|
printf(" -l - Load volume settings\n");
|
||||||
|
printf(" -s - Save volume settings\n\n");
|
||||||
|
printf(" Card number:\n");
|
||||||
|
printf(" ## - An affected card. If it isn't specified,\n");
|
||||||
|
printf(" configure all installed sound cards.\n\n");
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = get_card_number();
|
if(argc == 1) {
|
||||||
if (i < 0)
|
i = get_card_number();
|
||||||
return 0;
|
if (i < 0) {
|
||||||
if (has_config(i))
|
return 0;
|
||||||
return run_alsactl(i);
|
}
|
||||||
else
|
if (has_config(i)) {
|
||||||
frob_mixer(i);
|
load_volume_settings(i);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
frob_mixer(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(argc >= 2) {
|
||||||
|
|
||||||
|
int card_number = ALL_CARDS;
|
||||||
|
if(argc == 3) {
|
||||||
|
card_number = atoi(argv[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(argv[1][1] == 'l') {
|
||||||
|
load_volume_settings(card_number);
|
||||||
|
}
|
||||||
|
else if(argv[1][1] == 's') {
|
||||||
|
save_volume_settings(card_number);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
banner();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user