blob: 6e4367eed7a7db16a19d1565f56a39b490dce290 (
plain)
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
|
/*
* Completely, utterly untested.. most likely broke
* Code's by George L. Coulouris
*/
#include <sys/audio.h>
#define ARCH_esd_audio_open
int esd_audio_open()
{
audio_init a_init;
audio_change a_change;
audio_control a_control;
int afd;
int mode = O_WRONLY;
int flag;
static const char device[] = "/dev/paud0/1";
if ((esd_audio_format & ESD_MASK_FUNC) == ESD_RECORD) {
fprintf(stderr, "No idea how to record audio on solaris, FIXME\n");
esd_audio_fd = -1;
return -1;
}
if ((afd = open(device, mode)) == -1) {
perror(device);
esd_audio_fd = -1;
return -1;
}
a_init.srate = esd_audio_rate;
if ((esd_audio_format & ESD_MASK_CHAN) == ESD_STEREO)
a_init.channels = 2;
else
a_init.channels = 1;
if ((esd_audio_format & ESD_MASK_BITS) == ESD_BITS16)
a_init.bits_per_sample = 16;
else
a_init.bits_per_sample = 8;
a_init.mode = PCM;
a_init.flags = FIXED | BIG_ENDIAN | TWOS_COMPLEMENT;
a_init.operation = PLAY;
a_change.balance = 0x3fff0000;
a_change.balance_delay = 0;
a_change.volume = 0x7fffffff;
a_change.volume_delay = 0;
a_change.monitor = AUDIO_IGNORE;
a_change.input = AUDIO_IGNORE;
a_change.output = OUTPUT_1;
a_control.ioctl_request = AUDIO_CHANGE;
a_control.position = 0;
a_control.request_info = &a_change;
if (ioctl(afd, AUDIO_INIT, &a_init) == -1) {
perror("AUDIO_INIT");
close(afd);
esd_audio_fd = -1;
return -1;
}
if (ioctl(afd, AUDIO_CONTROL, &a_control) == -1) {
perror("AUDIO_CONTROL");
close(afd);
esd_audio_fd = -1;
return -1;
}
a_control.ioctl_request = AUDIO_START;
if (ioctl(afd, AUDIO_CONTROL, &a_control) == -1) {
perror("AUDIO_CONTROL");
close(afd);
esd_audio_fd = -1;
return -1;
}
esd_audio_fd = afd;
return afd;
}
|