1/*
2 *  ALSA client/server header file
3 *  Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
4 *
5 *   This library is free software; you can redistribute it and/or modify
6 *   it under the terms of the GNU Lesser General Public License as
7 *   published by the Free Software Foundation; either version 2.1 of
8 *   the License, or (at your option) any later version.
9 *
10 *   This program is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *   GNU Lesser General Public License for more details.
14 *
15 *   You should have received a copy of the GNU Lesser General Public
16 *   License along with this library; if not, write to the Free Software
17 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 *
19 */
20
21#include <netdb.h>
22#include "../src/pcm/pcm_local.h"
23#include "../src/control/control_local.h"
24
25int snd_receive_fd(int sock, void *data, size_t len, int *fd);
26int snd_is_local(struct hostent *hent);
27
28typedef enum _snd_dev_type {
29	SND_DEV_TYPE_PCM,
30	SND_DEV_TYPE_CONTROL,
31	SND_DEV_TYPE_RAWMIDI,
32	SND_DEV_TYPE_TIMER,
33	SND_DEV_TYPE_HWDEP,
34	SND_DEV_TYPE_SEQ,
35} snd_dev_type_t;
36
37typedef enum _snd_transport_type {
38	SND_TRANSPORT_TYPE_SHM,
39	SND_TRANSPORT_TYPE_TCP,
40} snd_transport_type_t;
41
42#define SND_PCM_IOCTL_HWSYNC		_IO ('A', 0x22)
43#define SND_PCM_IOCTL_STATE		_IO ('A', 0xf1)
44#define SND_PCM_IOCTL_MMAP		_IO ('A', 0xf2)
45#define SND_PCM_IOCTL_MUNMAP		_IO ('A', 0xf3)
46#define SND_PCM_IOCTL_MMAP_COMMIT	_IO ('A', 0xf4)
47#define SND_PCM_IOCTL_AVAIL_UPDATE	_IO ('A', 0xf5)
48#define SND_PCM_IOCTL_ASYNC		_IO ('A', 0xf6)
49#define SND_PCM_IOCTL_CLOSE		_IO ('A', 0xf7)
50#define SND_PCM_IOCTL_POLL_DESCRIPTOR	_IO ('A', 0xf8)
51#define SND_PCM_IOCTL_HW_PTR_FD		_IO ('A', 0xf9)
52#define SND_PCM_IOCTL_APPL_PTR_FD	_IO ('A', 0xfa)
53#define SND_PCM_IOCTL_FORWARD		_IO ('A', 0xfb)
54
55typedef struct {
56	snd_pcm_uframes_t ptr;
57	int use_mmap;
58	off_t offset;		/* for mmap */
59	int changed;
60} snd_pcm_shm_rbptr_t;
61
62typedef struct {
63	long result;
64	int cmd;
65	snd_pcm_shm_rbptr_t hw;
66	snd_pcm_shm_rbptr_t appl;
67	union {
68		struct {
69			int sig;
70			pid_t pid;
71		} async;
72		snd_pcm_info_t info;
73		snd_pcm_hw_params_t hw_refine;
74		snd_pcm_hw_params_t hw_params;
75		snd_pcm_sw_params_t sw_params;
76		snd_pcm_status_t status;
77		struct {
78			snd_pcm_uframes_t frames;
79		} avail;
80		struct {
81			snd_pcm_sframes_t frames;
82		} delay;
83		struct {
84			int enable;
85		} pause;
86		snd_pcm_channel_info_t channel_info;
87		struct {
88			snd_pcm_uframes_t frames;
89		} rewind;
90		struct {
91			snd_pcm_uframes_t frames;
92		} forward;
93		struct {
94			int fd;
95		} link;
96		struct {
97			snd_pcm_uframes_t offset;
98			snd_pcm_uframes_t frames;
99		} mmap_commit;
100		struct {
101			char use_mmap;
102			int shmid;
103			off_t offset;
104		} rbptr;
105	} u;
106	char data[0];
107} snd_pcm_shm_ctrl_t;
108
109#define PCM_SHM_SIZE sizeof(snd_pcm_shm_ctrl_t)
110
111#define SND_CTL_IOCTL_READ		_IOR('U', 0xf1, snd_ctl_event_t)
112#define SND_CTL_IOCTL_CLOSE		_IO ('U', 0xf2)
113#define SND_CTL_IOCTL_POLL_DESCRIPTOR	_IO ('U', 0xf3)
114#define SND_CTL_IOCTL_ASYNC		_IO ('U', 0xf4)
115
116typedef struct {
117	int result;
118	int cmd;
119	union {
120		struct {
121			int sig;
122			pid_t pid;
123		} async;
124		int device;
125		int subscribe_events;
126		snd_ctl_card_info_t card_info;
127		snd_ctl_elem_list_t element_list;
128		snd_ctl_elem_info_t element_info;
129		snd_ctl_elem_value_t element_read;
130		snd_ctl_elem_value_t element_write;
131		snd_ctl_elem_id_t element_lock;
132		snd_ctl_elem_id_t element_unlock;
133		snd_hwdep_info_t hwdep_info;
134		snd_pcm_info_t pcm_info;
135		int pcm_prefer_subdevice;
136		snd_rawmidi_info_t rawmidi_info;
137		int rawmidi_prefer_subdevice;
138		unsigned int power_state;
139		snd_ctl_event_t read;
140	} u;
141	char data[0];
142} snd_ctl_shm_ctrl_t;
143
144#define CTL_SHM_SIZE 65536
145#define CTL_SHM_DATA_MAXLEN (CTL_SHM_SIZE - offsetof(snd_ctl_shm_ctrl_t, data))
146
147typedef struct {
148	unsigned char dev_type;
149	unsigned char transport_type;
150	unsigned char stream;
151	unsigned char mode;
152	unsigned char namelen;
153	char name[0];
154} snd_client_open_request_t;
155
156typedef struct {
157	long result;
158	int cookie;
159} snd_client_open_answer_t;
160
161