116 |
|
|
117 |
g_samplewidth = pwfx->wBitsPerSample / 8; |
g_samplewidth = pwfx->wBitsPerSample / 8; |
118 |
|
|
119 |
if(o_device != NULL) |
if (o_device != NULL) |
120 |
ao_close(o_device); |
ao_close(o_device); |
121 |
|
|
122 |
o_device = ao_open_live(default_driver, &format, NULL); |
o_device = ao_open_live(default_driver, &format, NULL); |
165 |
{ |
{ |
166 |
struct audio_packet *packet; |
struct audio_packet *packet; |
167 |
STREAM out; |
STREAM out; |
168 |
unsigned char expanded[WAVEOUTBUF]; |
unsigned char outbuf[WAVEOUTBUF]; |
169 |
int offset,len,i; |
int offset, len, i; |
170 |
|
|
171 |
if (queue_lo == queue_hi) |
if (queue_lo == queue_hi) |
172 |
{ |
{ |
179 |
|
|
180 |
len = 0; |
len = 0; |
181 |
|
|
182 |
if (g_samplerate == 22050 ) |
if (g_samplerate == 22050) |
183 |
{ |
{ |
184 |
/* Resample to 44100 */ |
/* Resample to 44100 */ |
185 |
for(i=0; (i<((WAVEOUTBUF/8)*(3-g_samplewidth))) && (out->p < out->end); i++) |
for (i = 0; (i < ((WAVEOUTBUF / 8) * (3 - g_samplewidth))) && (out->p < out->end); |
186 |
|
i++) |
187 |
{ |
{ |
188 |
offset=i*4*g_samplewidth; |
offset = i * 4 * g_samplewidth; |
189 |
memcpy(&expanded[0*g_samplewidth+offset],out->p,g_samplewidth); |
memcpy(&outbuf[0 * g_samplewidth + offset], out->p, g_samplewidth); |
190 |
memcpy(&expanded[2*g_samplewidth+offset],out->p,g_samplewidth); |
memcpy(&outbuf[2 * g_samplewidth + offset], out->p, g_samplewidth); |
191 |
out->p += 2; |
out->p += 2; |
192 |
|
|
193 |
memcpy(&expanded[1*g_samplewidth+offset],out->p,g_samplewidth); |
memcpy(&outbuf[1 * g_samplewidth + offset], out->p, g_samplewidth); |
194 |
memcpy(&expanded[3*g_samplewidth+offset],out->p,g_samplewidth); |
memcpy(&outbuf[3 * g_samplewidth + offset], out->p, g_samplewidth); |
195 |
out->p += 2; |
out->p += 2; |
196 |
len += 4*g_samplewidth; |
len += 4 * g_samplewidth; |
197 |
} |
} |
198 |
} |
} |
199 |
else |
else |
200 |
{ |
{ |
201 |
len = (WAVEOUTBUF > (out->end - out->p)) ? (out->end - out->p) : WAVEOUTBUF; |
len = (WAVEOUTBUF > (out->end - out->p)) ? (out->end - out->p) : WAVEOUTBUF; |
202 |
memcpy(expanded,out->p,len); |
memcpy(outbuf, out->p, len); |
203 |
out->p += len; |
out->p += len; |
204 |
} |
} |
205 |
|
|
206 |
ao_play(o_device, expanded, len); |
ao_play(o_device, outbuf, len); |
207 |
|
|
208 |
if (out->p == out->end) |
if (out->p == out->end) |
209 |
{ |
{ |