/** @file
 * Wrappers for creating an ALSA MIDI sequencer client with i/o ports.
 */

#pragma once
#include <alsa/asoundlib.h>


typedef struct alsa_seq_client_s {
    snd_seq_t* handle;
    int client_id;
    int in_port;
    int out_port;
} alsa_seq_client_t;

typedef snd_seq_event_t* (*client_loop_cb_t)(snd_seq_event_t*, void*);

/** Initialize a new handle and client with the given name. */
int client_open(alsa_seq_client_t*, const char* name);

/** Close ports and handle. */
void client_close(alsa_seq_client_t*);

/** Read all pending input events and write callback results back out. */
void client_input_loop(alsa_seq_client_t*, client_loop_cb_t, void*);