您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ snd_use_lock_free函数代码示例

51自学网 2021-06-03 08:03:48
  C++
这篇教程C++ snd_use_lock_free函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中snd_use_lock_free函数的典型用法代码示例。如果您正苦于以下问题:C++ snd_use_lock_free函数的具体用法?C++ snd_use_lock_free怎么用?C++ snd_use_lock_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了snd_use_lock_free函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: snd_seq_oss_midi_close

/* * close the midi device if already opened */intsnd_seq_oss_midi_close(struct seq_oss_devinfo *dp, int dev){	struct seq_oss_midi *mdev;	struct snd_seq_port_subscribe subs;	if ((mdev = get_mididev(dp, dev)) == NULL)		return -ENODEV;	if (! mdev->opened || mdev->devinfo != dp) {		snd_use_lock_free(&mdev->use_lock);		return 0;	}	memset(&subs, 0, sizeof(subs));	if (mdev->opened & PERM_WRITE) {		subs.sender = dp->addr;		subs.dest.client = mdev->client;		subs.dest.port = mdev->port;		snd_seq_kernel_client_ctl(dp->cseq, SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT, &subs);	}	if (mdev->opened & PERM_READ) {		subs.sender.client = mdev->client;		subs.sender.port = mdev->port;		subs.dest = dp->addr;		snd_seq_kernel_client_ctl(dp->cseq, SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT, &subs);	}	mdev->opened = 0;	mdev->devinfo = NULL;	snd_use_lock_free(&mdev->use_lock);	return 0;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:36,


示例2: snd_seq_oss_synth_setup

voidsnd_seq_oss_synth_setup(struct seq_oss_devinfo *dp){	int i;	struct seq_oss_synth *rec;	struct seq_oss_synthinfo *info;	dp->max_synthdev = max_synth_devs;	dp->synth_opened = 0;	memset(dp->synths, 0, sizeof(dp->synths));	for (i = 0; i < dp->max_synthdev; i++) {		rec = get_sdev(i);		if (rec == NULL)			continue;		if (rec->oper.open == NULL || rec->oper.close == NULL) {			snd_use_lock_free(&rec->use_lock);			continue;		}		info = &dp->synths[i];		info->arg.app_index = dp->port;		info->arg.file_mode = dp->file_mode;		info->arg.seq_mode = dp->seq_mode;		if (dp->seq_mode == SNDRV_SEQ_OSS_MODE_SYNTH)			info->arg.event_passing = SNDRV_SEQ_OSS_PROCESS_EVENTS;		else			info->arg.event_passing = SNDRV_SEQ_OSS_PASS_EVENTS;		info->opened = 0;		if (!try_module_get(rec->oper.owner)) {			snd_use_lock_free(&rec->use_lock);			continue;		}		if (rec->oper.open(&info->arg, rec->private_data) < 0) {			module_put(rec->oper.owner);			snd_use_lock_free(&rec->use_lock);			continue;		}		info->nr_voices = rec->nr_voices;		if (info->nr_voices > 0) {			info->ch = kcalloc(info->nr_voices, sizeof(struct seq_oss_chinfo), GFP_KERNEL);			if (!info->ch) {				snd_printk(KERN_ERR "Cannot malloc/n");				rec->oper.close(&info->arg);				module_put(rec->oper.owner);				snd_use_lock_free(&rec->use_lock);				continue;			}			reset_channels(info);		}#ifdef CONFIG_DEBUG_PRINTK		debug_printk(("synth %d assigned/n", i));#else		debug_;#endif		info->opened++;		rec->opened++;		dp->synth_opened++;		snd_use_lock_free(&rec->use_lock);	}}
开发者ID:nos1609,项目名称:Chrono_Kernel-1,代码行数:59,


示例3: snd_seq_oss_midi_putc

/* * dump midi data * return 0 : enqueued *        non-zero : invalid - ignored */intsnd_seq_oss_midi_putc(struct seq_oss_devinfo *dp, int dev, unsigned char c, struct snd_seq_event *ev){	struct seq_oss_midi *mdev;	if ((mdev = get_mididev(dp, dev)) == NULL)		return -ENODEV;	if (snd_midi_event_encode_byte(mdev->coder, c, ev) > 0) {		snd_seq_oss_fill_addr(dp, ev, mdev->client, mdev->port);		snd_use_lock_free(&mdev->use_lock);		return 0;	}	snd_use_lock_free(&mdev->use_lock);	return -EINVAL;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:20,


示例4: snd_seq_oss_midi_check_exit_port

/* * release the midi device if it was registered */intsnd_seq_oss_midi_check_exit_port(int client, int port){	struct seq_oss_midi *mdev;	unsigned long flags;	int index;	if ((mdev = find_slot(client, port)) != NULL) {		spin_lock_irqsave(&register_lock, flags);		midi_devs[mdev->seq_device] = NULL;		spin_unlock_irqrestore(&register_lock, flags);		snd_use_lock_free(&mdev->use_lock);		snd_use_lock_sync(&mdev->use_lock);		snd_midi_event_free(mdev->coder);		kfree(mdev);	}	spin_lock_irqsave(&register_lock, flags);	for (index = max_midi_devs - 1; index >= 0; index--) {		if (midi_devs[index])			break;	}	max_midi_devs = index + 1;	spin_unlock_irqrestore(&register_lock, flags);	return 0;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:28,


示例5: snd_seq_oss_midi_reset

/* * reset the midi device and close it: * so far, only close the device. */voidsnd_seq_oss_midi_reset(struct seq_oss_devinfo *dp, int dev){	struct seq_oss_midi *mdev;	if ((mdev = get_mididev(dp, dev)) == NULL)		return;	if (! mdev->opened) {		snd_use_lock_free(&mdev->use_lock);		return;	}	if (mdev->opened & PERM_WRITE) {		struct snd_seq_event ev;		int c;		debug_printk(("resetting client %d port %d/n", mdev->client, mdev->port));		memset(&ev, 0, sizeof(ev));		ev.dest.client = mdev->client;		ev.dest.port = mdev->port;		ev.queue = dp->queue;		ev.source.port = dp->port;		if (dp->seq_mode == SNDRV_SEQ_OSS_MODE_SYNTH) {			ev.type = SNDRV_SEQ_EVENT_SENSING;			snd_seq_oss_dispatch(dp, &ev, 0, 0);		}		for (c = 0; c < 16; c++) {			ev.type = SNDRV_SEQ_EVENT_CONTROLLER;			ev.data.control.channel = c;			ev.data.control.param = MIDI_CTL_ALL_NOTES_OFF;			snd_seq_oss_dispatch(dp, &ev, 0, 0);			if (dp->seq_mode == SNDRV_SEQ_OSS_MODE_MUSIC) {				ev.data.control.param =					MIDI_CTL_RESET_CONTROLLERS;				snd_seq_oss_dispatch(dp, &ev, 0, 0);				ev.type = SNDRV_SEQ_EVENT_PITCHBEND;				ev.data.control.value = 0;				snd_seq_oss_dispatch(dp, &ev, 0, 0);			}		}	}	// snd_seq_oss_midi_close(dp, dev);	snd_use_lock_free(&mdev->use_lock);}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:48,


示例6: snd_seq_oss_midi_get_addr

/* * get client/port of the specified MIDI device */voidsnd_seq_oss_midi_get_addr(struct seq_oss_devinfo *dp, int dev, struct snd_seq_addr *addr){	struct seq_oss_midi *mdev;	if ((mdev = get_mididev(dp, dev)) == NULL)		return;	addr->client = mdev->client;	addr->port = mdev->port;	snd_use_lock_free(&mdev->use_lock);}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:14,


示例7: snd_seq_oss_midi_make_info

/* * create OSS compatible midi_info record */intsnd_seq_oss_midi_make_info(struct seq_oss_devinfo *dp, int dev, struct midi_info *inf){	struct seq_oss_midi *mdev;	if ((mdev = get_mididev(dp, dev)) == NULL)		return -ENXIO;	inf->device = dev;	inf->dev_type = 0; /* FIXME: ?? */	inf->capabilities = 0; /* FIXME: ?? */	strlcpy(inf->name, mdev->name, sizeof(inf->name));	snd_use_lock_free(&mdev->use_lock);	return 0;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:17,


示例8: snd_seq_oss_midi_input

/* * input callback - this can be atomic */intsnd_seq_oss_midi_input(struct snd_seq_event *ev, int direct, void *private_data){	struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private_data;	struct seq_oss_midi *mdev;	int rc;	if (dp->readq == NULL)		return 0;	if ((mdev = find_slot(ev->source.client, ev->source.port)) == NULL)		return 0;	if (! (mdev->opened & PERM_READ)) {		snd_use_lock_free(&mdev->use_lock);		return 0;	}	if (dp->seq_mode == SNDRV_SEQ_OSS_MODE_MUSIC)		rc = send_synth_event(dp, ev, mdev->seq_device);	else		rc = send_midi_event(dp, ev, mdev);	snd_use_lock_free(&mdev->use_lock);	return rc;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:27,


示例9: snd_seq_oss_midi_filemode

/* * change seq capability flags to file mode flags */intsnd_seq_oss_midi_filemode(struct seq_oss_devinfo *dp, int dev){	struct seq_oss_midi *mdev;	int mode;	if ((mdev = get_mididev(dp, dev)) == NULL)		return 0;	mode = 0;	if (mdev->opened & PERM_WRITE)		mode |= SNDRV_SEQ_OSS_FILE_WRITE;	if (mdev->opened & PERM_READ)		mode |= SNDRV_SEQ_OSS_FILE_READ;	snd_use_lock_free(&mdev->use_lock);	return mode;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:21,


示例10: snd_seq_oss_synth_cleanup

voidsnd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp){	int i;	struct seq_oss_synth *rec;	struct seq_oss_synthinfo *info;	if (snd_BUG_ON(dp->max_synthdev >= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS))		return;	for (i = 0; i < dp->max_synthdev; i++) {		info = &dp->synths[i];		if (! info->opened)			continue;		if (info->is_midi) {			if (midi_synth_dev.opened > 0) {				snd_seq_oss_midi_close(dp, info->midi_mapped);				midi_synth_dev.opened--;			}		} else {			rec = get_sdev(i);			if (rec == NULL)				continue;			if (rec->opened > 0) {#ifdef CONFIG_DEBUG_PRINTK				debug_printk(("synth %d closed/n", i));#else				debug_;#endif				rec->oper.close(&info->arg);				module_put(rec->oper.owner);				rec->opened = 0;			}			snd_use_lock_free(&rec->use_lock);		}		kfree(info->sysex);		info->sysex = NULL;		kfree(info->ch);		info->ch = NULL;	}	dp->synth_opened = 0;	dp->max_synthdev = 0;}
开发者ID:nos1609,项目名称:Chrono_Kernel-1,代码行数:42,


示例11: snd_seq_oss_midi_info_read

voidsnd_seq_oss_midi_info_read(struct snd_info_buffer *buf){	int i;	struct seq_oss_midi *mdev;	snd_iprintf(buf, "/nNumber of MIDI devices: %d/n", max_midi_devs);	for (i = 0; i < max_midi_devs; i++) {		snd_iprintf(buf, "/nmidi %d: ", i);		mdev = get_mdev(i);		if (mdev == NULL) {			snd_iprintf(buf, "*empty*/n");			continue;		}		snd_iprintf(buf, "[%s] ALSA port %d:%d/n", mdev->name,			    mdev->client, mdev->port);		snd_iprintf(buf, "  capability %s / opened %s/n",			    capmode_str(mdev->flags),			    capmode_str(mdev->opened));		snd_use_lock_free(&mdev->use_lock);	}}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:22,


示例12: snd_seq_oss_midi_check_new_port

/* * register a new port if it doesn't exist yet */intsnd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo){	int i;	struct seq_oss_midi *mdev;	unsigned long flags;	/* the port must include generic midi */	if (! (pinfo->type & SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC))		return 0;	/* either read or write subscribable */	if ((pinfo->capability & PERM_WRITE) != PERM_WRITE &&	    (pinfo->capability & PERM_READ) != PERM_READ)		return 0;	/*	 * look for the identical slot	 */	if ((mdev = find_slot(pinfo->addr.client, pinfo->addr.port)) != NULL) {		/* already exists */		snd_use_lock_free(&mdev->use_lock);		return 0;	}	/*	 * allocate midi info record	 */	mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);	if (!mdev)		return -ENOMEM;	/* copy the port information */	mdev->client = pinfo->addr.client;	mdev->port = pinfo->addr.port;	mdev->flags = pinfo->capability;	mdev->opened = 0;	snd_use_lock_init(&mdev->use_lock);	/* copy and truncate the name of synth device */	strlcpy(mdev->name, pinfo->name, sizeof(mdev->name));	/* create MIDI coder */	if (snd_midi_event_new(MAX_MIDI_EVENT_BUF, &mdev->coder) < 0) {		pr_err("ALSA: seq_oss: can't malloc midi coder/n");		kfree(mdev);		return -ENOMEM;	}	/* OSS sequencer adds running status to all sequences */	snd_midi_event_no_status(mdev->coder, 1);	/*	 * look for en empty slot	 */	spin_lock_irqsave(&register_lock, flags);	for (i = 0; i < max_midi_devs; i++) {		if (midi_devs[i] == NULL)			break;	}	if (i >= max_midi_devs) {		if (max_midi_devs >= SNDRV_SEQ_OSS_MAX_MIDI_DEVS) {			spin_unlock_irqrestore(&register_lock, flags);			snd_midi_event_free(mdev->coder);			kfree(mdev);			return -ENOMEM;		}		max_midi_devs++;	}	mdev->seq_device = i;	midi_devs[mdev->seq_device] = mdev;	spin_unlock_irqrestore(&register_lock, flags);	return 0;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:76,


示例13: snd_seq_oss_midi_check_new_port

intsnd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo){	int i;	struct seq_oss_midi *mdev;	unsigned long flags;	debug_printk(("check for MIDI client %d port %d/n", pinfo->addr.client, pinfo->addr.port));	/*                                    */	if (! (pinfo->type & SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC))		return 0;	/*                                   */	if ((pinfo->capability & PERM_WRITE) != PERM_WRITE &&	    (pinfo->capability & PERM_READ) != PERM_READ)		return 0;	/*                                 */	if ((mdev = find_slot(pinfo->addr.client, pinfo->addr.port)) != NULL) {		/*                */		snd_use_lock_free(&mdev->use_lock);		return 0;	}	/*                               */	if ((mdev = kzalloc(sizeof(*mdev), GFP_KERNEL)) == NULL) {		snd_printk(KERN_ERR "can't malloc midi info/n");		return -ENOMEM;	}	/*                           */	mdev->client = pinfo->addr.client;	mdev->port = pinfo->addr.port;	mdev->flags = pinfo->capability;	mdev->opened = 0;	snd_use_lock_init(&mdev->use_lock);	/*                                            */	strlcpy(mdev->name, pinfo->name, sizeof(mdev->name));	/*                   */	if (snd_midi_event_new(MAX_MIDI_EVENT_BUF, &mdev->coder) < 0) {		snd_printk(KERN_ERR "can't malloc midi coder/n");		kfree(mdev);		return -ENOMEM;	}	/*                                                    */	snd_midi_event_no_status(mdev->coder, 1);	/*                            */	spin_lock_irqsave(&register_lock, flags);	for (i = 0; i < max_midi_devs; i++) {		if (midi_devs[i] == NULL)			break;	}	if (i >= max_midi_devs) {		if (max_midi_devs >= SNDRV_SEQ_OSS_MAX_MIDI_DEVS) {			spin_unlock_irqrestore(&register_lock, flags);			snd_midi_event_free(mdev->coder);			kfree(mdev);			return -ENOMEM;		}		max_midi_devs++;	}	mdev->seq_device = i;	midi_devs[mdev->seq_device] = mdev;	spin_unlock_irqrestore(&register_lock, flags);	return 0;}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:75,


示例14: snd_seq_oss_midi_open

/* * open the midi device if not opened yet */intsnd_seq_oss_midi_open(struct seq_oss_devinfo *dp, int dev, int fmode){	int perm;	struct seq_oss_midi *mdev;	struct snd_seq_port_subscribe subs;	if ((mdev = get_mididev(dp, dev)) == NULL)		return -ENODEV;	/* already used? */	if (mdev->opened && mdev->devinfo != dp) {		snd_use_lock_free(&mdev->use_lock);		return -EBUSY;	}	perm = 0;	if (is_write_mode(fmode))		perm |= PERM_WRITE;	if (is_read_mode(fmode))		perm |= PERM_READ;	perm &= mdev->flags;	if (perm == 0) {		snd_use_lock_free(&mdev->use_lock);		return -ENXIO;	}	/* already opened? */	if ((mdev->opened & perm) == perm) {		snd_use_lock_free(&mdev->use_lock);		return 0;	}	perm &= ~mdev->opened;	memset(&subs, 0, sizeof(subs));	if (perm & PERM_WRITE) {		subs.sender = dp->addr;		subs.dest.client = mdev->client;		subs.dest.port = mdev->port;		if (snd_seq_kernel_client_ctl(dp->cseq, SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT, &subs) >= 0)			mdev->opened |= PERM_WRITE;	}	if (perm & PERM_READ) {		subs.sender.client = mdev->client;		subs.sender.port = mdev->port;		subs.dest = dp->addr;		subs.flags = SNDRV_SEQ_PORT_SUBS_TIMESTAMP;		subs.queue = dp->queue;		/* queue for timestamps */		if (snd_seq_kernel_client_ctl(dp->cseq, SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT, &subs) >= 0)			mdev->opened |= PERM_READ;	}	if (! mdev->opened) {		snd_use_lock_free(&mdev->use_lock);		return -ENXIO;	}	mdev->devinfo = dp;	snd_use_lock_free(&mdev->use_lock);	return 0;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:66,



注:本文中的snd_use_lock_free函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ snew_bc函数代码示例
C++ snd_strerror函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。