本文整理汇总了C++中snd_ctl_close函数的典型用法代码示例。如果您正苦于以下问题:C++ snd_ctl_close函数的具体用法?C++ snd_ctl_close怎么用?C++ snd_ctl_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snd_ctl_close函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: snd_card_get_index
/**
* \brief Convert card string to an integer value.
* \param string String containing card identifier
* \return zero if success, otherwise a negative error code
*
* The accepted format is an integer value in ASCII representation
* or the card identifier (the id parameter for sound-card drivers).
*/
int snd_card_get_index(const char *string)
{
int card;
snd_ctl_t *handle;
snd_ctl_card_info_t info;
if (!string || *string == '\0')
return -EINVAL;
if ((isdigit(*string) && *(string + 1) == 0) ||
(isdigit(*string) && isdigit(*(string + 1)) && *(string + 2) == 0)) {
if (sscanf(string, "%i", &card) != 1)
return -EINVAL;
if (card < 0 || card > 31)
return -EINVAL;
if (snd_card_load(card))
return card;
return -ENODEV;
}
for (card = 0; card < 32; card++) {
if (! snd_card_load(card))
continue;
if (snd_ctl_hw_open(&handle, NULL, card, 0) < 0)
continue;
if (snd_ctl_card_info(handle, &info) < 0) {
snd_ctl_close(handle);
continue;
}
snd_ctl_close(handle);
if (!strcmp((const char *)info.id, string))
return card;
}
return -ENODEV;
}
开发者ID:canalplus,项目名称:r7oss,代码行数:41,代码来源:cards.c
示例2: open_with_subdev
/* open the substream with the given subdevice number */
static int open_with_subdev(const char *filename, int fmode,
int card, int subdev)
{
snd_pcm_info_t info;
snd_ctl_t *ctl;
int err, counts, fd;
err = _snd_ctl_hw_open(&ctl, card);
if (err < 0)
return err;
err = snd_ctl_pcm_prefer_subdevice(ctl, subdev);
if (err < 0)
return err;
for (counts = 0; counts < 3; counts++) {
fd = open(filename, fmode);
if (fd < 0)
return -errno;
memset(&info, 0, sizeof(info));
if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, &info) >= 0 &&
info.subdevice == subdev) {
snd_ctl_close(ctl);
return fd;
}
close(fd);
}
snd_ctl_close(ctl);
return -EBUSY;
}
开发者ID:543872407,项目名称:Linux_SourceCode,代码行数:31,代码来源:pcm.c
示例3: search_device
static const char* search_device(void)
{
int card, err;
snd_hwdep_info_t* info;
snd_hwdep_info_alloca(&info);
card = -1;
while (snd_card_next(&card) >= 0 && card >= 0) {
char ctl_name[20];
snd_ctl_t* ctl;
int device;
sprintf(ctl_name, "hw:CARD=%d", card);
err = snd_ctl_open(&ctl, ctl_name, SND_CTL_NONBLOCK);
if (err < 0)
continue;
device = -1;
while (snd_ctl_hwdep_next_device(ctl, &device) >= 0 && device >= 0) {
snd_hwdep_info_set_device(info, device);
err = snd_ctl_hwdep_info(ctl, info);
if (err >= 0 && snd_hwdep_info_get_iface(info) == SND_HWDEP_IFACE_SB_RC) {
static char name[36];
sprintf(name, "hw:CARD=%d,DEV=%d", card, device);
snd_ctl_close(ctl);
return name;
}
}
snd_ctl_close(ctl);
}
return NULL;
}
开发者ID:andyvand,项目名称:LIRC,代码行数:32,代码来源:alsa_usb.c
示例4: open_ctl
static int open_ctl(snd_use_case_mgr_t *uc_mgr,
snd_ctl_t **ctl,
const char *ctl_dev)
{
int err;
/* FIXME: add a list of ctl devices to uc_mgr structure and
cache accesses for multiple opened ctl devices */
if (uc_mgr->ctl_dev != NULL && strcmp(ctl_dev, uc_mgr->ctl_dev) == 0) {
*ctl = uc_mgr->ctl;
return 0;
}
if (uc_mgr->ctl_dev) {
free(uc_mgr->ctl_dev);
uc_mgr->ctl_dev = NULL;
snd_ctl_close(uc_mgr->ctl);
uc_mgr->ctl = NULL;
}
err = snd_ctl_open(ctl, ctl_dev, 0);
if (err < 0)
return err;
uc_mgr->ctl_dev = strdup(ctl_dev);
if (uc_mgr->ctl_dev == NULL) {
snd_ctl_close(*ctl);
return -ENOMEM;
}
uc_mgr->ctl = *ctl;
return 0;
}
开发者ID:Blackrose,项目名称:mini2440-bsp,代码行数:30,代码来源:main.c
示例5: snd_ctl_card_info_alloca
static char *ListAvailableDevices( demux_t *p_demux, bool b_probe )
{
snd_ctl_card_info_t *p_info = NULL;
snd_ctl_card_info_alloca( &p_info );
snd_pcm_info_t *p_pcminfo = NULL;
snd_pcm_info_alloca( &p_pcminfo );
if( !b_probe )
msg_Dbg( p_demux, "Available alsa capture devices:" );
int i_card = -1;
while( !snd_card_next( &i_card ) && i_card >= 0 )
{
char psz_devname[10];
snprintf( psz_devname, 10, "hw:%d", i_card );
snd_ctl_t *p_ctl = NULL;
if( snd_ctl_open( &p_ctl, psz_devname, 0 ) < 0 ) continue;
snd_ctl_card_info( p_ctl, p_info );
if( !b_probe )
msg_Dbg( p_demux, " %s (%s)",
snd_ctl_card_info_get_id( p_info ),
snd_ctl_card_info_get_name( p_info ) );
int i_dev = -1;
while( !snd_ctl_pcm_next_device( p_ctl, &i_dev ) && i_dev >= 0 )
{
snd_pcm_info_set_device( p_pcminfo, i_dev );
snd_pcm_info_set_subdevice( p_pcminfo, 0 );
snd_pcm_info_set_stream( p_pcminfo, SND_PCM_STREAM_CAPTURE );
if( snd_ctl_pcm_info( p_ctl, p_pcminfo ) < 0 ) continue;
if( !b_probe )
msg_Dbg( p_demux, " hw:%d,%d : %s (%s)", i_card, i_dev,
snd_pcm_info_get_id( p_pcminfo ),
snd_pcm_info_get_name( p_pcminfo ) );
else
{
char *psz_device;
if( asprintf( &psz_device, "hw:%d,%d", i_card, i_dev ) > 0 )
{
if( ProbeAudioDevAlsa( p_demux, psz_device ) )
{
snd_ctl_close( p_ctl );
return psz_device;
}
else
free( psz_device );
}
}
}
snd_ctl_close( p_ctl );
}
return NULL;
}
开发者ID:Italianmoose,项目名称:Stereoscopic-VLC,代码行数:57,代码来源:alsa.c
示例6: snd_ctl_card_info_alloca
bool MainWindowImpl::FindRadioshark(string& device)
{
int card = -1;
int dev = -1;
snd_ctl_t *handle = NULL;
snd_ctl_card_info_t *info = NULL;
snd_pcm_info_t *pcminfo = NULL;
snd_pcm_stream_t stream = SND_PCM_STREAM_CAPTURE;
char card_id[32];
char *name = NULL;
snd_ctl_card_info_alloca (&info);
snd_pcm_info_alloca (&pcminfo);
if (snd_card_next (&card) < 0 || card < 0)
{
return false;
}
while(card >= 0)
{
snprintf (card_id, 32, "hw:%d", card);
if (snd_ctl_open (&handle, card_id, 0) == 0)
{
snd_ctl_card_info (handle, info);
while (1)
{
snd_ctl_pcm_next_device (handle, &dev);
if (dev < 0){
break;
}
snd_pcm_info_set_device (pcminfo, dev);
snd_pcm_info_set_subdevice (pcminfo, 0);
snd_pcm_info_set_stream (pcminfo, stream);
if (snd_ctl_pcm_info (handle, pcminfo) >= 0)
{
snd_card_get_name (card, &name);
if(strncmp(name,"radioSHARK",32) == 0)
{void PokeScreensaver(void);
snd_ctl_close(handle);
free (name);
snprintf (card_id, 32, "hw:%d,%d", card,dev);
device = string(card_id);
return true;
}
free (name);
}
}
snd_ctl_close(handle);
}
snd_card_next (&card);
}
return false;//didn't find the proper Radioshark card.
}
开发者ID:RyanNerd,项目名称:finny,代码行数:55,代码来源:mainwindowimpl.cpp
示例7: deviceList
static void deviceList(int type, vector_DevMap *devmap)
{
snd_ctl_t* handle;
snd_pcm_info_t pcminfo;
int max_cards, card, err, dev;
DevMap entry;
char name[1024];
struct snd_ctl_hw_info info;
void* temp;
max_cards = snd_cards();
if(max_cards < 0)
return;
VECTOR_RESERVE(*devmap, max_cards+1);
VECTOR_RESIZE(*devmap, 0);
entry.name = strdup(qsaDevice);
entry.card = 0;
entry.dev = 0;
VECTOR_PUSH_BACK(*devmap, entry);
for(card = 0;card < max_cards;card++)
{
if((err=snd_ctl_open(&handle, card)) < 0)
continue;
if((err=snd_ctl_hw_info(handle, &info)) < 0)
{
snd_ctl_close(handle);
continue;
}
for(dev = 0;dev < (int)info.pcmdevs;dev++)
{
if((err=snd_ctl_pcm_info(handle, dev, &pcminfo)) < 0)
continue;
if((type==SND_PCM_CHANNEL_PLAYBACK && (pcminfo.flags&SND_PCM_INFO_PLAYBACK)) ||
(type==SND_PCM_CHANNEL_CAPTURE && (pcminfo.flags&SND_PCM_INFO_CAPTURE)))
{
snprintf(name, sizeof(name), "%s [%s] (hw:%d,%d)", info.name, pcminfo.name, card, dev);
entry.name = strdup(name);
entry.card = card;
entry.dev = dev;
VECTOR_PUSH_BACK(*devmap, entry);
TRACE("Got device \"%s\", card %d, dev %d\n", name, card, dev);
}
}
snd_ctl_close(handle);
}
}
开发者ID:Sponk,项目名称:NeoEditor,代码行数:53,代码来源:qsa.c
示例8: ALSA_AddUserSpecifiedDevice
/*----------------------------------------------------------------------------
** ALSA_AddUserSpecifiedDevice
** Add a device given from the registry
*/
static int ALSA_AddUserSpecifiedDevice(const char *ctlname, const char *pcmname)
{
int rc;
int okay = 0;
snd_ctl_t *ctl = NULL;
snd_pcm_t *pcm = NULL;
if (ctlname)
{
rc = snd_ctl_open(&ctl, ctlname, SND_CTL_NONBLOCK);
if (rc < 0)
ctl = NULL;
}
rc = snd_pcm_open(&pcm, pcmname, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
if (rc >= 0)
{
ALSA_AddPlaybackDevice(ctl, pcm, pcmname, FALSE);
okay++;
snd_pcm_close(pcm);
}
rc = snd_pcm_open(&pcm, pcmname, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
if (rc >= 0)
{
ALSA_AddCaptureDevice(ctl, pcm, pcmname, FALSE);
okay++;
snd_pcm_close(pcm);
}
if (ctl)
snd_ctl_close(ctl);
return (okay == 0);
}
开发者ID:mikekap,项目名称:wine,代码行数:39,代码来源:waveinit.c
示例9: get_cards
/**
* Partly based on get_cards function in alsamixer.
* This gets all alsa cards and fills the global
* GSList 'cards'.
* The list always starts with the 'default' card.
*/
static void
get_cards(void)
{
int err, num;
snd_ctl_card_info_t *info;
snd_ctl_t *ctl;
char buf[10];
struct acard *cur_card, *default_card;
if (cards != NULL)
g_slist_free_full(cards, card_free);
cards = NULL;
default_card = g_malloc(sizeof(struct acard));
default_card->name = g_strdup("(default)");
default_card->dev = g_strdup("default");
default_card->channels = get_channels("default");
cards = g_slist_append(cards, default_card);
// don't need to free this as it's alloca'd
snd_ctl_card_info_alloca(&info);
num = -1;
for (;;) {
err = snd_card_next(&num);
if (err < 0) {
report_error("Can't get sounds cards: %s", snd_strerror(err));
return;
}
if (num < 0)
break;
sprintf(buf, "hw:%d", num);
if (snd_ctl_open(&ctl, buf, 0) < 0)
continue;
err = snd_ctl_card_info(ctl, info);
snd_ctl_close(ctl);
if (err < 0)
continue;
cur_card = g_malloc(sizeof(struct acard));
cur_card->name = g_strdup(snd_ctl_card_info_get_name(info));
sprintf(buf, "hw:%d", num);
cur_card->dev = g_strdup(buf);
cur_card->channels = get_channels(buf);
cards = g_slist_append(cards, cur_card);
}
#ifdef DEBUG
GSList *tmp = cards;
if (tmp) {
printf("------ Card list ------\n");
while (tmp) {
struct acard *c = tmp->data;
printf("\t%s\t%s\t%s\n", c->dev, c->name,
c->channels ? "" : "No chann");
tmp = tmp->next;
}
printf("-----------------------\n");
}
#endif
}
开发者ID:aarizkuren,项目名称:pnmixer,代码行数:66,代码来源:alsa.c
示例10: cards
static int cards(lua_State *lstate) {
snd_ctl_t *handle;
int ret, card, ord;
char buf[32];
snd_ctl_card_info_t *info;
snd_ctl_card_info_alloca(&info);
ord = 1;
card = -1;
lua_newtable(lstate);
while (1) {
if ((snd_card_next(&card) < 0) || (card < 0)) break;
sprintf(buf, "hw:%d", card);
if ((ret = snd_ctl_open(&handle, buf, 0)) < 0) {
logmsg("control open: %s\n", snd_strerror(ret));
continue;
}
if ((ret = snd_ctl_card_info(handle, info)) < 0) {
logmsg("control info: %s\n", snd_strerror(ret));
continue;
}
lua_pushinteger(lstate, ord++);
lua_newtable(lstate);
set_string(lstate, "dev", buf);
set_string(lstate, "name",
snd_ctl_card_info_get_name(info));
lua_settable(lstate, -3);
snd_ctl_close(handle);
//view_card(buf);
}
return 1;
}
开发者ID:pmyadlowsky,项目名称:mash,代码行数:31,代码来源:alsa.c
示例11: PORT_GetPortMixerCount
INT32 PORT_GetPortMixerCount() {
INT32 mixerCount;
int card;
char devname[16];
int err;
snd_ctl_t *handle;
snd_ctl_card_info_t* info;
TRACE0("> PORT_GetPortMixerCount\n");
initAlsaSupport();
snd_ctl_card_info_malloc(&info);
card = -1;
mixerCount = 0;
if (snd_card_next(&card) >= 0) {
while (card >= 0) {
sprintf(devname, ALSA_HARDWARE_CARD, card);
TRACE1("PORT_GetPortMixerCount: Opening alsa device \"%s\"...\n", devname);
err = snd_ctl_open(&handle, devname, 0);
if (err < 0) {
ERROR2("ERROR: snd_ctl_open, card=%d: %s\n", card, snd_strerror(err));
} else {
mixerCount++;
snd_ctl_close(handle);
}
if (snd_card_next(&card) < 0) {
break;
}
}
}
snd_ctl_card_info_free(info);
TRACE0("< PORT_GetPortMixerCount\n");
return mixerCount;
}
开发者ID:krichter722,项目名称:jdk9-jdk9-jdk,代码行数:35,代码来源:PLATFORM_API_LinuxOS_ALSA_Ports.c
示例12: PORT_GetPortMixerDescription
INT32 PORT_GetPortMixerDescription(INT32 mixerIndex, PortMixerDescription* description) {
snd_ctl_t* handle;
snd_ctl_card_info_t* card_info;
char devname[16];
int err;
char buffer[100];
TRACE0("> PORT_GetPortMixerDescription\n");
snd_ctl_card_info_malloc(&card_info);
sprintf(devname, ALSA_HARDWARE_CARD, (int) mixerIndex);
TRACE1("Opening alsa device \"%s\"...\n", devname);
err = snd_ctl_open(&handle, devname, 0);
if (err < 0) {
ERROR2("ERROR: snd_ctl_open, card=%d: %s\n", (int) mixerIndex, snd_strerror(err));
return FALSE;
}
err = snd_ctl_card_info(handle, card_info);
if (err < 0) {
ERROR2("ERROR: snd_ctl_card_info, card=%d: %s\n", (int) mixerIndex, snd_strerror(err));
}
strncpy(description->name, snd_ctl_card_info_get_id(card_info), PORT_STRING_LENGTH - 1);
sprintf(buffer, " [%s]", devname);
strncat(description->name, buffer, PORT_STRING_LENGTH - 1 - strlen(description->name));
strncpy(description->vendor, "ALSA (http://www.alsa-project.org)", PORT_STRING_LENGTH - 1);
strncpy(description->description, snd_ctl_card_info_get_name(card_info), PORT_STRING_LENGTH - 1);
strncat(description->description, ", ", PORT_STRING_LENGTH - 1 - strlen(description->description));
strncat(description->description, snd_ctl_card_info_get_mixername(card_info), PORT_STRING_LENGTH - 1 - strlen(description->description));
getALSAVersion(description->version, PORT_STRING_LENGTH - 1);
snd_ctl_close(handle);
snd_ctl_card_info_free(card_info);
TRACE0("< PORT_GetPortMixerDescription\n");
return TRUE;
}
开发者ID:krichter722,项目名称:jdk9-jdk9-jdk,代码行数:35,代码来源:PLATFORM_API_LinuxOS_ALSA_Ports.c
示例13: scan_cycle
void scan_cycle(alsa_rawmidi_t *midi)
{
int card = -1, err;
scan_t scan;
midi_port_t **ports;
//debug_log("scan: cleanup");
scan_cleanup(midi);
scan.midi = midi;
scan.iterator = &midi->scan.ports;
snd_rawmidi_info_alloca(&scan.info);
//debug_log("scan: rescan");
while ((err = snd_card_next(&card))>=0 && card>=0) {
char name[32];
snprintf(name, sizeof(name), "hw:%d", card);
if ((err = snd_ctl_open(&scan.ctl, name, SND_CTL_NONBLOCK))>=0) {
scan_card(&scan);
snd_ctl_close(scan.ctl);
} else
alsa_error("scan: snd_ctl_open", err);
}
// delayed open to workaround alsa<1.0.14 bug (can't open more than 1 subdevice if ctl is opened).
ports = &midi->scan.ports;
while (*ports) {
midi_port_t *port = *ports;
if (port->state == PORT_CREATED)
ports = scan_port_open(midi, ports);
else
ports = &port->next;
}
}
开发者ID:basilnut,项目名称:jack2,代码行数:34,代码来源:alsa_rawmidi.c
示例14: while
std::vector<String> AudioOutputDeviceAlsa::ParameterCard::PossibilitiesAsString(std::map<String,String> Parameters) {
int err;
std::vector<String> CardNames;
// iterate through all cards
int card_index = -1;
while (snd_card_next(&card_index) >= 0 && card_index >= 0) {
String hw_name = "hw:" + ToString(card_index);
snd_ctl_t* hCardCtrl;
if ((err = snd_ctl_open(&hCardCtrl, hw_name.c_str(), 0)) < 0) {
std::cerr << "AudioOutputDeviceAlsa: Cannot open sound control for card " << card_index << " - " << snd_strerror(err) << std::endl;
continue;
}
// iterate through all devices of that card
int device_index = -1;
while (!snd_ctl_pcm_next_device(hCardCtrl, &device_index) && device_index >= 0) {
String name = ToString(card_index) + "," + ToString(device_index);
//dmsg(1,("[possibility:%s]", name.c_str()));
CardNames.push_back(name);
}
snd_ctl_close(hCardCtrl);
}
return CardNames;
}
开发者ID:lxlxlo,项目名称:LS-linuxsampler,代码行数:27,代码来源:AudioOutputDeviceAlsa.cpp
示例15: audio_set_default_levels
void audio_set_default_levels() {
int err;
snd_ctl_t *ctl;
snd_ctl_elem_value_t *val;
snd_ctl_elem_value_alloca(&val);
if (snd_ctl_open(&ctl, ALSA_DEVICE, 0)) {
fprintf(stderr, "can't open audio device");
return;
}
/* unmute microphone */
snd_ctl_elem_value_set_interface(val, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_value_set_name(val, "Mic Capture Switch");
snd_ctl_elem_value_set_integer(val, 0, 1);
err = snd_ctl_elem_write(ctl, val);
if (err)
fprintf(stderr, "can't unmute microphone: %s\n", snd_strerror(err));
/* unmute speaker */
snd_ctl_elem_value_clear(val);
snd_ctl_elem_value_set_interface(val, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_value_set_name(val, "Speaker Playback Switch");
snd_ctl_elem_value_set_integer(val, 0, 1);
err = snd_ctl_elem_write(ctl, val);
if (err)
fprintf(stderr, "can't unmute speaker: %s\n", snd_strerror(err));
/* set mic volume */
snd_ctl_elem_value_clear(val);
snd_ctl_elem_value_set_interface(val, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_value_set_name(val, "Mic Capture Volume");
snd_ctl_elem_value_set_integer(val, 0, DEFAULT_MIC_VOL);
err = snd_ctl_elem_write(ctl, val);
if (err)
fprintf(stderr, "can't set microphone volume: %s\n", snd_strerror(err));
/* set speaker volume */
snd_ctl_elem_value_clear(val);
snd_ctl_elem_value_set_interface(val, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_value_set_name(val, "Speaker Playback Volume");
snd_ctl_elem_value_set_integer(val, 0, DEFAULT_SPKR_VOL);
snd_ctl_elem_value_set_integer(val, 1, DEFAULT_SPKR_VOL);
err = snd_ctl_elem_write(ctl, val);
if (err)
fprintf(stderr, "can't set speaker volume: %s\n", snd_strerror(err));
/* set capture source */
snd_ctl_elem_value_clear(val);
snd_ctl_elem_value_set_interface(val, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_value_set_name(val, "PCM Capture Source");
snd_ctl_elem_value_set_integer(val, 0, 0);
err = snd_ctl_elem_write(ctl, val);
if (err)
fprintf(stderr, "can't set capture source: %s\n", snd_strerror(err));
snd_ctl_close(ctl);
}
开发者ID:sobkas,项目名称:usbrevue,代码行数:59,代码来源:audio.c
示例16: pyalsacontrol_dealloc
static void
pyalsacontrol_dealloc(struct pyalsacontrol *self)
{
if (self->handle != NULL)
snd_ctl_close(self->handle);
self->ob_type->tp_free(self);
}
开发者ID:physacco,项目名称:pyalsa,代码行数:8,代码来源:alsacontrol.c
示例17: main
int main(int argc, char **argv)
{
register int err;
int cardNum;
// Start with first card
cardNum = -1;
for (;;)
{
snd_ctl_t *cardHandle;
// Get next sound card's card number. When "cardNum" == -1, then ALSA
// fetches the first card
if ((err = snd_card_next(&cardNum)) < 0)
{
printf("Can't get the next card number: %s\n", snd_strerror(err));
break;
}
// No more cards? ALSA sets "cardNum" to -1 if so
if (cardNum < 0) break;
// Open this card's control interface. We specify only the card number -- not
// any device nor sub-device too
{
char str[64];
sprintf(str, "hw:%i", cardNum);
if ((err = snd_ctl_open(&cardHandle, str, 0)) < 0)
{
printf("Can't open card %i: %s\n", cardNum, snd_strerror(err));
continue;
}
}
{
snd_ctl_card_info_t *cardInfo;
// We need to get a snd_ctl_card_info_t. Just alloc it on the stack
snd_ctl_card_info_alloca(&cardInfo);
// Tell ALSA to fill in our snd_ctl_card_info_t with info about this card
if ((err = snd_ctl_card_info(cardHandle, cardInfo)) < 0)
printf("Can't get info for card %i: %s\n", cardNum, snd_strerror(err));
else
printf("Card %i = %s\n", cardNum, snd_ctl_card_info_get_name(cardInfo));
}
// Close the card's control interface after we're done with it
snd_ctl_close(cardHandle);
}
// ALSA allocates some mem to load its config file when we call some of the
// above functions. Now that we're done getting the info, let's tell ALSA
// to unload the info and free up that mem
snd_config_update_free_global();
}
开发者ID:Ku-Al,项目名称:distanceplay,代码行数:58,代码来源:card.c
示例18: main
int main(int argc, char **argv)
{
int hwdep_fd;
snd_ctl_t *ctl;
(void) argc;
(void) argv;
// Setup the signal handler
struct sigaction sa = { 0 };
sa.sa_handler = &handle_signal;
// Handle standard signals to quit properly
sigemptyset(&sa.sa_mask);
sigaction(SIGINT, &sa, NULL);
sigaction(SIGHUP, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
// Open control and hwdep devices
if (open_hwdep(Y50_HWDEP_DEVICE, &hwdep_fd) != 0
|| open_ctl(Y50_CTL_NAME, &ctl) != 0) {
return 1;
}
// Initialize subwoofer
lfe_initialize(hwdep_fd);
// Set initial values
set_headphones_plugged(&headphones_plugged);
set_lfe_volume(hwdep_fd, headphones_plugged ? 0 : get_master_volume());
// Poll events
while (!doneflag) {
struct pollfd fds;
snd_ctl_poll_descriptors(ctl, &fds, 1);
if (poll(&fds, 1, -1) <= 0) {
if (errno == EINTR) {
continue;
} else {
perror("poll");
break;
}
}
unsigned short revents;
snd_ctl_poll_descriptors_revents(ctl, &fds, 1, &revents);
if (revents & POLLIN) {
handle_event(hwdep_fd, ctl);
}
}
// Close resources
close(hwdep_fd);
snd_ctl_close(ctl);
return EXIT_SUCCESS;
}
开发者ID:polter-rnd,项目名称:y50-subwoofer,代码行数:58,代码来源:y50-subwoofer.c
示例19: softvol_free
static void softvol_free(snd_pcm_softvol_t *svol)
{
if (svol->plug.gen.close_slave)
snd_pcm_close(svol->plug.gen.slave);
if (svol->ctl)
snd_ctl_close(svol->ctl);
if (svol->dB_value && svol->dB_value != preset_dB_value)
free(svol->dB_value);
free(svol);
}
开发者ID:xenyinzen,项目名称:lx_toolset,代码行数:10,代码来源:pcm_softvol.c
示例20: snd_hctl_close
/**
* \brief close HCTL handle
* \param hctl HCTL handle
* \return 0 on success otherwise a negative error code
*
* Closes the specified HCTL handle and frees all associated
* resources.
*/
int snd_hctl_close(snd_hctl_t *hctl)
{
int err;
assert(hctl);
err = snd_ctl_close(hctl->ctl);
snd_hctl_free(hctl);
free(hctl);
return err;
}
开发者ID:OpenSmalltalk,项目名称:opensmalltalk-vm,代码行数:18,代码来源:hcontrol.c
注:本文中的snd_ctl_close函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论