/[pidim]/src/pidim_common.c
ViewVC logotype

Contents of /src/pidim_common.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Wed Aug 25 18:17:40 2010 UTC (10 years, 1 month ago) by ben
File MIME type: text/plain
File size: 1556 byte(s)
first import, some apps working
1 #include <alsa/asoundlib.h>
2
3 /* create a client handle */
4 snd_seq_t* alsa_open_client (const char* name)
5 {
6 snd_seq_t* handle;
7 int err;
8
9 err = snd_seq_open(&handle, "default", SND_SEQ_OPEN_INPUT|SND_SEQ_OPEN_OUTPUT, 0);
10 if (err < 0) {
11 return NULL;
12 }
13 snd_seq_set_client_name(handle, name);
14 return handle;
15 }
16
17 /* create an input port */
18 int alsa_open_input_port(snd_seq_t *handle, const char* name)
19 {
20 return snd_seq_create_simple_port(handle, name,
21 SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
22 SND_SEQ_PORT_TYPE_APPLICATION);
23 }
24
25 /* create an output port */
26 int alsa_open_output_port(snd_seq_t *handle, const char* name)
27 {
28 return snd_seq_create_simple_port(handle, name,
29 SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ,
30 SND_SEQ_PORT_TYPE_APPLICATION);
31 }
32
33 void alsa_init_queue(snd_seq_t *handle)
34 {
35 int queue_id;
36 queue_id = snd_seq_alloc_queue(handle);
37 snd_seq_set_client_pool_output(handle, 1);
38 }
39
40 void alsa_clear_queue(snd_seq_t *handle, int queue_id)
41 {
42
43 }
44
45 /* get the file descriptor of the first MIDI input port */
46 #if SND_LIB_MAJOR > 0 || SND_LIB_MINOR >= 6
47 /* FIXME: this is a dirty hack form XMBC code */
48 int alsa_get_fd(snd_seq_t *handle)
49 {
50 int pfds = snd_seq_poll_descriptors_count(handle, POLLIN);
51 if (pfds > 0) {
52 struct pollfd pfd;
53 if (snd_seq_poll_descriptors(handle, &pfd, 1, POLLIN) >= 0)
54 return pfd.fd;
55 }
56 return -1;
57 }
58 #endif

  ViewVC Help
Powered by ViewVC 1.1.26