本文整理汇总了C++中snd_ctl_open函数的典型用法代码示例。如果您正苦于以下问题:C++ snd_ctl_open函数的具体用法?C++ snd_ctl_open怎么用?C++ snd_ctl_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snd_ctl_open函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例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: 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
示例11: 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
示例12: 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
示例13: 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
示例14: 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
示例15: snd_ctl_card_info_alloca
std::vector<HwIDPair>
AlsaLayer::getAudioDeviceIndexMap(bool getCapture) const
{
snd_ctl_t* handle;
snd_ctl_card_info_t *info;
snd_pcm_info_t* pcminfo;
snd_ctl_card_info_alloca(&info);
snd_pcm_info_alloca(&pcminfo);
int numCard = -1;
std::vector<HwIDPair> audioDevice;
if (snd_card_next(&numCard) < 0 || numCard < 0)
return audioDevice;
do {
std::stringstream ss;
ss << numCard;
std::string name = "hw:" + ss.str();
if (snd_ctl_open(&handle, name.c_str(), 0) == 0) {
if (snd_ctl_card_info(handle, info) == 0) {
snd_pcm_info_set_device(pcminfo, 0);
snd_pcm_info_set_stream(pcminfo, getCapture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK);
int err;
if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) {
WARN("Cannot get info for %s %s: %s", getCapture ?
"capture device" : "playback device", name.c_str(),
snd_strerror(err));
} else {
DEBUG("card %i : %s [%s]",
numCard,
snd_ctl_card_info_get_id(info),
snd_ctl_card_info_get_name(info));
std::string description = snd_ctl_card_info_get_name(info);
description.append(" - ");
description.append(snd_pcm_info_get_name(pcminfo));
// The number of the sound card is associated with a string description
audioDevice.push_back(HwIDPair(numCard, description));
}
}
snd_ctl_close(handle);
}
} while (snd_card_next(&numCard) >= 0 && numCard >= 0);
return audioDevice;
}
开发者ID:ThereIsNoYeti,项目名称:sflphone,代码行数:53,代码来源:alsalayer.cpp
示例16: snd_hctl_open
/**
* \brief Opens an HCTL
* \param hctlp Returned HCTL handle
* \param name ASCII identifier of the underlying CTL handle
* \param mode Open mode (see #SND_CTL_NONBLOCK, #SND_CTL_ASYNC)
* \return 0 on success otherwise a negative error code
*/
int snd_hctl_open(snd_hctl_t **hctlp, const char *name, int mode)
{
snd_ctl_t *ctl;
int err;
if ((err = snd_ctl_open(&ctl, name, mode)) < 0)
return err;
err = snd_hctl_open_ctl(hctlp, ctl);
if (err < 0)
snd_ctl_close(ctl);
return err;
}
开发者ID:OpenSmalltalk,项目名称:opensmalltalk-vm,代码行数:19,代码来源:hcontrol.c
示例17: ags_devout_list_cards
/**
* ags_devout_list_cards:
* @soundcard: the #AgsSoundcard
* @card_id: alsa identifier
* @card_name: card name
*
* List available soundcards.
*
* Since: 0.4
*/
void
ags_devout_list_cards(AgsSoundcard *soundcard,
GList **card_id, GList **card_name)
{
snd_ctl_t *card_handle;
snd_ctl_card_info_t *card_info;
char *name;
gchar *str;
int card_num;
int error;
*card_id = NULL;
*card_name = NULL;
card_num = -1;
while(TRUE){
error = snd_card_next(&card_num);
if(card_num < 0){
break;
}
if(error < 0){
continue;
}
str = g_strdup_printf("hw:%i\0", card_num);
error = snd_ctl_open(&card_handle, str, 0);
if(error < 0){
continue;
}
snd_ctl_card_info_alloca(&card_info);
error = snd_ctl_card_info(card_handle, card_info);
if(error < 0){
continue;
}
*card_id = g_list_prepend(*card_id, str);
*card_name = g_list_prepend(*card_name, g_strdup(snd_ctl_card_info_get_name(card_info)));
snd_ctl_close(card_handle);
}
snd_config_update_free_global();
*card_id = g_list_reverse(*card_id);
*card_name = g_list_reverse(*card_name);
}
开发者ID:joelkraehemann,项目名称:gsequencer,代码行数:61,代码来源:ags_devout.c
示例18: get_gain
int get_gain(int idx, int src, int dst)
{
int err;
int val = HDSPMM_ERROR_NO_CARD;
snd_ctl_elem_id_t *id;
snd_ctl_elem_value_t *ctl;
snd_ctl_t *handle;
if(idx >= HDSPMM_MAX_CARDS || idx < 0)
return HDSPMM_ERROR_WRONG_IDX;
snd_ctl_elem_value_alloca(&ctl);
snd_ctl_elem_id_alloca(&id);
snd_ctl_elem_id_set_name(id, "Mixer");
snd_ctl_elem_id_set_numid(id, 0);
snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP);
snd_ctl_elem_id_set_device(id, 0);
snd_ctl_elem_id_set_subdevice(id, 0);
snd_ctl_elem_id_set_index(id, 0);
snd_ctl_elem_value_set_id(ctl, id);
if ((err = snd_ctl_open(&handle, card_name[cardid], SND_CTL_NONBLOCK)) < 0) {
#ifndef QUIET
fprintf(stderr, "Alsa error: %s\n", snd_strerror(err));
#endif
return HDSPMM_ERROR_ALSA_OPEN;
}
snd_ctl_elem_value_set_integer(ctl, 0, src);
snd_ctl_elem_value_set_integer(ctl, 1, dst);
if ((err = snd_ctl_elem_read(handle, ctl)) < 0) {
#ifndef QUIET
fprintf(stderr, "Alsa error: %s\n", snd_strerror(err));
#endif
return HDSPMM_ERROR_ALSA_READ;
}
val = snd_ctl_elem_value_get_integer(ctl, 2);
snd_ctl_close(handle);
return val;
SETFLOAT(x->x_at+1, delta);
SETFLOAT(x->x_at+2, phi);
outlet_list(x->x_out_para, &s_list, 3, x->x_at);
outlet_anything(x->x_obj.ob_outlet, s, x->x_size2d+1, x->x_at);
}
开发者ID:IcaroL2ORK,项目名称:pd,代码行数:50,代码来源:hdspm_mixer.c
示例19: set_gain
int set_gain(int idx, int src, int dst, int val)
{
int err;
snd_ctl_elem_id_t *id;
snd_ctl_elem_value_t *ctl;
snd_ctl_t *handle;
if(idx >= HDSPMM_MAX_CARDS || idx < 0)
return HDSPMM_ERROR_WRONG_IDX;
snd_ctl_elem_value_alloca(&ctl);
snd_ctl_elem_id_alloca(&id);
snd_ctl_elem_id_set_name(id, "Mixer");
snd_ctl_elem_id_set_numid(id, 0);
snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP);
snd_ctl_elem_id_set_device(id, 0);
snd_ctl_elem_id_set_subdevice(id, 0);
snd_ctl_elem_id_set_index(id, 0);
snd_ctl_elem_value_set_id(ctl, id);
if ((err = snd_ctl_open(&handle, card_name[idx], SND_CTL_NONBLOCK)) < 0) {
#ifndef QUIET
fprintf(stderr, "Alsa error: %s\n", snd_strerror(err));
#endif
return HDSPMM_ERROR_ALSA_OPEN;
}
snd_ctl_elem_value_set_integer(ctl, 0, src);
snd_ctl_elem_value_set_integer(ctl, 1, dst);
snd_ctl_elem_value_set_integer(ctl, 2, val);
if ((err = snd_ctl_elem_write(handle, ctl)) < 0) {
#ifndef QUIET
fprintf(stderr, "Alsa error: %s\n", snd_strerror(err));
#endif
return HDSPMM_ERROR_ALSA_WRITE;
}
val = snd_ctl_elem_value_get_integer(ctl, 2);
snd_ctl_close(handle);
return val;
}
开发者ID:IcaroL2ORK,项目名称:pd,代码行数:45,代码来源:hdspm_mixer.c
示例20: open_ctl
static int open_ctl(const char *name, snd_ctl_t **ctlp)
{
snd_ctl_t *ctl;
if (snd_ctl_open(&ctl, name, SND_CTL_READONLY) < 0) {
fprintf(stderr, "Cannot open ctl %s\n", name);
return 1;
}
if (snd_ctl_subscribe_events(ctl, 1) < 0) {
fprintf(stderr, "Cannot open subscribe events to ctl %s\n", name);
snd_ctl_close(ctl);
return 1;
}
*ctlp = ctl;
return 0;
}
开发者ID:polter-rnd,项目名称:y50-subwoofer,代码行数:18,代码来源:y50-subwoofer.c
注:本文中的snd_ctl_open函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论