38 |
static BOOL g_swapaudio; |
static BOOL g_swapaudio; |
39 |
static int g_snd_rate; |
static int g_snd_rate; |
40 |
static BOOL g_swapaudio; |
static BOOL g_swapaudio; |
|
static short g_samplewidth; |
|
41 |
static int width = AL_SAMPLE_16; |
static int width = AL_SAMPLE_16; |
42 |
|
|
43 |
double min_volume, max_volume, volume_range; |
double min_volume, max_volume, volume_range; |
144 |
#if (defined(IRIX_DEBUG)) |
#if (defined(IRIX_DEBUG)) |
145 |
fprintf(stderr, "wave_out_set_format: init...\n"); |
fprintf(stderr, "wave_out_set_format: init...\n"); |
146 |
#endif |
#endif |
|
/* limited support to configure an opened audio port in IRIX */ |
|
|
/* have to reopen the audio port, using same config */ |
|
|
alClosePort(output_port); |
|
147 |
|
|
148 |
g_swapaudio = False; |
g_swapaudio = False; |
|
|
|
149 |
if (pwfx->wBitsPerSample == 8) |
if (pwfx->wBitsPerSample == 8) |
150 |
width = AL_SAMPLE_8; |
width = AL_SAMPLE_8; |
151 |
else if (pwfx->wBitsPerSample == 16) |
else if (pwfx->wBitsPerSample == 16) |
152 |
{ |
{ |
153 |
width = AL_SAMPLE_16; |
width = AL_SAMPLE_16; |
154 |
/* Do we need to swap the 16bit values? (Are we BigEndian) */ |
/* Do we need to swap the 16bit values? (Are we BigEndian) */ |
155 |
#if (defined(IRIX_DEBUG)) |
#if (defined(B_ENDIAN)) |
156 |
g_swapaudio = 1; |
g_swapaudio = 1; |
157 |
#else |
#else |
158 |
g_swapaudio = 0; |
g_swapaudio = 0; |
159 |
#endif |
#endif |
160 |
} |
} |
161 |
|
|
162 |
g_samplewidth = pwfx->wBitsPerSample / 8; |
/* Limited support to configure an opened audio port in IRIX The |
163 |
|
number of channels is a static setting and can not be changed after |
164 |
|
a port is opened. So if the number of channels remains the same, we |
165 |
|
can configure other settings Otherwise we have to reopen the audio |
166 |
|
port, using same config. */ |
167 |
|
|
168 |
channels = pwfx->nChannels; |
channels = pwfx->nChannels; |
169 |
g_snd_rate = pwfx->nSamplesPerSec; |
g_snd_rate = pwfx->nSamplesPerSec; |
170 |
|
|
171 |
alSetSampFmt(audioconfig, AL_SAMPFMT_TWOSCOMP); |
alSetSampFmt(audioconfig, AL_SAMPFMT_TWOSCOMP); |
172 |
alSetWidth(audioconfig, width); |
alSetWidth(audioconfig, width); |
173 |
alSetChannels(audioconfig, channels); |
if ( channels != alGetChannels(audioconfig) ) |
174 |
|
{ |
175 |
|
alClosePort(output_port); |
176 |
|
alSetChannels(audioconfig, channels); |
177 |
|
output_port = alOpenPort("rdpsnd", "w", audioconfig); |
178 |
|
|
179 |
output_port = alOpenPort("rdpsnd", "w", audioconfig); |
if (output_port == (ALport) 0) |
180 |
|
{ |
181 |
|
fprintf(stderr, "wave_out_set_format: alOpenPort failed: %s\n", |
182 |
|
alGetErrorString(oserror())); |
183 |
|
return False; |
184 |
|
} |
185 |
|
|
|
if (output_port == (ALport) 0) |
|
|
{ |
|
|
fprintf(stderr, "wave_out_set_format: alOpenPort failed: %s\n", |
|
|
alGetErrorString(oserror())); |
|
|
return False; |
|
186 |
} |
} |
187 |
|
|
188 |
resource = alGetResource(output_port); |
resource = alGetResource(output_port); |
285 |
unsigned int i; |
unsigned int i; |
286 |
uint8 swap; |
uint8 swap; |
287 |
STREAM out; |
STREAM out; |
|
static long startedat_us; |
|
|
static long startedat_s; |
|
|
static BOOL started = False; |
|
288 |
static BOOL swapped = False; |
static BOOL swapped = False; |
|
struct timeval tv; |
|
289 |
int gf; |
int gf; |
|
static long long temp; |
|
290 |
|
|
291 |
while (1) |
while (1) |
292 |
{ |
{ |
311 |
swapped = True; |
swapped = True; |
312 |
} |
} |
313 |
|
|
|
if (!started) |
|
|
{ |
|
|
gettimeofday(&tv, NULL); |
|
|
startedat_us = tv.tv_usec; |
|
|
startedat_s = tv.tv_sec; |
|
|
started = True; |
|
|
} |
|
|
|
|
314 |
len = out->end - out->p; |
len = out->end - out->p; |
|
gf = alGetFillable(output_port); |
|
|
if (len > gf) |
|
|
{ |
|
|
/* len = gf * combinedFrameSize; */ |
|
|
#if (defined(IRIX_DEBUG)) |
|
|
/* fprintf(stderr,"Fillable...\n"); */ |
|
|
#endif |
|
|
} |
|
315 |
|
|
316 |
alWriteFrames(output_port, out->p, len / combinedFrameSize); |
alWriteFrames(output_port, out->p, len / combinedFrameSize); |
317 |
|
|
318 |
out->p += len; |
out->p += len; |
319 |
if (out->p == out->end) |
if (out->p == out->end) |
320 |
{ |
{ |
321 |
long long duration; |
gf = alGetFilled(output_port); |
322 |
long elapsed; |
if ( gf < (4 * maxFillable / 10) ) |
|
|
|
|
gettimeofday(&tv, NULL); |
|
|
duration = (out->size * (1000000 / (g_samplewidth * g_snd_rate))); |
|
|
elapsed = (tv.tv_sec - startedat_s) * 1000000 + (tv.tv_usec - startedat_us); |
|
|
/* 7/10 is not good for IRIX audio port, 4x/100 is suitable */ |
|
|
if (elapsed >= (duration * 485) / 1000) |
|
323 |
{ |
{ |
324 |
rdpsnd_send_completion(packet->tick, packet->index); |
rdpsnd_send_completion(packet->tick, packet->index); |
325 |
free(out->data); |
free(out->data); |
326 |
queue_lo = (queue_lo + 1) % MAX_QUEUE; |
queue_lo = (queue_lo + 1) % MAX_QUEUE; |
|
started = False; |
|
327 |
swapped = False; |
swapped = False; |
328 |
} |
} |
329 |
else |
else |
330 |
{ |
{ |
331 |
#if (defined(IRIX_DEBUG)) |
#if (defined(IRIX_DEBUG)) |
332 |
/* fprintf(stderr,"Busy playing...\n"); */ |
/* fprintf(stderr,"Busy playing...\n"); */ |
333 |
#endif |
#endif |
334 |
g_dsp_busy = True; |
g_dsp_busy = True; |
335 |
return; |
return; |