1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
/*
Y Sound Systems
Client to Server Library Functions
Any Y client program needs to #include this file and link to
the library libY2.
For contact and programming information, see:
http://fox.mit.edu/xsw/yiff
*/
#ifndef YLIB_H
#define YLIB_H
#include <stdio.h>
#include <db.h>
#include <sys/types.h>
#include "Y.h"
/*
* Volume data structure:
*/
typedef struct {
/* Coefficient = (val / ((u_int16_t)-1)) */
u_int16_t left,
right;
} YVolumeStruct;
/*
* Event structures:
*/
/* Change mode event structure. */
typedef struct {
Boolean preset; /* Use preset? */
/* If preset is True, these members contain correct info. */
char mode_name[YAudioNameMax];
/* If preset is False, these members contain correct info. */
int sample_size;
int channels;
int sample_rate;
int direction;
int allow_fragmenting;
int num_fragments;
int fragment_size_bytes;
} YEventAudioChange;
/* Y server stats event structure. */
typedef struct {
int protocol_version_major;
int protocol_version_minor;
Coefficient cycle_load;
/* More items to be added in future. */
} YEventServerStats;
/* Change cycle event structure. */
typedef struct {
long cycle_us;
} YEventCycleChange;
/* Disconnect event structure. */
typedef struct {
int reason; /* Why you were disconnected. */
} YEventDisconnect;
/* Host add or remove event structure. */
typedef struct {
int op; /* 0 for remove, 1 for add. */
YIPUnion ip;
} YEventHost;
/* Sound kill event structure. */
typedef struct {
YID yid;
} YEventSoundKill;
/* Mixer event structure. */
typedef struct {
int code; /* Mixer device code. */
Coefficient value[YMixerValues]; /* Argument values. */
} YEventMixer;
/* Sound play event structure. */
typedef struct {
YID yid;
} YEventSoundPlay;
/* Sound object attributes event structure. */
typedef struct {
int format;
int sample_size;
int channels;
int sample_rate;
char path[YPathMax];
} YEventSoundObjectAttributes;
/* Shutdown event structure. */
typedef struct {
int reason; /* Why server shut down. */
} YEventShutdown;
/* Sync event structure. */
typedef struct {
long cycle_ahead_us;
} YEventSync;
/* Audio stats structure. */
typedef struct {
int cycle_set;
long cycle_us;
long compensated_cycle_us;
long write_ahead_us;
long cumulative_latency_us;
int sample_size;
int channels;
int sample_rate;
int bytes_per_sec;
Boolean allow_fragments;
int num_fragments;
int fragment_size;
Boolean flip_stereo;
int direction;
} YEventAudioStats;
/* Main yiff event structure. */
typedef struct {
int type; /* Event type code (aka the op code). */
YEventAudioChange audio;
YEventServerStats serverstats;
YEventCycleChange cycle;
YEventDisconnect disconnect;
YEventHost host;
YEventSoundKill kill;
YEventMixer mixer;
YEventSoundPlay play;
YEventSoundObjectAttributes sndobjattributes;
YEventShutdown shutdown;
YEventSync sync;
YEventAudioStats audiostats;
} YEvent;
/*
* Connection to YIFF server structure:
*/
typedef struct {
int fd;
int we_started_server;
/* Queued events. */
int total_queued_events;
YEvent *queued_event;
YID prev_generated_yid;
/* Receive buffer. */
u_int8_t *buf;
YDataLength buf_len, /* Allocated length of buf. */
buf_cont; /* Contents in buf. */
} YConnection;
/*
* Audio mode list structure:
*/
typedef struct {
char name[YAudioNameMax];
int sample_rate;
int channels;
int sample_size;
int fragment_size_bytes;
char direction;
char allow_fragmenting;
int num_fragments;
} YAudioModeValuesStruct;
/*
* Functions:
*/
extern YConnection *YOpenConnection(
char *start_arg, /* Can be NULL for don't start if needed. */
char *con_arg /* Should not be NULL. */
);
extern int YSetAudioModeValues(
YConnection *con,
int sample_size,
int channels,
int sample_rate,
int direction, /* 0 = play, only 0 is supported. */
int allow_fragmenting,
int num_fragments,
int fragment_size
);
extern int YChangeAudioModePreset(YConnection *con, char *name);
extern int YGetAudioStats(YConnection *con, YEventAudioStats *buf);
extern YAudioModeValuesStruct **YGetAudioModes(
YConnection *con,
int *count
);
extern void YFreeAudioModesList(YAudioModeValuesStruct **list, int count);
extern int YGetServerStats(YConnection *con, YEventServerStats *buf);
extern long YCalculateCycle(
YConnection *con,
int sample_rate, int channels,
int sample_size, int fragment_size
);
extern int YSetCycle(YConnection *con, long us);
extern void YSyncAll(YConnection *con, Boolean block);
extern int YAddHost(YConnection *con, YIPUnion *ip);
extern int YRemoveHost(YConnection *con, YIPUnion *ip);
extern int YSetMixerChannel(
YConnection *con,
int mixer_channel_code, /* One of YMixerCode*. */
Coefficient value1, /* 0 to 1. */
Coefficient value2 /* 0 to 1. */
);
extern int YGetMixerChannel(
YConnection *con,
int mixer_channel_code, /* One of YMixerCode*. */
Coefficient *value1, /* 0 to 1. */
Coefficient *value2 /* 0 to 1. */
);
extern YID YStartPlaySoundObject(
YConnection *con,
char *path, /* Path on disk on server's computer. */
YDataPosition pos,
Coefficient left_volume,
Coefficient right_volume,
int repeats /* Can be -1 to repeat infinatly. */
);
extern int YGetSoundObjectAttributes(
YConnection *con,
char *path,
YEventSoundObjectAttributes *buf
);
extern void YDestroyPlaySoundObject(YConnection *con, YID yid);
extern void YCloseConnection(YConnection *con, Boolean no_shutdown);
extern void YShutdownServer(YConnection *con);
extern int YGetNextEvent(
YConnection *con,
YEvent *event,
Boolean block
);
extern void YPutBackEvent(YConnection *con, YEvent *event);
#endif /* YLIB_H */
|