rpms/alsa-utils/FC-4 alsacard.c, NONE, 1.1 alsaunmute.c, NONE, 1.1 .cvsignore, 1.11, 1.12 alsa-utils.spec, 1.18, 1.19 salsa.c, 1.3, 1.4 sources, 1.12, 1.13
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Mon Dec 5 07:43:46 UTC 2005
- Previous message (by thread): rpms/alsa-lib/FC-4 alsa-lib-1.0.10-ainit.patch, NONE, 1.1 .cvsignore, 1.14, 1.15 alsa-lib.spec, 1.30, 1.31 sources, 1.16, 1.17 alsa-lib-ainit-2.patch, 1.1, NONE
- Next message (by thread): rpms/php/devel php.spec,1.93,1.94
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: stransky
Update of /cvs/dist/rpms/alsa-utils/FC-4
In directory cvs.devel.redhat.com:/tmp/cvs-serv29682
Modified Files:
.cvsignore alsa-utils.spec salsa.c sources
Added Files:
alsacard.c alsaunmute.c
Log Message:
update to 1.0.10
--- NEW FILE alsacard.c ---
/* Copyright 2005 Red Hat, Inc.
*
* This software may be freely redistributed under the terms of the GNU
* public license.
*
* 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 <stdio.h>
#include <string.h>
#include <alsa/asoundlib.h>
int get_card_device(const char *p_device)
{
int err;
snd_ctl_t *handle;
snd_ctl_card_info_t *info;
snd_ctl_card_info_alloca(&info);
if ((err = snd_ctl_open(&handle, "default", 0)) < 0) {
fprintf(stderr,"Open error: %s\n", snd_strerror(err));
return(0);
}
if ((err = snd_ctl_card_info(handle, info)) < 0) {
fprintf(stderr,"HW info error: %s\n", snd_strerror(err));
return(0);
}
return (snd_ctl_card_info_get_card(info));
}
int main(int argc, char *argv[])
{
char *p_device = "default";
int card;
if (argc > 1 && argv[1])
p_device = argv[1];
card = get_card_device(p_device);
printf("%d",card);
return (card);
}
--- NEW FILE alsaunmute.c ---
/* Copyright 2005 Red Hat, Inc.
*
* Portions extraced from various ALSA code:
* Copyright (c) by Abramo Bagnara <abramo at alsa-project.org>
* Jaroslav Kysela <perex at suse.cz>
* Takashi Iwai <tiwai at suse.de>
* Bernd Kaindl <bk at suse.de>
* Jan ONDREJ (SAL) <ondrejj at salstar.sk>
*
* This software may be freely redistributed under the terms of the GNU
* public license.
*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <alsa/asoundlib.h>
#define TRUE (1==1)
#define FALSE (1!=1)
int verbose = 0;
typedef struct _CHANNEL {
char name[100];
int play_volume;
int play_switch;
int rec_volume;
int rec_switch;
char driver[100];
} CHANNEL;
CHANNEL channels[] = {
// channel pl vol pl swt rec vol rec swt driver
{"Master", 75, 1, 0, 0, ""},
{"Front", 75, 1, 0, 0, ""},
{"PCM", 75, 1, 0, 0, ""},
{"PCM-2", 75, 1, 0, 0, ""},
{"Synth", 75, 1, 0, 0, ""},
{"CD", 75, 1, 90, 1, ""},
// mute mic
{"Mic", 0, 0, 0, 0, ""},
// Trident/YMFPCI/emu10k1
{"Wave", 100, 1, 0, 0, ""},
{"Music", 100, 1, 0, 0, ""},
{"AC97", 100, 1, 0, 0, ""},
// CS4237B chipset
{"Master Digital", 75, 1, 0, 0, ""},
// Envy24 chips with analog outs
{"DAC", 75, 1, 0, 0, ""},
// Powermacs
{"DRC Range", 75, 1, 0, 0, ""},
// some notebooks use headphone instead of master
{"Headphone", 75, 1, 0, 0, ""},
{"Playback", 100, 1, 0, 0, ""},
// turn off digital switches
{"SB Live Analog/Digital Output Jack", 0, 0, 0, 0, ""},
{"Audigy Analog/Digital Output Jack", 0, 0, 0, 0, ""},
// Specific config for ca0106
{"Analog Front", 75, 1, 0, 0, "snd-ca0106"},
{"Analog Rear", 75, 1, 0, 0, "snd-ca0106"},
{"SPDIF Out", 0, 0, 0, 0, "snd-ca0106"},
// Specific config for snd-emu10k1
{"Audigy Analog/Digital Output Jack", 0,1,0, 0, "snd-emu10k1"},
{"IEC958 Optical Raw", 0, 0, 0, 0, "snd-emu10k1"},
{"Tone", 0, 0, 0, 0, "snd-emu10k1"},
// Specific config for snd-intel8x0
{"External Amplifier", 1, 1, 0, 0, "snd-intel8x0"},
// Specific config for snd-intel8x0 (xw8000)
{"Master Mono", 75, 1, 0, 0, "snd-intel8x0"},
// Specific config for snd-ens1371
{"IEC958", 0, 0, 0, 0, "snd-ens1371"},
// Specific config for snd-azx/snd-hda
{"Mono", 75, 1, 0, 0, "snd-azx"},
{"Mono", 75, 1, 0, 0, "snd-hda"}
};
char * strlwr(char *a)
{
char *ret = a;
while (*a != '\0') {
if (isupper (*a))
*a = tolower (*a);
a++;
}
return ret;
}
CHANNEL * channel_find(const char *p_name, const char *p_driver) {
int i;
for (i = 0; i < sizeof(channels) / sizeof(channels[0]); i++)
if (!strcmp(channels[i].driver, p_driver) && !strcmp(channels[i].name, p_name))
return (channels + i);
return (NULL);
}
int calc_volume(long min, long max, int percent)
{
return ((int)(min + ((max - min) / 100.0f) * percent));
}
int unmute_card(int index, const char *p_driver)
{
CHANNEL *p_chan;
long pmin, pmax;
long rmin, rmax;
int rc = 0;
char card[32];
char channel_name[500];
int c,vol;
snd_mixer_t *handle;
snd_mixer_selem_id_t *sid;
snd_mixer_elem_t *elem;
snd_mixer_selem_id_alloca(&sid);
if(verbose) {
fprintf(stderr,"Unmuting %s...\n",p_driver ? p_driver : "");
}
sprintf(card, "hw:%d", index);
if ((rc = snd_mixer_open(&handle, 0)) < 0) {
if(verbose) {
fprintf(stderr,"%s: error file %s, line %d...\n",__FUNCTION__,__FILE__,__LINE__);
}
return rc;
}
if ((rc = snd_mixer_attach(handle, card)) < 0) {
if(verbose) {
fprintf(stderr,"%s: error file %s, line %d...\n",__FUNCTION__,__FILE__,__LINE__);
}
goto out;
}
if ((rc = snd_mixer_selem_register(handle, NULL, NULL)) < 0) {
if(verbose) {
fprintf(stderr,"%s: error file %s, line %d...\n",__FUNCTION__,__FILE__,__LINE__);
}
goto out;
}
rc = snd_mixer_load(handle);
if (rc < 0) {
if(verbose) {
fprintf(stderr,"%s: error file %s, line %d...\n",__FUNCTION__,__FILE__,__LINE__);
}
goto out;
}
for (elem = snd_mixer_first_elem(handle); elem;
elem = snd_mixer_elem_next(elem)) {
snd_mixer_selem_get_id(elem, sid);
strncpy(channel_name,snd_mixer_selem_id_get_name(sid),500);
channel_name[499] = '\0';
p_chan = channel_find(strlwr(channel_name),p_driver);
if (!p_chan)
continue;
for (c = 0; c < SND_MIXER_SCHN_LAST; c++) {
if (snd_mixer_selem_has_capture_channel(elem, c)) {
if (snd_mixer_selem_has_capture_switch(elem)) {
snd_mixer_selem_set_capture_switch(elem, c, p_chan->rec_switch);
if(verbose) {
fprintf(stderr,"Cap. Switch %s(%d) to %d\n",p_chan->name,c,p_chan->rec_switch);
}
}
if (snd_mixer_selem_has_capture_volume(elem)) {
snd_mixer_selem_get_capture_volume_range(elem, &rmin, &rmax);
vol = calc_volume(rmin, rmax,p_chan->rec_volume);
snd_mixer_selem_set_capture_volume(elem, c, vol);
if(verbose) {
fprintf(stderr,"Cap. Volume %s(%d) to %d\n",p_chan->name,c,vol);
}
}
}
if (snd_mixer_selem_has_playback_channel(elem, c)) {
if (snd_mixer_selem_has_playback_switch(elem)) {
snd_mixer_selem_set_playback_switch(elem, c, p_chan->play_switch);
if(verbose) {
fprintf(stderr,"Play. Switch %s(%d) to %d\n",p_chan->name,c,p_chan->play_switch);
}
}
if (snd_mixer_selem_has_playback_volume(elem)) {
snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
vol = calc_volume(pmin, pmax,p_chan->play_volume);
snd_mixer_selem_set_playback_volume(elem, c, vol);
if(verbose) {
fprintf(stderr,"Play. Volume %s(%d) to %d\n",p_chan->name,c,vol);
}
}
}
}
}
return(TRUE);
out:
snd_mixer_close(handle);
return rc;
}
char * check_driver_name(char *p_name)
{
char *p_tmp = strchr(p_name,'-');
if(p_tmp) {
*p_tmp = '_';
}
return(p_name);
}
#define PROC_MODULES "/proc/asound/modules"
static char driver_name[100];
const char * get_card_driver(int index)
{
FILE *f = fopen(PROC_MODULES,"r");
char tmp[100];
char *p_tmp;
int id;
if(!f)
return(NULL);
while(fgets(tmp,100,f)) {
sscanf(tmp," %d %s",&id,driver_name);
if(id == index) {
return(check_driver_name(driver_name));
}
}
return(NULL);
}
void check_data(void)
{
char *p_tmp;
int i;
for (i = 0; i < sizeof(channels) / sizeof(channels[0]); i++) {
strlwr(channels[i].name);
check_driver_name(channels[i].driver);
}
}
void usage(char *p_name)
{
printf("Alsa Unmute utility, Copyright 2005 Red Hat, Inc.\n");
printf("This software may be freely redistributed under the terms of the GNU\n");
printf("public license.\n\n");
printf("usage: %s card_number [-v]\n\n", p_name);
printf(" card_number - number of unmuted card\n");
printf(" [-v] - verbose mode\n\n");
exit(0);
}
/*
Unmute specified card
alsaunmute 0
*/
int main(int argc, char **argv)
{
const char *p_driver;
int index;
if (argc < 2) {
usage(argv[0]);
exit(0);
}
index = atoi(argv[1]);
p_driver = get_card_driver(index);
if (argc == 3 && (!strcmp(argv[2],"-v") || !strcmp(argv[2],"-V"))) {
verbose = TRUE;
}
if(!p_driver) {
fprintf(stderr,"Wrong card index %d...\n",index);
return(1);
}
if(verbose) {
fprintf(stderr,"Card %d Driver %s...\n",index,p_driver);
}
check_data();
// default settings for all cards
unmute_card(index,"");
// specific setting for selected card_number
unmute_card(index,p_driver);
return (0);
}
Index: .cvsignore
===================================================================
RCS file: /cvs/dist/rpms/alsa-utils/FC-4/.cvsignore,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- .cvsignore 16 Jun 2005 10:00:29 -0000 1.11
+++ .cvsignore 5 Dec 2005 07:43:44 -0000 1.12
@@ -4,3 +4,4 @@
alsa-utils-1.0.9.tar.bz2
alsacard.c
alsa-utils-1.0.9a.tar.bz2
+alsa-utils-1.0.10.tar.bz2
Index: alsa-utils.spec
===================================================================
RCS file: /cvs/dist/rpms/alsa-utils/FC-4/alsa-utils.spec,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- alsa-utils.spec 16 Jun 2005 10:00:30 -0000 1.18
+++ alsa-utils.spec 5 Dec 2005 07:43:44 -0000 1.19
@@ -1,16 +1,14 @@
-%define version_tar 1.0.9a
-%define version_pack 1.0.9rf
-
Summary: Advanced Linux Sound Architecture (ALSA) utilities
Name: alsa-utils
-Version: %{version_pack}
-Release: 2.FC4
+Version: 1.0.10
+Release: 1.FC4
License: GPL
Group: Applications/Multimedia
URL: http://www.alsa-project.org/
-Source: ftp://ftp.alsa-project.org/pub/utils/alsa-utils-%{version_tar}%{?prever}.tar.bz2
-Source2: salsa.c
+Source: ftp://ftp.alsa-project.org/pub/utils/alsa-utils-%{version}%{?prever}.tar.bz2
+Source2: salsa.c
Source3: alsacard.c
+Source4: alsaunmute.c
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: alsa-lib-devel >= %{version}
BuildRequires: ncurses-devel
@@ -22,7 +20,7 @@
Architecture (ALSA).
%prep
-%setup -q -n %{name}-%{version_tar}%{?prever}
+%setup -q -n %{name}-%{version}%{?prever}
%build
autoreconf -f -i
@@ -30,6 +28,7 @@
%{__make} %{?_smp_mflags}
%{__cc} $RPM_OPT_FLAGS -o salsa %{SOURCE2} -lasound
%{__cc} $RPM_OPT_FLAGS -o alsacard %{SOURCE3} -lasound
+%{__cc} $RPM_OPT_FLAGS -o alsaunmute %{SOURCE4} -lasound
%install
%{__rm} -rf ${RPM_BUILD_ROOT}
@@ -44,6 +43,7 @@
mkdir -p -m755 $RPM_BUILD_ROOT/etc/dev.d/sound
install -m 755 salsa $RPM_BUILD_ROOT/etc/dev.d/sound/alsa.dev
install -m 755 alsacard %{buildroot}%{_bindir}
+install -m 755 alsaunmute %{buildroot}%{_bindir}
%clean
%{__rm} -rf $RPM_BUILD_ROOT
@@ -60,10 +60,13 @@
%{_mandir}/fr/man?/*
/usr/share/sounds/alsa/*
/usr/share/alsa/speaker-test/*
-%{_bindir}/alsacard
-
+/usr/share/locale/*
%changelog
+* Mon Dec 05 2005 Martin Stransky <stransky at redhat.com> 1.0.10-1.FC4
+- New upstream version
+- Added alsaunmute utility from devel branch
+
* Thu Jun 16 2005 Martin Stransky <stransky at redhat.com> 1.0.9-2.FC4
- New upstream version
Index: salsa.c
===================================================================
RCS file: /cvs/dist/rpms/alsa-utils/FC-4/salsa.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- salsa.c 16 May 2005 20:44:56 -0000 1.3
+++ salsa.c 5 Dec 2005 07:43:44 -0000 1.4
@@ -88,64 +88,10 @@
int frob_mixer(int index)
{
- int rc = 0;
- char card[32];
- snd_mixer_t *handle;
- snd_mixer_selem_id_t *sid;
- snd_mixer_elem_t *elem;
- snd_mixer_selem_id_alloca(&sid);
-
- sprintf(card,"hw:%d",index);
- if ((rc = snd_mixer_open(&handle, 0)) < 0) {
- return rc;
- }
- if ((rc = snd_mixer_attach(handle, card)) < 0) {
- goto out;
- }
- if ((rc = snd_mixer_selem_register(handle, NULL, NULL)) < 0) {
- goto out;
- }
- rc = snd_mixer_load(handle);
- if (rc < 0) {
- goto out;
- }
- for (elem = snd_mixer_first_elem(handle); elem; elem = snd_mixer_elem_next(elem)) {
- long pmin, pmax;
- int c;
-
- snd_mixer_selem_get_id(elem, sid);
- snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
- for (c = 0; c < SND_MIXER_SCHN_LAST; c++) {
- if (snd_mixer_selem_has_capture_channel(elem, c)) {
- if (snd_mixer_selem_has_capture_volume(elem))
- snd_mixer_selem_set_capture_volume(elem, c, 0);
- if (!strcmp(snd_mixer_selem_id_get_name(sid),"CD")) {
- if (snd_mixer_selem_has_capture_switch(elem))
- snd_mixer_selem_set_capture_switch(elem, c, 1);
- } else {
- if (snd_mixer_selem_has_capture_switch(elem))
- snd_mixer_selem_set_capture_switch(elem, c, 0);
- if (snd_mixer_selem_has_playback_switch(elem))
- snd_mixer_selem_set_playback_switch(elem, c, 0);
- if (snd_mixer_selem_has_playback_volume(elem))
- snd_mixer_selem_set_playback_volume(elem, c, 0);
- }
- }
- if (snd_mixer_selem_has_playback_channel(elem, c)) {
- if (!snd_mixer_selem_has_capture_channel(elem, c) ||
- !strcmp(snd_mixer_selem_id_get_name(sid),"CD") ||
- !strcmp(snd_mixer_selem_id_get_name(sid),"Wave")) {
- if (snd_mixer_selem_has_playback_switch(elem))
- snd_mixer_selem_set_playback_switch(elem, c, 1);
- if (snd_mixer_selem_has_playback_volume(elem))
- snd_mixer_selem_set_playback_volume(elem, c, pmin + (pmax - pmin) * 0.75);
- }
- }
- }
- }
-out:
- snd_mixer_close(handle);
- return rc;
+ char tmp[100];
+ snprintf(tmp, 100, "%d", index);
+ tmp[99] = '\0';
+ execl("/bin/alsaunmute","/bin/alsaunmute", tmp, "-v", NULL);
}
int main(int argc, char **argv)
Index: sources
===================================================================
RCS file: /cvs/dist/rpms/alsa-utils/FC-4/sources,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- sources 16 Jun 2005 10:00:30 -0000 1.12
+++ sources 5 Dec 2005 07:43:44 -0000 1.13
@@ -1,2 +1 @@
-84a139aff67d14024a3f3e4e9c586367 alsacard.c
-d4b77e9fe0311772293e402fdd634ad2 alsa-utils-1.0.9a.tar.bz2
+94bdec65e9c3fd02f7ef8ceb8f918afe alsa-utils-1.0.10.tar.bz2
- Previous message (by thread): rpms/alsa-lib/FC-4 alsa-lib-1.0.10-ainit.patch, NONE, 1.1 .cvsignore, 1.14, 1.15 alsa-lib.spec, 1.30, 1.31 sources, 1.16, 1.17 alsa-lib-ainit-2.patch, 1.1, NONE
- Next message (by thread): rpms/php/devel php.spec,1.93,1.94
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-cvs-commits
mailing list