43 |
{ |
{ |
44 |
char *dsp_dev = "/dev/dsp"; |
char *dsp_dev = "/dev/dsp"; |
45 |
|
|
46 |
if ((g_dsp_fd = open(dsp_dev, O_WRONLY)) == -1) |
if ((g_dsp_fd = open(dsp_dev, O_WRONLY|O_NONBLOCK)) == -1) |
47 |
{ |
{ |
48 |
perror(dsp_dev); |
perror(dsp_dev); |
49 |
return False; |
return False; |
113 |
} |
} |
114 |
|
|
115 |
void |
void |
116 |
|
wave_out_volume(uint16 left, uint16 right) |
117 |
|
{ |
118 |
|
uint32 volume; |
119 |
|
|
120 |
|
volume = left/(65536/100); |
121 |
|
volume |= right/(65536/100) << 8; |
122 |
|
if (ioctl(g_dsp_fd, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1) |
123 |
|
{ |
124 |
|
perror("MIXER_WRITE(SOUND_MIXER_PCM)"); |
125 |
|
return; |
126 |
|
} |
127 |
|
} |
128 |
|
|
129 |
|
void |
130 |
wave_out_write(STREAM s, uint16 tick, uint8 index) |
wave_out_write(STREAM s, uint16 tick, uint8 index) |
131 |
{ |
{ |
132 |
struct audio_packet *packet = &packet_queue[queue_hi]; |
struct audio_packet *packet = &packet_queue[queue_hi]; |
143 |
packet->s = *s; |
packet->s = *s; |
144 |
packet->tick = tick; |
packet->tick = tick; |
145 |
packet->index = index; |
packet->index = index; |
146 |
|
packet->s.p += 4; |
147 |
|
|
148 |
/* we steal the data buffer from s, give it a new one */ |
/* we steal the data buffer from s, give it a new one */ |
149 |
s->data = malloc(s->size); |
s->data = malloc(s->size); |