mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-19 08:57:08 -05:00
Removed snd_defaults_ functions.
Updated the syntax of configuration file to substitute values from the environment space. Updated alsa.conf to replace old snd_defaults_ functions.
This commit is contained in:
parent
5ce8fbeab5
commit
b7c05ad942
7 changed files with 80 additions and 158 deletions
|
|
@ -1,6 +1,6 @@
|
|||
EXTRA_LTLIBRARIES = libcontrol.la
|
||||
|
||||
libcontrol_la_SOURCES = cards.c cards_id.c hcontrol.c defaults.c \
|
||||
libcontrol_la_SOURCES = cards.c cards_id.c hcontrol.c \
|
||||
control.c control_hw.c control_shm.c \
|
||||
setup.c
|
||||
|
||||
|
|
|
|||
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
* Control Interface - defaults
|
||||
* Copyright (c) 1998 by Jaroslav Kysela <perex@suse.cz>
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "local.h"
|
||||
|
||||
static int defaults_card(const char *env)
|
||||
{
|
||||
char *e;
|
||||
|
||||
e = getenv(env);
|
||||
if (!e)
|
||||
return -ENOENT;
|
||||
return snd_card_get_index(e);
|
||||
}
|
||||
|
||||
static int defaults_device(const char *env)
|
||||
{
|
||||
char *e;
|
||||
int dev;
|
||||
|
||||
e = getenv(env);
|
||||
if (e) {
|
||||
dev = atoi(env);
|
||||
if (dev >= 0 && dev < 1024 * 1024)
|
||||
return dev;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_defaults_card(void)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = defaults_card("ALSA_CARD");
|
||||
if (result >= 0)
|
||||
return result;
|
||||
result = -1;
|
||||
if (snd_card_next(&result))
|
||||
return -ENOENT;
|
||||
return result;
|
||||
}
|
||||
|
||||
int snd_defaults_mixer_card(void)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = defaults_card("ALSA_MIXER_CARD");
|
||||
if (result >= 0)
|
||||
return result;
|
||||
return snd_defaults_card();
|
||||
}
|
||||
|
||||
int snd_defaults_pcm_card(void)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = defaults_card("ALSA_PCM_CARD");
|
||||
if (result >= 0)
|
||||
return result;
|
||||
return snd_defaults_card();
|
||||
}
|
||||
|
||||
int snd_defaults_pcm_device(void)
|
||||
{
|
||||
snd_ctl_t *handle;
|
||||
char id[16];
|
||||
int result;
|
||||
|
||||
result = defaults_device("ALSA_PCM_DEVICE");
|
||||
if (result >= 0)
|
||||
return result;
|
||||
sprintf(id, "hw:%i", snd_defaults_pcm_card());
|
||||
if (snd_ctl_open(&handle, id, 0) < 0)
|
||||
return -ENOENT;
|
||||
result = -1;
|
||||
if (snd_ctl_pcm_next_device(handle, &result) < 0) {
|
||||
snd_ctl_close(handle);
|
||||
return -ENOENT;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int snd_defaults_rawmidi_card(void)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = defaults_card("ALSA_RAWMIDI_CARD");
|
||||
if (result >= 0)
|
||||
return result;
|
||||
return snd_defaults_card();
|
||||
}
|
||||
|
||||
int snd_defaults_rawmidi_device(void)
|
||||
{
|
||||
snd_ctl_t *handle;
|
||||
char id[16];
|
||||
int result;
|
||||
|
||||
result = defaults_device("ALSA_RAWMIDI_DEVICE");
|
||||
if (result >= 0)
|
||||
return result;
|
||||
sprintf(id, "hw:%i", snd_defaults_rawmidi_card());
|
||||
if (snd_ctl_open(&handle, id, 0) < 0)
|
||||
return -ENOENT;
|
||||
result = -1;
|
||||
if (snd_ctl_rawmidi_next_device(handle, &result) < 0) {
|
||||
snd_ctl_close(handle);
|
||||
return -ENOENT;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue