111 |
if (pwfx->wBitsPerSample == 8) |
if (pwfx->wBitsPerSample == 8) |
112 |
{ |
{ |
113 |
info.play.encoding = AUDIO_ENCODING_LINEAR8; |
info.play.encoding = AUDIO_ENCODING_LINEAR8; |
|
samplewidth = 1; |
|
114 |
} |
} |
115 |
else if (pwfx->wBitsPerSample == 16) |
else if (pwfx->wBitsPerSample == 16) |
116 |
{ |
{ |
117 |
info.play.encoding = AUDIO_ENCODING_LINEAR; |
info.play.encoding = AUDIO_ENCODING_LINEAR; |
|
samplewidth = 2; |
|
118 |
/* Do we need to swap the 16bit values? (Are we BigEndian) */ |
/* Do we need to swap the 16bit values? (Are we BigEndian) */ |
119 |
swapaudio = !(*(uint8 *) (&test)); |
swapaudio = !(*(uint8 *) (&test)); |
120 |
} |
} |
121 |
|
|
122 |
|
samplewidth = pwfx->wBitsPerSample/8; |
123 |
|
|
124 |
if (pwfx->nChannels == 1 ) |
if (pwfx->nChannels == 1 ) |
125 |
{ |
{ |
126 |
info.play.channels = AUDIO_CHANNELS_MONO; |
info.play.channels = AUDIO_CHANNELS_MONO; |
136 |
info.play.samples = 0; |
info.play.samples = 0; |
137 |
info.play.eof = 0; |
info.play.eof = 0; |
138 |
info.play.error = 0; |
info.play.error = 0; |
139 |
|
reopened = True; |
140 |
|
|
141 |
if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1) |
if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1) |
142 |
{ |
{ |
149 |
} |
} |
150 |
|
|
151 |
void |
void |
152 |
|
wave_out_volume(uint16 left, uint16 right) |
153 |
|
{ |
154 |
|
audio_info_t info; |
155 |
|
uint balance; |
156 |
|
uint volume; |
157 |
|
|
158 |
|
if (ioctl(g_dsp_fd, AUDIO_GETINFO, &info) == -1) |
159 |
|
{ |
160 |
|
perror("AUDIO_GETINFO"); |
161 |
|
return; |
162 |
|
} |
163 |
|
|
164 |
|
volume = (left > right) ? left : right; |
165 |
|
|
166 |
|
if ( volume/AUDIO_MID_BALANCE != 0 ) |
167 |
|
{ |
168 |
|
balance = AUDIO_MID_BALANCE - (left/(volume/AUDIO_MID_BALANCE)) + (right/(volume/AUDIO_MID_BALANCE)); |
169 |
|
} |
170 |
|
else |
171 |
|
{ |
172 |
|
balance = AUDIO_MID_BALANCE; |
173 |
|
} |
174 |
|
|
175 |
|
info.play.gain = volume/(65536/AUDIO_MAX_GAIN); |
176 |
|
info.play.balance = balance; |
177 |
|
|
178 |
|
if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1) |
179 |
|
{ |
180 |
|
perror("AUDIO_SETINFO"); |
181 |
|
return; |
182 |
|
} |
183 |
|
} |
184 |
|
|
185 |
|
void |
186 |
wave_out_write(STREAM s, uint16 tick, uint8 index) |
wave_out_write(STREAM s, uint16 tick, uint8 index) |
187 |
{ |
{ |
188 |
struct audio_packet *packet = &packet_queue[queue_hi]; |
struct audio_packet *packet = &packet_queue[queue_hi]; |
199 |
packet->s = *s; |
packet->s = *s; |
200 |
packet->tick = tick; |
packet->tick = tick; |
201 |
packet->index = index; |
packet->index = index; |
202 |
|
packet->s.p += 4; |
203 |
|
|
204 |
/* we steal the data buffer from s, give it a new one */ |
/* we steal the data buffer from s, give it a new one */ |
205 |
s->data = malloc(s->size); |
s->data = malloc(s->size); |
245 |
/* Swap the current packet, but only once */ |
/* Swap the current packet, but only once */ |
246 |
if ( swapaudio && ! swapped ) |
if ( swapaudio && ! swapped ) |
247 |
{ |
{ |
248 |
for ( i = 0; i < out->end - out->p; i+=2 ) |
for ( i = 0; i < out->end - out->p; i += 2 ) |
249 |
{ |
{ |
250 |
swap = *(out->p + i); |
swap = *(out->p + i); |
251 |
*(out->p + i ) = *(out->p + i + 1); |
*(out->p + i) = *(out->p + i + 1); |
252 |
*(out->p + i + 1) = swap; |
*(out->p + i + 1) = swap; |
|
swapped = True; |
|
253 |
} |
} |
254 |
|
swapped = True; |
255 |
} |
} |
256 |
|
|
257 |
if ( sentcompletion ) |
if ( sentcompletion ) |