Blame test/seq-decoder.c

Packit 4a16fb
/*
Packit 4a16fb
 *  Simple event decoder
Packit 4a16fb
 */
Packit 4a16fb
Packit 4a16fb
static char *event_names[256] = {
Packit 4a16fb
	[SND_SEQ_EVENT_SYSTEM]=	"System",
Packit 4a16fb
	[SND_SEQ_EVENT_RESULT]=	"Result",
Packit 4a16fb
	[SND_SEQ_EVENT_NOTE]=	"Note",
Packit 4a16fb
	[SND_SEQ_EVENT_NOTEON]=	"Note On",
Packit 4a16fb
	[SND_SEQ_EVENT_NOTEOFF]=	"Note Off",
Packit 4a16fb
	[SND_SEQ_EVENT_KEYPRESS]=	"Key Pressure",
Packit 4a16fb
	[SND_SEQ_EVENT_CONTROLLER]=	"Controller",
Packit 4a16fb
	[SND_SEQ_EVENT_PGMCHANGE]=	"Program Change",
Packit 4a16fb
	[SND_SEQ_EVENT_CHANPRESS]=	"Channel Pressure",
Packit 4a16fb
	[SND_SEQ_EVENT_PITCHBEND]=	"Pitchbend",
Packit 4a16fb
	[SND_SEQ_EVENT_CONTROL14]=	"Control14",
Packit 4a16fb
	[SND_SEQ_EVENT_NONREGPARAM]=	"Nonregparam",
Packit 4a16fb
	[SND_SEQ_EVENT_REGPARAM]=		"Regparam",
Packit 4a16fb
	[SND_SEQ_EVENT_SONGPOS]=	"Song Position",
Packit 4a16fb
	[SND_SEQ_EVENT_SONGSEL]=	"Song Select",
Packit 4a16fb
	[SND_SEQ_EVENT_QFRAME]=	"Qframe",
Packit 4a16fb
	[SND_SEQ_EVENT_TIMESIGN]=	"SMF Time Signature",
Packit 4a16fb
	[SND_SEQ_EVENT_KEYSIGN]=	"SMF Key Signature",
Packit 4a16fb
	[SND_SEQ_EVENT_START]=	"Start",
Packit 4a16fb
	[SND_SEQ_EVENT_CONTINUE]=	"Continue",
Packit 4a16fb
	[SND_SEQ_EVENT_STOP]=	"Stop",
Packit 4a16fb
	[SND_SEQ_EVENT_SETPOS_TICK]=	"Set Position Tick",
Packit 4a16fb
	[SND_SEQ_EVENT_SETPOS_TIME]=	"Set Position Time",
Packit 4a16fb
	[SND_SEQ_EVENT_TEMPO]=	"Tempo",
Packit 4a16fb
	[SND_SEQ_EVENT_CLOCK]=	"Clock",
Packit 4a16fb
	[SND_SEQ_EVENT_TICK]=	"Tick",
Packit 4a16fb
	[SND_SEQ_EVENT_TUNE_REQUEST]=	"Tune Request",
Packit 4a16fb
	[SND_SEQ_EVENT_RESET]=	"Reset",
Packit 4a16fb
	[SND_SEQ_EVENT_SENSING]=	"Active Sensing",
Packit 4a16fb
	[SND_SEQ_EVENT_ECHO]=	"Echo",
Packit 4a16fb
	[SND_SEQ_EVENT_OSS]=	"OSS",
Packit 4a16fb
	[SND_SEQ_EVENT_CLIENT_START]=	"Client Start",
Packit 4a16fb
	[SND_SEQ_EVENT_CLIENT_EXIT]=	"Client Exit",
Packit 4a16fb
	[SND_SEQ_EVENT_CLIENT_CHANGE]=	"Client Change",
Packit 4a16fb
	[SND_SEQ_EVENT_PORT_START]=	"Port Start",
Packit 4a16fb
	[SND_SEQ_EVENT_PORT_EXIT]=	"Port Exit",
Packit 4a16fb
	[SND_SEQ_EVENT_PORT_CHANGE]=	"Port Change",
Packit 4a16fb
	[SND_SEQ_EVENT_PORT_SUBSCRIBED]=	"Port Subscribed",
Packit 4a16fb
	[SND_SEQ_EVENT_PORT_UNSUBSCRIBED]=	"Port Unsubscribed",
Packit 4a16fb
#if 0
Packit 4a16fb
	[SND_SEQ_EVENT_SAMPLE]=	"Sample",
Packit 4a16fb
	[SND_SEQ_EVENT_SAMPLE_CLUSTER]=	"Sample Cluster",
Packit 4a16fb
	[SND_SEQ_EVENT_SAMPLE_START]=	"Sample Start",
Packit 4a16fb
	[SND_SEQ_EVENT_SAMPLE_STOP]=	"Sample Stop",
Packit 4a16fb
	[SND_SEQ_EVENT_SAMPLE_FREQ]=	"Sample Freq",
Packit 4a16fb
	[SND_SEQ_EVENT_SAMPLE_VOLUME]=	"Sample Volume",
Packit 4a16fb
	[SND_SEQ_EVENT_SAMPLE_LOOP]=	"Sample Loop",
Packit 4a16fb
	[SND_SEQ_EVENT_SAMPLE_POSITION]=	"Sample Position",
Packit 4a16fb
	[SND_SEQ_EVENT_SAMPLE_PRIVATE1]=	"Sample Private1",
Packit 4a16fb
#endif
Packit 4a16fb
	[SND_SEQ_EVENT_USR0]=	"User 0",
Packit 4a16fb
	[SND_SEQ_EVENT_USR1]=	"User 1",
Packit 4a16fb
	[SND_SEQ_EVENT_USR2]=	"User 2",
Packit 4a16fb
	[SND_SEQ_EVENT_USR3]=	"User 3",
Packit 4a16fb
	[SND_SEQ_EVENT_USR4]=	"User 4",
Packit 4a16fb
	[SND_SEQ_EVENT_USR5]=	"User 5",
Packit 4a16fb
	[SND_SEQ_EVENT_USR6]=	"User 6",
Packit 4a16fb
	[SND_SEQ_EVENT_USR7]=	"User 7",
Packit 4a16fb
	[SND_SEQ_EVENT_USR8]=	"User 8",
Packit 4a16fb
	[SND_SEQ_EVENT_USR9]=	"User 9",
Packit 4a16fb
#if 0
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_BEGIN]=	"Instr Begin",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_END]=	"Instr End",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_INFO]=	"Instr Info",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_INFO_RESULT]=	"Instr Info Result",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_FINFO]=	"Instr Font Info",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_FINFO_RESULT]=	"Instr Font Info Result",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_RESET]=	"Instr Reset",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_STATUS]=	"Instr Status",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_STATUS_RESULT]=	"Instr Status Result",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_PUT]=	"Instr Put",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_GET]=	"Instr Get",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_GET_RESULT]=	"Instr Get Result",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_FREE]=	"Instr Free",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_LIST]=	"Instr List",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_LIST_RESULT]=	"Instr List Result",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_CLUSTER]=	"Instr Cluster",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_CLUSTER_GET]=	"Instr Cluster Get",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_CLUSTER_RESULT]=	"Instr Cluster Result",
Packit 4a16fb
	[SND_SEQ_EVENT_INSTR_CHANGE]=	"Instr Change",
