/* -*- c-basic-offset: 8 -*-
rdesktop: A Remote Desktop Protocol client.
Sound Channel Process Functions - Sun
Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 2003-2008
Copyright (C) GuoJunBo <guojunbo@ict.ac.cn> 2003
Copyright (C) Michael Gernoth <mike@zerfleddert.de> 2003-2008
Copyright 2007-2008 Pierre Ossman <ossman@cendio.se> for Cendio AB
Copyright 2008-2011 Peter Astrand <astrand@cendio.se> for Cendio AB
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Oracle GPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the General Public License version 2 (GPLv2) at this time for any software where
* a choice of GPL license versions is made available with the language indicating
* that GPLv2 or any later version may be used, or where a choice of which version
* of the GPL is applied is otherwise unspecified.
*/
#include "rdesktop.h"
#include "rdpsnd.h"
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stropts.h>
#endif
static int dsp_mode;
static int dsp_refs;
static int stereo;
static int format;
static short samplewidth;
static char *dsp_dev;
void sun_play(void);
void sun_record(void);
static int
sun_pause(void)
{
return -1;
return -1;
#endif
return 0;
}
static int
sun_resume(void)
{
return -1;
return 0;
}
void
{
if (dsp_fd == -1)
return;
if (dsp_out && !rdpsnd_queue_empty())
if (dsp_in)
if (dsp_fd > *n)
*n = dsp_fd;
}
void
{
sun_play();
sun_record();
}
{
if (dsp_fd != -1)
{
dsp_refs++;
return True;
return True;
dsp_refs--;
return False;
}
dsp_broken = False;
written_samples = 0;
if (dsp_fd != -1)
{
{
dsp_fd = -1;
}
}
if (dsp_fd == -1)
{
if (dsp_fd == -1)
{
return False;
}
}
/*
* Pause recording until we actually start using it.
*/
{
if (sun_pause() == -1)
{
dsp_fd = -1;
return False;
}
}
dsp_refs++;
return True;
}
void
sun_close(void)
{
dsp_refs--;
if (dsp_refs != 0)
return;
dsp_fd = -1;
}
sun_open_out(void)
{
return False;
return True;
}
void
sun_close_out(void)
{
/* Flush the audiobuffer */
#endif
#if defined AUDIO_FLUSH
#endif
sun_close();
/* Ack all remaining packets */
while (!rdpsnd_queue_empty())
}
sun_open_in(void)
{
/*
* It is not possible to reliably use the recording without
* flush operations.
*/
return False;
#endif
return False;
/* 2 channel recording is known to be broken on Solaris x86
Sun Ray systems */
#ifdef L_ENDIAN
#endif
/*
* Unpause the stream now that we have someone using it.
*/
if (sun_resume() == -1)
{
sun_close();
return False;
}
return True;
}
void
sun_close_in(void)
{
/*
* Repause the stream when the user goes away.
*/
sun_pause();
sun_close();
}
{
return False;
return False;
return False;
return True;
}
{
if (dsp_configured)
{
return False;
return False;
return False;
return False;
return True;
}
sun_pause();
{
stereo = 0;
}
{
stereo = 1;
samplewidth *= 2;
{
}
}
{
perror("AUDIO_SETINFO");
sun_close();
return False;
}
if (dsp_in)
sun_resume();
return True;
}
void
{
if (volume / AUDIO_MID_BALANCE != 0)
{
balance =
}
else
{
}
{
perror("AUDIO_SETINFO");
return;
}
}
void
sun_play(void)
{
/* We shouldn't be called if the queue is empty, but still */
if (rdpsnd_queue_empty())
return;
if (len == -1)
{
if (errno != EWOULDBLOCK)
{
if (!dsp_broken)
perror("RDPSND: write()");
dsp_broken = True;
}
return;
}
dsp_broken = False;
{
unsigned long delay_us;
else
}
}
void
sun_record(void)
{
int len;
if (len == -1)
{
if (errno != EWOULDBLOCK)
perror("read audio");
return;
}
{
unsigned int i;
/* Loop over each byte read backwards and put in place */
i = len - 1;
do
{
// Channel 1
// Channel 2
i--;
}
while (i);
len *= 2;
}
}
struct audio_driver *
{
if (options)
{
}
else
{
{
}
}
return &sun_driver;
}