Linux Audio

Check our new training course

Loading...
v5.4
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 *   ALSA sequencer Ports 
  4 *   Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
  5 */
  6#ifndef __SND_SEQ_PORTS_H
  7#define __SND_SEQ_PORTS_H
  8
  9#include <sound/seq_kernel.h>
 10#include "seq_lock.h"
 11
 12/* list of 'exported' ports */
 13
 14/* Client ports that are not exported are still accessible, but are
 15 anonymous ports. 
 16 
 17 If a port supports SUBSCRIPTION, that port can send events to all
 18 subscribersto a special address, with address
 19 (queue==SNDRV_SEQ_ADDRESS_SUBSCRIBERS). The message is then send to all
 20 recipients that are registered in the subscription list. A typical
 21 application for these SUBSCRIPTION events is handling of incoming MIDI
 22 data. The port doesn't 'know' what other clients are interested in this
 23 message. If for instance a MIDI recording application would like to receive
 24 the events from that port, it will first have to subscribe with that port.
 25 
 26*/
 27
 28struct snd_seq_subscribers {
 29	struct snd_seq_port_subscribe info;	/* additional info */
 30	struct list_head src_list;	/* link of sources */
 31	struct list_head dest_list;	/* link of destinations */
 32	atomic_t ref_count;
 33};
 34
 35struct snd_seq_port_subs_info {
 36	struct list_head list_head;	/* list of subscribed ports */
 37	unsigned int count;		/* count of subscribers */
 38	unsigned int exclusive: 1;	/* exclusive mode */
 39	struct rw_semaphore list_mutex;
 40	rwlock_t list_lock;
 41	int (*open)(void *private_data, struct snd_seq_port_subscribe *info);
 42	int (*close)(void *private_data, struct snd_seq_port_subscribe *info);
 43};
 44
 45struct snd_seq_client_port {
 46
 47	struct snd_seq_addr addr;	/* client/port number */
 48	struct module *owner;		/* owner of this port */
 49	char name[64];			/* port name */	
 50	struct list_head list;		/* port list */
 51	snd_use_lock_t use_lock;
 52
 53	/* subscribers */
 54	struct snd_seq_port_subs_info c_src;	/* read (sender) list */
 55	struct snd_seq_port_subs_info c_dest;	/* write (dest) list */
 56
 57	int (*event_input)(struct snd_seq_event *ev, int direct, void *private_data,
 58			   int atomic, int hop);
 59	void (*private_free)(void *private_data);
 60	void *private_data;
 61	unsigned int closing : 1;
 62	unsigned int timestamping: 1;
 63	unsigned int time_real: 1;
 64	int time_queue;
 65	
 66	/* capability, inport, output, sync */
 67	unsigned int capability;	/* port capability bits */
 68	unsigned int type;		/* port type bits */
 69
 70	/* supported channels */
 71	int midi_channels;
 72	int midi_voices;
 73	int synth_voices;
 74		
 75};
 76
 77struct snd_seq_client;
 78
 79/* return pointer to port structure and lock port */
 80struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client, int num);
 81
 82/* search for next port - port is locked if found */
 83struct snd_seq_client_port *snd_seq_port_query_nearest(struct snd_seq_client *client,
 84						       struct snd_seq_port_info *pinfo);
 85
 86/* unlock the port */
 87#define snd_seq_port_unlock(port) snd_use_lock_free(&(port)->use_lock)
 88
 89/* create a port, port number is returned (-1 on failure) */
 90struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, int port_index);
 91
 92/* delete a port */
 93int snd_seq_delete_port(struct snd_seq_client *client, int port);
 94
 95/* delete all ports */
 96int snd_seq_delete_all_ports(struct snd_seq_client *client);
 97
 98/* set port info fields */
 99int snd_seq_set_port_info(struct snd_seq_client_port *port,
100			  struct snd_seq_port_info *info);
101
102/* get port info fields */
103int snd_seq_get_port_info(struct snd_seq_client_port *port,
104			  struct snd_seq_port_info *info);
105
106/* add subscriber to subscription list */
107int snd_seq_port_connect(struct snd_seq_client *caller,
108			 struct snd_seq_client *s, struct snd_seq_client_port *sp,
109			 struct snd_seq_client *d, struct snd_seq_client_port *dp,
110			 struct snd_seq_port_subscribe *info);
111
112/* remove subscriber from subscription list */ 
113int snd_seq_port_disconnect(struct snd_seq_client *caller,
114			    struct snd_seq_client *s, struct snd_seq_client_port *sp,
115			    struct snd_seq_client *d, struct snd_seq_client_port *dp,
116			    struct snd_seq_port_subscribe *info);
117
118/* subscribe port */
119int snd_seq_port_subscribe(struct snd_seq_client_port *port,
120			   struct snd_seq_port_subscribe *info);
121
122/* get matched subscriber */
123int snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp,
124				  struct snd_seq_addr *dest_addr,
125				  struct snd_seq_port_subscribe *subs);
126
127#endif
v5.9
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 *   ALSA sequencer Ports 
  4 *   Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
  5 */
  6#ifndef __SND_SEQ_PORTS_H
  7#define __SND_SEQ_PORTS_H
  8
  9#include <sound/seq_kernel.h>
 10#include "seq_lock.h"
 11
 12/* list of 'exported' ports */
 13
 14/* Client ports that are not exported are still accessible, but are
 15 anonymous ports. 
 16 
 17 If a port supports SUBSCRIPTION, that port can send events to all
 18 subscribersto a special address, with address
 19 (queue==SNDRV_SEQ_ADDRESS_SUBSCRIBERS). The message is then send to all
 20 recipients that are registered in the subscription list. A typical
 21 application for these SUBSCRIPTION events is handling of incoming MIDI
 22 data. The port doesn't 'know' what other clients are interested in this
 23 message. If for instance a MIDI recording application would like to receive
 24 the events from that port, it will first have to subscribe with that port.
 25 
 26*/
 27
 28struct snd_seq_subscribers {
 29	struct snd_seq_port_subscribe info;	/* additional info */
 30	struct list_head src_list;	/* link of sources */
 31	struct list_head dest_list;	/* link of destinations */
 32	atomic_t ref_count;
 33};
 34
 35struct snd_seq_port_subs_info {
 36	struct list_head list_head;	/* list of subscribed ports */
 37	unsigned int count;		/* count of subscribers */
 38	unsigned int exclusive: 1;	/* exclusive mode */
 39	struct rw_semaphore list_mutex;
 40	rwlock_t list_lock;
 41	int (*open)(void *private_data, struct snd_seq_port_subscribe *info);
 42	int (*close)(void *private_data, struct snd_seq_port_subscribe *info);
 43};
 44
 45struct snd_seq_client_port {
 46
 47	struct snd_seq_addr addr;	/* client/port number */
 48	struct module *owner;		/* owner of this port */
 49	char name[64];			/* port name */	
 50	struct list_head list;		/* port list */
 51	snd_use_lock_t use_lock;
 52
 53	/* subscribers */
 54	struct snd_seq_port_subs_info c_src;	/* read (sender) list */
 55	struct snd_seq_port_subs_info c_dest;	/* write (dest) list */
 56
 57	int (*event_input)(struct snd_seq_event *ev, int direct, void *private_data,
 58			   int atomic, int hop);
 59	void (*private_free)(void *private_data);
 60	void *private_data;
 61	unsigned int closing : 1;
 62	unsigned int timestamping: 1;
 63	unsigned int time_real: 1;
 64	int time_queue;
 65	
 66	/* capability, inport, output, sync */
 67	unsigned int capability;	/* port capability bits */
 68	unsigned int type;		/* port type bits */
 69
 70	/* supported channels */
 71	int midi_channels;
 72	int midi_voices;
 73	int synth_voices;
 74		
 75};
 76
 77struct snd_seq_client;
 78
 79/* return pointer to port structure and lock port */
 80struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client, int num);
 81
 82/* search for next port - port is locked if found */
 83struct snd_seq_client_port *snd_seq_port_query_nearest(struct snd_seq_client *client,
 84						       struct snd_seq_port_info *pinfo);
 85
 86/* unlock the port */
 87#define snd_seq_port_unlock(port) snd_use_lock_free(&(port)->use_lock)
 88
 89/* create a port, port number is returned (-1 on failure) */
 90struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, int port_index);
 91
 92/* delete a port */
 93int snd_seq_delete_port(struct snd_seq_client *client, int port);
 94
 95/* delete all ports */
 96int snd_seq_delete_all_ports(struct snd_seq_client *client);
 97
 98/* set port info fields */
 99int snd_seq_set_port_info(struct snd_seq_client_port *port,
100			  struct snd_seq_port_info *info);
101
102/* get port info fields */
103int snd_seq_get_port_info(struct snd_seq_client_port *port,
104			  struct snd_seq_port_info *info);
105
106/* add subscriber to subscription list */
107int snd_seq_port_connect(struct snd_seq_client *caller,
108			 struct snd_seq_client *s, struct snd_seq_client_port *sp,
109			 struct snd_seq_client *d, struct snd_seq_client_port *dp,
110			 struct snd_seq_port_subscribe *info);
111
112/* remove subscriber from subscription list */ 
113int snd_seq_port_disconnect(struct snd_seq_client *caller,
114			    struct snd_seq_client *s, struct snd_seq_client_port *sp,
115			    struct snd_seq_client *d, struct snd_seq_client_port *dp,
116			    struct snd_seq_port_subscribe *info);
117
118/* subscribe port */
119int snd_seq_port_subscribe(struct snd_seq_client_port *port,
120			   struct snd_seq_port_subscribe *info);
121
122/* get matched subscriber */
123int snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp,
124				  struct snd_seq_addr *dest_addr,
125				  struct snd_seq_port_subscribe *subs);
126
127#endif