Packit 4a16fb
#endif
Packit 4a16fb
	[SND_SEQ_EVENT_SYSEX]=	"Sysex",
Packit 4a16fb
	[SND_SEQ_EVENT_BOUNCE]=	"Bounce",
Packit 4a16fb
	[SND_SEQ_EVENT_USR_VAR0]=	"User Var0",
Packit 4a16fb
	[SND_SEQ_EVENT_USR_VAR1]=	"User Var1",
Packit 4a16fb
	[SND_SEQ_EVENT_USR_VAR2]=	"User Var2",
Packit 4a16fb
	[SND_SEQ_EVENT_USR_VAR3]=	"User Var3",
Packit 4a16fb
	[SND_SEQ_EVENT_USR_VAR4]=	"User Var4",
Packit 4a16fb
#if 0
Packit 4a16fb
	[SND_SEQ_EVENT_IPCSHM]=	"IPC Shm",
Packit 4a16fb
	[SND_SEQ_EVENT_USR_VARIPC0]=	"User IPC0",
Packit 4a16fb
	[SND_SEQ_EVENT_USR_VARIPC1]=	"User IPC1",
Packit 4a16fb
	[SND_SEQ_EVENT_USR_VARIPC2]=	"User IPC2",
Packit 4a16fb
	[SND_SEQ_EVENT_USR_VARIPC3]=	"User IPC3",
