rdpsnd_alsa.c revision 6e9aa255e3376b2da5824c09c4c62bc233463bfe
/* -*- c-basic-offset: 8 -*-
rdesktop: A Remote Desktop Protocol client.
Sound Channel Process Functions - alsa-driver
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> 2006-2008
Copyright 2006-2008 Pierre Ossman <ossman@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 "rdpsnd_dsp.h"
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <alsa/asoundlib.h>
#define DEFAULTDEVICE "default"
#define MAX_FRAMES 32
static int num_fds_out;
static int num_fds_in;
static short samplewidth_out;
static int audiochannels_out;
static unsigned int rate_out;
static short samplewidth_in;
static int audiochannels_in;
static unsigned int rate_in;
static char *pcm_name;
void alsa_play(void);
void alsa_record(void);
void
{
int err;
struct pollfd *f;
if (out_handle && !rdpsnd_queue_empty())
{
return;
if (err < 0)
return;
{
*n = f->fd;
}
}
if (in_handle)
{
return;
if (err < 0)
return;
{
*n = f->fd;
}
}
}
void
{
struct pollfd *f;
int err;
unsigned short revents;
if (out_handle && !rdpsnd_queue_empty())
{
{
f->revents = 0;
if (f->fd != -1)
{
/* Fixme: This doesn't properly deal with things like POLLHUP */
}
}
if (err < 0)
return;
alsa_play();
}
if (in_handle)
{
{
f->revents = 0;
if (f->fd != -1)
{
/* Fixme: This doesn't properly deal with things like POLLHUP */
}
}
if (err < 0)
return;
alsa_record();
}
}
static RD_BOOL
{
int err;
unsigned int buffertime;
short samplewidth;
int audiochannels;
unsigned int rate;
{
return False;
}
{
return False;
}
{
return False;
}
{
{
return False;
}
}
else
{
{
return False;
}
}
#if 0
{
return False;
}
#endif
{
return False;
}
{
return False;
}
{
return False;
}
{
return False;
}
{
return False;
}
return True;
}
alsa_open_out(void)
{
int err;
{
return False;
}
return True;
}
void
alsa_close_out(void)
{
/* Ack all remaining packets */
while (!rdpsnd_queue_empty())
if (out_handle)
{
out_handle = NULL;
}
}
{
#if 0
int err;
{
return False;
}
{
return False;
}
#endif
return False;
return False;
return False;
return False;
return True;
}
{
return False;
return True;
}
void
alsa_play(void)
{
struct audio_packet *packet;
int len;
unsigned int duration;
int next_tick;
if (reopened)
{
}
/* We shouldn't be called if the queue is empty, but still */
if (rdpsnd_queue_empty())
return;
{
printf("Fooo!\n");
len = 0;
}
next_tick += 65536;
{
unsigned long delay_us;
{
}
if (delay_frames < 0)
delay_frames = 0;
}
}
alsa_open_in(void)
{
int err;
if ((err =
{
return False;
}
return True;
}
void
alsa_close_in(void)
{
if (in_handle)
{
}
}
{
int err;
return False;
{
return False;
}
return True;
}
void
alsa_record(void)
{
int len;
char buffer[32768];
if (len < 0)
{
len = 0;
}
}
struct audio_driver *
alsa_register(char *options)
{
static struct audio_driver alsa_driver;
if (options)
{
}
else
{
}
return &alsa_driver;
}