28 |
#include <errno.h> |
#include <errno.h> |
29 |
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
30 |
#include <sys/audioio.h> |
#include <sys/audioio.h> |
31 |
|
#include <string.h> |
32 |
|
|
33 |
#if (defined(sun) && (defined(__svr4__) || defined(__SVR4))) |
#if (defined(sun) && (defined(__svr4__) || defined(__SVR4))) |
34 |
#include <stropts.h> |
#include <stropts.h> |
43 |
|
|
44 |
static RD_BOOL dsp_configured; |
static RD_BOOL dsp_configured; |
45 |
static RD_BOOL dsp_broken; |
static RD_BOOL dsp_broken; |
46 |
|
static RD_BOOL broken_2_channel_record = False; |
47 |
|
|
48 |
static RD_BOOL dsp_out; |
static RD_BOOL dsp_out; |
49 |
static RD_BOOL dsp_in; |
static RD_BOOL dsp_in; |
242 |
if (!sun_open(O_RDONLY)) |
if (!sun_open(O_RDONLY)) |
243 |
return False; |
return False; |
244 |
|
|
245 |
|
/* 2 channel recording is known to be broken on Solaris x86 |
246 |
|
Sun Ray systems */ |
247 |
|
#ifdef L_ENDIAN |
248 |
|
if (strstr(dsp_dev, "/utaudio/")) |
249 |
|
broken_2_channel_record = True; |
250 |
|
#endif |
251 |
|
|
252 |
/* |
/* |
253 |
* Unpause the stream now that we have someone using it. |
* Unpause the stream now that we have someone using it. |
254 |
*/ |
*/ |
322 |
|
|
323 |
samplewidth = pwfx->wBitsPerSample / 8; |
samplewidth = pwfx->wBitsPerSample / 8; |
324 |
|
|
325 |
|
info.play.channels = pwfx->nChannels; |
326 |
|
info.record.channels = info.play.channels; |
327 |
|
|
328 |
if (pwfx->nChannels == 1) |
if (pwfx->nChannels == 1) |
329 |
{ |
{ |
|
info.play.channels = 1; |
|
330 |
stereo = 0; |
stereo = 0; |
331 |
} |
} |
332 |
else if (pwfx->nChannels == 2) |
else if (pwfx->nChannels == 2) |
333 |
{ |
{ |
|
info.play.channels = 2; |
|
334 |
stereo = 1; |
stereo = 1; |
335 |
samplewidth *= 2; |
samplewidth *= 2; |
336 |
|
|
337 |
|
if (broken_2_channel_record) |
338 |
|
{ |
339 |
|
info.record.channels = 1; |
340 |
|
} |
341 |
} |
} |
342 |
|
|
343 |
snd_rate = pwfx->nSamplesPerSec; |
snd_rate = pwfx->nSamplesPerSec; |
350 |
info.play.error = 0; |
info.play.error = 0; |
351 |
|
|
352 |
info.record.sample_rate = info.play.sample_rate; |
info.record.sample_rate = info.play.sample_rate; |
|
info.record.channels = info.play.channels; |
|
353 |
info.record.precision = info.play.precision; |
info.record.precision = info.play.precision; |
354 |
info.record.encoding = info.play.encoding; |
info.record.encoding = info.play.encoding; |
355 |
info.record.samples = 0; |
info.record.samples = 0; |
459 |
char buffer[32768]; |
char buffer[32768]; |
460 |
int len; |
int len; |
461 |
|
|
462 |
len = read(dsp_fd, buffer, sizeof(buffer)); |
len = read(dsp_fd, buffer, sizeof(buffer) / 2); |
463 |
if (len == -1) |
if (len == -1) |
464 |
{ |
{ |
465 |
if (errno != EWOULDBLOCK) |
if (errno != EWOULDBLOCK) |
467 |
return; |
return; |
468 |
} |
} |
469 |
|
|
470 |
|
if (broken_2_channel_record) |
471 |
|
{ |
472 |
|
unsigned int i; |
473 |
|
int rec_samplewidth = samplewidth / 2; |
474 |
|
/* Loop over each byte read backwards and put in place */ |
475 |
|
i = len - 1; |
476 |
|
do |
477 |
|
{ |
478 |
|
int samples_before = i / rec_samplewidth * 2; |
479 |
|
int sample_byte = i % rec_samplewidth; |
480 |
|
int ch1_offset = samples_before * rec_samplewidth + sample_byte; |
481 |
|
// Channel 1 |
482 |
|
buffer[ch1_offset] = buffer[i]; |
483 |
|
// Channel 2 |
484 |
|
buffer[ch1_offset + rec_samplewidth] = buffer[i]; |
485 |
|
|
486 |
|
i--; |
487 |
|
} |
488 |
|
while (i); |
489 |
|
len *= 2; |
490 |
|
} |
491 |
|
|
492 |
rdpsnd_record(buffer, len); |
rdpsnd_record(buffer, len); |
493 |
} |
} |
494 |
|
|