Packit 4a16fb
	[SND_SEQ_EVENT_USR_VARIPC4]=	"User IPC4",
Packit 4a16fb
#endif
Packit 4a16fb
	[SND_SEQ_EVENT_NONE]=	"None",
Packit 4a16fb
};
Packit 4a16fb
Packit 4a16fb
int decode_event(snd_seq_event_t * ev)
Packit 4a16fb
{
Packit 4a16fb
	char *space = "         ";
Packit 4a16fb
Packit 4a16fb
	printf("EVENT>>> Type = %d, flags = 0x%x", ev->type, ev->flags);
Packit 4a16fb
	switch (ev->flags & SND_SEQ_TIME_STAMP_MASK) {
Packit 4a16fb
	case SND_SEQ_TIME_STAMP_TICK:
Packit 4a16fb
		printf(", time = %d ticks",
Packit 4a16fb
		       ev->time.tick);
Packit 4a16fb
		break;
Packit 4a16fb
	case SND_SEQ_TIME_STAMP_REAL:
Packit 4a16fb
		printf(", time = %d.%09d",
Packit 4a16fb
		       (int)ev->time.time.tv_sec,
Packit 4a16fb
		       (int)ev->time.time.tv_nsec);
Packit 4a16fb
		break;
Packit 4a16fb
	}
Packit 4a16fb
	printf("\n%sSource = %d.%d, dest = %d.%d, queue = %d\n",
Packit 4a16fb
	       space,
Packit 4a16fb
	       ev->source.client,
Packit 4a16fb
	       ev->source.port,
Packit 4a16fb
	       ev->dest.client,
Packit 4a16fb
	       ev->dest.port,
Packit 4a16fb
	       ev->queue);
Packit 4a16fb
Packit 4a16fb
	if (event_names[ev->type])
Packit 4a16fb
		printf("%sEvent = %s", space, event_names[ev->type]);
Packit 4a16fb
	else
Packit 4a16fb
		printf("%sEvent = Reserved %d\n", space, ev->type);
Packit 4a16fb
	/* decode the actual event data... */
Packit 4a16fb
	switch (ev->type) {
Packit 4a16fb
	case SND_SEQ_EVENT_NOTE:
Packit 4a16fb
		printf("; ch=%d, note=%d, velocity=%d, off_velocity=%d, duration=%d\n",
Packit 4a16fb
		       ev->data.note.channel,
Packit 4a16fb
		       ev->data.note.note,
Packit 4a16fb
		       ev->data.note.velocity,
Packit 4a16fb
		       ev->data.note.off_velocity,
Packit 4a16fb
		       ev->data.note.duration);
Packit 4a16fb
		break;
Packit 4a16fb
Packit 4a16fb
	case SND_SEQ_EVENT_NOTEON:
Packit 4a16fb
	case SND_SEQ_EVENT_NOTEOFF:
Packit 4a16fb
	case SND_SEQ_EVENT_KEYPRESS:
Packit 4a16fb
		printf("; ch=%d, note=%d, velocity=%d\n",
Packit 4a16fb
		       ev->data.note.channel,
Packit 4a16fb
		       ev->data.note.note,
Packit 4a16fb
		       ev->data.note.velocity);
Packit 4a16fb
		break;
Packit 4a16fb
		
Packit 4a16fb
	case SND_SEQ_EVENT_CONTROLLER:
Packit 4a16fb
		printf("; ch=%d, param=%i, value=%i\n",
Packit 4a16fb
		       ev->data.control.channel,
Packit 4a16fb
		       ev->data.control.param,
Packit 4a16fb
		       ev->data.control.value);
Packit 4a16fb
		break;
Packit 4a16fb
Packit 4a16fb
	case SND_SEQ_EVENT_PGMCHANGE:
Packit 4a16fb
		printf("; ch=%d, program=%i\n",
Packit 4a16fb
		       ev->data.control.channel,
Packit 4a16fb
		       ev->data.control.value);
Packit 4a16fb
		break;
Packit 4a16fb
			
Packit 4a16fb
	case SND_SEQ_EVENT_CHANPRESS:
Packit 4a16fb
	case SND_SEQ_EVENT_PITCHBEND:
Packit 4a16fb
		printf("; ch=%d, value=%i\n",
Packit 4a16fb
		       ev->data.control.channel,
Packit 4a16fb
		       ev->data.control.value);
Packit 4a16fb
		break;
Packit 4a16fb
			
Packit 4a16fb
	case SND_SEQ_EVENT_SYSEX:
Packit 4a16fb
		{
Packit 4a16fb
			unsigned char *sysex = (unsigned char *) ev + sizeof(snd_seq_event_t);
Packit 4a16fb
			unsigned int c;
Packit 4a16fb
			
Packit 4a16fb
			printf("; len=%d [", ev->data.ext.len);
Packit 4a16fb
			
Packit 4a16fb
			for (c = 0; c < ev->data.ext.len; c++) {
Packit 4a16fb
				printf("%02x%s", sysex[c], c < ev->data.ext.len - 1 ? ":" : "");
Packit 4a16fb
			}
Packit 4a16fb
			printf("]\n");
Packit 4a16fb
		}
Packit 4a16fb
		break;
Packit 4a16fb
			
Packit 4a16fb
	case SND_SEQ_EVENT_QFRAME:
Packit 4a16fb
		printf("; frame=0x%02x\n", ev->data.control.value);
Packit 4a16fb
		break;
Packit 4a16fb
		
Packit 4a16fb
	case SND_SEQ_EVENT_CLOCK:
Packit 4a16fb
	case SND_SEQ_EVENT_START:
Packit 4a16fb
	case SND_SEQ_EVENT_CONTINUE:
Packit 4a16fb
	case SND_SEQ_EVENT_STOP:
Packit 4a16fb
		printf("; queue = %i\n", ev->data.queue.queue);
Packit 4a16fb
		break;
Packit 4a16fb
Packit 4a16fb
	case SND_SEQ_EVENT_SENSING:
Packit 4a16fb
		printf("\n");
Packit 4a16fb
		break;
Packit 4a16fb
Packit 4a16fb
	case SND_SEQ_EVENT_ECHO:
Packit 4a16fb
		{
Packit 4a16fb
			int i;
Packit 4a16fb
				
Packit 4a16fb
			printf("; ");
Packit 4a16fb
			for (i = 0; i < 8; i++) {
Packit 4a16fb
				printf("%02i%s", ev->data.raw8.d[i], i < 7 ? ":" : "\n");
Packit 4a16fb
			}
Packit 4a16fb
		}
Packit 4a16fb
		break;
Packit 4a16fb
			
Packit 4a16fb
	case SND_SEQ_EVENT_CLIENT_START:
Packit 4a16fb
	case SND_SEQ_EVENT_CLIENT_EXIT:
Packit 4a16fb
	case SND_SEQ_EVENT_CLIENT_CHANGE:
Packit 4a16fb
		printf("; client=%i\n", ev->data.addr.client);
Packit 4a16fb
		break;
Packit 4a16fb
Packit 4a16fb
	case SND_SEQ_EVENT_PORT_START:
Packit 4a16fb
	case SND_SEQ_EVENT_PORT_EXIT:
Packit 4a16fb
	case SND_SEQ_EVENT_PORT_CHANGE:
Packit 4a16fb
		printf("; client=%i, port = %i\n", ev->data.addr.client, ev->data.addr.port);
Packit 4a16fb
		break;
Packit 4a16fb
Packit 4a16fb
	case SND_SEQ_EVENT_PORT_SUBSCRIBED:
Packit 4a16fb
	case SND_SEQ_EVENT_PORT_UNSUBSCRIBED:
Packit 4a16fb
		printf("; %i:%i -> %i:%i\n",
Packit 4a16fb
		       ev->data.connect.sender.client, ev->data.connect.sender.port,
Packit 4a16fb
		       ev->data.connect.dest.client, ev->data.connect.dest.port);
Packit 4a16fb
		break;
Packit 4a16fb
Packit 4a16fb
	default:
Packit 4a16fb
		printf("; not implemented\n");
Packit 4a16fb
	}
Packit 4a16fb
Packit 4a16fb
Packit 4a16fb
	switch (ev->flags & SND_SEQ_EVENT_LENGTH_MASK) {
Packit 4a16fb
	case SND_SEQ_EVENT_LENGTH_FIXED:
Packit 4a16fb
		return sizeof(snd_seq_event_t);
Packit 4a16fb
Packit 4a16fb
	case SND_SEQ_EVENT_LENGTH_VARIABLE:
Packit 4a16fb
		return sizeof(snd_seq_event_t) + ev->data.ext.len;
Packit 4a16fb
	}
Packit 4a16fb
Packit 4a16fb
	return 0;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
void event_decoder_start_timer(snd_seq_t *handle, int queue,
Packit 4a16fb
			       int client ATTRIBUTE_UNUSED,
Packit 4a16fb
			       int port ATTRIBUTE_UNUSED)
Packit 4a16fb
{
Packit 4a16fb
	int err;
Packit 4a16fb
Packit 4a16fb
	if ((err = snd_seq_start_queue(handle, queue, NULL))<0)
Packit 4a16fb
		fprintf(stderr, "Timer event output error: %s\n", snd_strerror(err));
Packit 4a16fb
	while (snd_seq_drain_output(handle)>0)
Packit 4a16fb
		sleep(1);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
void event_decoder(snd_seq_t *handle, int argc, char *argv[])
Packit 4a16fb
{
Packit 4a16fb
	snd_seq_event_t *ev;
Packit 4a16fb
	snd_seq_port_info_t *pinfo;
Packit 4a16fb
	snd_seq_port_subscribe_t *sub;
Packit 4a16fb
	snd_seq_addr_t addr;
Packit 4a16fb
	int client, port, queue, max, err, v1, v2;
Packit 4a16fb
	char *ptr;
Packit 4a16fb
	struct pollfd *pfds;
Packit 4a16fb
Packit 4a16fb
	if ((client = snd_seq_client_id(handle))<0) {
Packit 4a16fb
		fprintf(stderr, "Cannot determine client number: %s\n", snd_strerror(client));
Packit 4a16fb
		return;
Packit 4a16fb
	}
Packit 4a16fb
	printf("Client ID = %i\n", client);
Packit 4a16fb
	if ((queue = snd_seq_alloc_queue(handle))<0) {
Packit 4a16fb
		fprintf(stderr, "Cannot allocate queue: %s\n", snd_strerror(queue));
Packit 4a16fb
		return;
Packit 4a16fb
	}
Packit 4a16fb
	printf("Queue ID = %i\n", queue);
Packit 4a16fb
	if ((err = snd_seq_nonblock(handle, 1))<0)
Packit 4a16fb
		fprintf(stderr, "Cannot set nonblock mode: %s\n", snd_strerror(err));
Packit 4a16fb
	snd_seq_port_info_alloca(&pinfo);
Packit 4a16fb
	snd_seq_port_info_set_name(pinfo, "Input");
Packit 4a16fb
	snd_seq_port_info_set_type(pinfo, SND_SEQ_PORT_TYPE_MIDI_GENERIC);
Packit 4a16fb
	snd_seq_port_info_set_capability(pinfo, SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_WRITE);
Packit 4a16fb
Packit 4a16fb
	/* Enable timestamping for events sent by external subscribers. */
Packit 4a16fb
	snd_seq_port_info_set_timestamping(pinfo, 1);
Packit 4a16fb
	snd_seq_port_info_set_timestamp_real(pinfo, 1);
Packit 4a16fb
	snd_seq_port_info_set_timestamp_queue(pinfo, queue);
Packit 4a16fb
Packit 4a16fb
	if ((err = snd_seq_create_port(handle, pinfo)) < 0) {
Packit 4a16fb
		fprintf(stderr, "Cannot create input port: %s\n", snd_strerror(err));
Packit 4a16fb
		return;
Packit 4a16fb
	}
Packit 4a16fb
	port = snd_seq_port_info_get_port(pinfo);
Packit 4a16fb
	event_decoder_start_timer(handle, queue, client, port);
Packit 4a16fb
Packit 4a16fb
	snd_seq_port_subscribe_alloca(&sub);
Packit 4a16fb
	addr.client = SND_SEQ_CLIENT_SYSTEM;
Packit 4a16fb
	addr.port = SND_SEQ_PORT_SYSTEM_ANNOUNCE;
Packit 4a16fb
	snd_seq_port_subscribe_set_sender(sub, &addr);
Packit 4a16fb
	addr.client = client;
Packit 4a16fb
	addr.port = port;
Packit 4a16fb
	snd_seq_port_subscribe_set_dest(sub, &addr);
Packit 4a16fb
	snd_seq_port_subscribe_set_queue(sub, queue);
Packit 4a16fb
	snd_seq_port_subscribe_set_time_update(sub, 1);
Packit 4a16fb
	snd_seq_port_subscribe_set_time_real(sub, 1);
Packit 4a16fb
	if ((err = snd_seq_subscribe_port(handle, sub))<0) {
Packit 4a16fb
		fprintf(stderr, "Cannot subscribe announce port: %s\n", snd_strerror(err));
Packit 4a16fb
		return;
Packit 4a16fb
	}
Packit 4a16fb
Packit 4a16fb
	addr.client = SND_SEQ_CLIENT_SYSTEM;
Packit 4a16fb
	addr.port = SND_SEQ_PORT_SYSTEM_TIMER;
Packit 4a16fb
	snd_seq_port_subscribe_set_sender(sub, &addr);
Packit 4a16fb
	if ((err = snd_seq_subscribe_port(handle, sub))<0) {
Packit 4a16fb
		fprintf(stderr, "Cannot subscribe timer port: %s\n", snd_strerror(err));
Packit 4a16fb
		return;
Packit 4a16fb
	}
Packit 4a16fb
Packit 4a16fb
	for (max = 0; max < argc; max++) {
Packit 4a16fb
		ptr = argv[max];
Packit 4a16fb
		if (!ptr)
Packit 4a16fb
			continue;
Packit 4a16fb
		snd_seq_port_subscribe_set_time_real(sub, 0);
Packit 4a16fb
		if (tolower(*ptr) == 'r') {
Packit 4a16fb
			snd_seq_port_subscribe_set_time_real(sub, 1);
Packit 4a16fb
			ptr++;
Packit 4a16fb
		}
Packit 4a16fb
		if (sscanf(ptr, "%i.%i", &v1, &v2) != 2) {
Packit 4a16fb
			fprintf(stderr, "Wrong argument '%s'...\n", argv[max]);
Packit 4a16fb
			return;
Packit 4a16fb
		}
Packit 4a16fb
		addr.client = v1;
Packit 4a16fb
		addr.port = v2;
Packit 4a16fb
		snd_seq_port_subscribe_set_sender(sub, &addr);
Packit 4a16fb
		if ((err = snd_seq_subscribe_port(handle, sub))<0) {
Packit 4a16fb
			fprintf(stderr, "Cannot subscribe port %i from client %i: %s\n", v2, v1, snd_strerror(err));
Packit 4a16fb
			return;
Packit 4a16fb
		}
Packit 4a16fb
	}
Packit 4a16fb
	
Packit 4a16fb
	max = snd_seq_poll_descriptors_count(handle, POLLIN);
Packit 4a16fb
	pfds = alloca(sizeof(*pfds) * max);
Packit 4a16fb
	while (1) {
Packit 4a16fb
		snd_seq_poll_descriptors(handle, pfds, max, POLLIN);
Packit 4a16fb
		if (poll(pfds, max, -1) < 0)
Packit 4a16fb
			break;
Packit 4a16fb
		do {
Packit 4a16fb
			if ((err = snd_seq_event_input(handle, &ev))<0)
Packit 4a16fb
				break;
Packit 4a16fb
			if (!ev)
Packit 4a16fb
				continue;
Packit 4a16fb
			decode_event(ev);
Packit 4a16fb
			snd_seq_free_event(ev);
Packit 4a16fb
		} while (err > 0);
Packit 4a16fb
	}
Packit 4a16fb
}