31 |
int g_dsp_fd; |
int g_dsp_fd; |
32 |
BOOL g_dsp_busy; |
BOOL g_dsp_busy; |
33 |
|
|
34 |
static struct audio_packet { |
static struct audio_packet |
35 |
|
{ |
36 |
struct stream s; |
struct stream s; |
37 |
uint16 tick; |
uint16 tick; |
38 |
uint8 index; |
uint8 index; |
44 |
{ |
{ |
45 |
char *dsp_dev = "/dev/dsp"; |
char *dsp_dev = "/dev/dsp"; |
46 |
|
|
47 |
if ((g_dsp_fd = open(dsp_dev, O_WRONLY|O_NONBLOCK)) == -1) |
if ((g_dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1) |
48 |
{ |
{ |
49 |
perror(dsp_dev); |
perror(dsp_dev); |
50 |
return False; |
return False; |
51 |
} |
} |
52 |
|
|
53 |
/* Non-blocking so that user interface is responsive */ |
/* Non-blocking so that user interface is responsive */ |
54 |
fcntl(g_dsp_fd, F_SETFL, fcntl(g_dsp_fd, F_GETFL)|O_NONBLOCK); |
fcntl(g_dsp_fd, F_SETFL, fcntl(g_dsp_fd, F_GETFL) | O_NONBLOCK); |
55 |
return True; |
return True; |
56 |
} |
} |
57 |
|
|
62 |
} |
} |
63 |
|
|
64 |
BOOL |
BOOL |
65 |
wave_out_format_supported(WAVEFORMATEX *pwfx) |
wave_out_format_supported(WAVEFORMATEX * pwfx) |
66 |
{ |
{ |
67 |
if (pwfx->wFormatTag != WAVE_FORMAT_PCM) |
if (pwfx->wFormatTag != WAVE_FORMAT_PCM) |
68 |
return False; |
return False; |
75 |
} |
} |
76 |
|
|
77 |
BOOL |
BOOL |
78 |
wave_out_set_format(WAVEFORMATEX *pwfx) |
wave_out_set_format(WAVEFORMATEX * pwfx) |
79 |
{ |
{ |
80 |
int speed, channels, format; |
int speed, channels, format; |
81 |
|
|
118 |
{ |
{ |
119 |
uint32 volume; |
uint32 volume; |
120 |
|
|
121 |
volume = left/(65536/100); |
volume = left / (65536 / 100); |
122 |
volume |= right/(65536/100) << 8; |
volume |= right / (65536 / 100) << 8; |
123 |
if (ioctl(g_dsp_fd, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1) |
if (ioctl(g_dsp_fd, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1) |
124 |
{ |
{ |
125 |
perror("MIXER_WRITE(SOUND_MIXER_PCM)"); |
perror("MIXER_WRITE(SOUND_MIXER_PCM)"); |
171 |
packet = &packet_queue[queue_lo]; |
packet = &packet_queue[queue_lo]; |
172 |
out = &packet->s; |
out = &packet->s; |
173 |
|
|
174 |
len = write(g_dsp_fd, out->p, out->end-out->p); |
len = write(g_dsp_fd, out->p, out->end - out->p); |
175 |
if (len == -1) |
if (len == -1) |
176 |
{ |
{ |
177 |
if (errno != EWOULDBLOCK) |
if (errno != EWOULDBLOCK) |