2005-08-03 12:56:16 +02:00
|
|
|
/* -*- c-basic-offset: 8 -*-
|
2003-09-30 11:11:08 +02:00
|
|
|
rdesktop: A Remote Desktop Protocol client.
|
|
|
|
Sound Channel Process Functions
|
|
|
|
Copyright (C) Matthew Chapman 2003
|
|
|
|
Copyright (C) GuoJunBo guojunbo@ict.ac.cn 2003
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 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, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2003-07-01 11:31:25 +02:00
|
|
|
#include "rdesktop.h"
|
2006-09-17 12:32:18 +02:00
|
|
|
#include "rdpsnd.h"
|
2006-09-17 16:41:16 +02:00
|
|
|
#include "rdpsnd_dsp.h"
|
2003-07-01 11:31:25 +02:00
|
|
|
|
2003-09-30 11:11:08 +02:00
|
|
|
#define RDPSND_CLOSE 1
|
|
|
|
#define RDPSND_WRITE 2
|
|
|
|
#define RDPSND_SET_VOLUME 3
|
|
|
|
#define RDPSND_UNKNOWN4 4
|
|
|
|
#define RDPSND_COMPLETION 5
|
2006-02-08 13:10:41 +01:00
|
|
|
#define RDPSND_SERVERTICK 6
|
2003-09-30 11:11:08 +02:00
|
|
|
#define RDPSND_NEGOTIATE 7
|
|
|
|
|
|
|
|
#define MAX_FORMATS 10
|
2006-09-17 12:32:18 +02:00
|
|
|
#define MAX_QUEUE 10
|
|
|
|
|
|
|
|
BOOL g_dsp_busy = False;
|
|
|
|
int g_dsp_fd;
|
2003-09-30 11:11:08 +02:00
|
|
|
|
2003-07-01 11:31:25 +02:00
|
|
|
static VCHANNEL *rdpsnd_channel;
|
2006-09-17 13:04:50 +02:00
|
|
|
static struct audio_driver *drivers = NULL;
|
2006-09-17 13:42:22 +02:00
|
|
|
struct audio_driver *current_driver = NULL;
|
2003-07-01 11:31:25 +02:00
|
|
|
|
2003-09-30 11:11:08 +02:00
|
|
|
static BOOL device_open;
|
|
|
|
static WAVEFORMATEX formats[MAX_FORMATS];
|
|
|
|
static unsigned int format_count;
|
|
|
|
static unsigned int current_format;
|
2006-09-17 13:42:22 +02:00
|
|
|
unsigned int queue_hi, queue_lo;
|
|
|
|
struct audio_packet packet_queue[MAX_QUEUE];
|
2003-09-30 11:11:08 +02:00
|
|
|
|
2006-09-17 13:04:50 +02:00
|
|
|
void (*wave_out_play) (void);
|
|
|
|
|
2004-04-17 09:24:22 +02:00
|
|
|
static STREAM
|
2003-09-30 11:11:08 +02:00
|
|
|
rdpsnd_init_packet(uint16 type, uint16 size)
|
|
|
|
{
|
|
|
|
STREAM s;
|
|
|
|
|
2003-10-15 16:01:32 +02:00
|
|
|
s = channel_init(rdpsnd_channel, size + 4);
|
2003-09-30 11:11:08 +02:00
|
|
|
out_uint16_le(s, type);
|
|
|
|
out_uint16_le(s, size);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2004-04-17 09:24:22 +02:00
|
|
|
static void
|
2003-09-30 11:11:08 +02:00
|
|
|
rdpsnd_send(STREAM s)
|
|
|
|
{
|
|
|
|
#ifdef RDPSND_DEBUG
|
|
|
|
printf("RDPSND send:\n");
|
2003-10-15 16:01:32 +02:00
|
|
|
hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8);
|
2003-09-30 11:11:08 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
channel_send(s, rdpsnd_channel);
|
|
|
|
}
|
|
|
|
|
2003-10-15 16:01:32 +02:00
|
|
|
void
|
|
|
|
rdpsnd_send_completion(uint16 tick, uint8 packet_index)
|
2003-09-30 11:11:08 +02:00
|
|
|
{
|
|
|
|
STREAM s;
|
|
|
|
|
|
|
|
s = rdpsnd_init_packet(RDPSND_COMPLETION, 4);
|
2006-09-17 12:32:18 +02:00
|
|
|
out_uint16_le(s, tick);
|
2003-09-30 11:11:08 +02:00
|
|
|
out_uint8(s, packet_index);
|
|
|
|
out_uint8(s, 0);
|
|
|
|
s_mark_end(s);
|
|
|
|
rdpsnd_send(s);
|
|
|
|
}
|
|
|
|
|
2004-04-17 09:24:22 +02:00
|
|
|
static void
|
2003-09-30 11:11:08 +02:00
|
|
|
rdpsnd_process_negotiate(STREAM in)
|
|
|
|
{
|
|
|
|
unsigned int in_format_count, i;
|
|
|
|
WAVEFORMATEX *format;
|
|
|
|
STREAM out;
|
2003-10-13 18:09:45 +02:00
|
|
|
BOOL device_available = False;
|
2003-10-14 09:53:10 +02:00
|
|
|
int readcnt;
|
|
|
|
int discardcnt;
|
2003-09-30 11:11:08 +02:00
|
|
|
|
|
|
|
in_uint8s(in, 14); /* flags, volume, pitch, UDP port */
|
|
|
|
in_uint16_le(in, in_format_count);
|
|
|
|
in_uint8s(in, 4); /* pad, status, pad */
|
|
|
|
|
2006-09-17 13:04:50 +02:00
|
|
|
if (current_driver->wave_out_open())
|
2003-10-13 18:09:45 +02:00
|
|
|
{
|
2006-09-17 13:04:50 +02:00
|
|
|
current_driver->wave_out_close();
|
2003-10-13 18:09:45 +02:00
|
|
|
device_available = True;
|
|
|
|
}
|
|
|
|
|
2003-09-30 11:11:08 +02:00
|
|
|
format_count = 0;
|
2003-10-15 16:01:32 +02:00
|
|
|
if (s_check_rem(in, 18 * in_format_count))
|
2003-09-30 11:11:08 +02:00
|
|
|
{
|
|
|
|
for (i = 0; i < in_format_count; i++)
|
|
|
|
{
|
|
|
|
format = &formats[format_count];
|
|
|
|
in_uint16_le(in, format->wFormatTag);
|
|
|
|
in_uint16_le(in, format->nChannels);
|
|
|
|
in_uint32_le(in, format->nSamplesPerSec);
|
|
|
|
in_uint32_le(in, format->nAvgBytesPerSec);
|
|
|
|
in_uint16_le(in, format->nBlockAlign);
|
|
|
|
in_uint16_le(in, format->wBitsPerSample);
|
|
|
|
in_uint16_le(in, format->cbSize);
|
|
|
|
|
2003-10-14 09:46:49 +02:00
|
|
|
/* read in the buffer of unknown use */
|
2003-10-14 09:53:10 +02:00
|
|
|
readcnt = format->cbSize;
|
|
|
|
discardcnt = 0;
|
2003-10-14 09:46:49 +02:00
|
|
|
if (format->cbSize > MAX_CBSIZE)
|
|
|
|
{
|
2003-10-15 16:01:32 +02:00
|
|
|
fprintf(stderr, "cbSize too large for buffer: %d\n",
|
|
|
|
format->cbSize);
|
2003-10-14 09:46:49 +02:00
|
|
|
readcnt = MAX_CBSIZE;
|
|
|
|
discardcnt = format->cbSize - MAX_CBSIZE;
|
|
|
|
}
|
|
|
|
in_uint8a(in, format->cb, readcnt);
|
|
|
|
in_uint8s(in, discardcnt);
|
|
|
|
|
2006-09-17 13:04:50 +02:00
|
|
|
if (device_available && current_driver->wave_out_format_supported(format))
|
2003-09-30 11:11:08 +02:00
|
|
|
{
|
|
|
|
format_count++;
|
|
|
|
if (format_count == MAX_FORMATS)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-15 16:01:32 +02:00
|
|
|
out = rdpsnd_init_packet(RDPSND_NEGOTIATE | 0x200, 20 + 18 * format_count);
|
|
|
|
out_uint32_le(out, 3); /* flags */
|
2003-09-30 11:11:08 +02:00
|
|
|
out_uint32(out, 0xffffffff); /* volume */
|
2003-10-15 16:01:32 +02:00
|
|
|
out_uint32(out, 0); /* pitch */
|
|
|
|
out_uint16(out, 0); /* UDP port */
|
2003-09-30 11:11:08 +02:00
|
|
|
|
|
|
|
out_uint16_le(out, format_count);
|
2003-10-15 16:01:32 +02:00
|
|
|
out_uint8(out, 0x95); /* pad? */
|
|
|
|
out_uint16_le(out, 2); /* status */
|
|
|
|
out_uint8(out, 0x77); /* pad? */
|
2003-09-30 11:11:08 +02:00
|
|
|
|
|
|
|
for (i = 0; i < format_count; i++)
|
|
|
|
{
|
|
|
|
format = &formats[i];
|
|
|
|
out_uint16_le(out, format->wFormatTag);
|
|
|
|
out_uint16_le(out, format->nChannels);
|
|
|
|
out_uint32_le(out, format->nSamplesPerSec);
|
|
|
|
out_uint32_le(out, format->nAvgBytesPerSec);
|
|
|
|
out_uint16_le(out, format->nBlockAlign);
|
|
|
|
out_uint16_le(out, format->wBitsPerSample);
|
2003-10-15 16:01:32 +02:00
|
|
|
out_uint16(out, 0); /* cbSize */
|
2003-09-30 11:11:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
s_mark_end(out);
|
|
|
|
rdpsnd_send(out);
|
|
|
|
}
|
|
|
|
|
2004-04-17 09:24:22 +02:00
|
|
|
static void
|
2006-02-08 13:10:41 +01:00
|
|
|
rdpsnd_process_servertick(STREAM in)
|
2003-09-30 11:11:08 +02:00
|
|
|
{
|
2006-02-08 13:10:41 +01:00
|
|
|
uint16 tick1, tick2;
|
2003-09-30 11:11:08 +02:00
|
|
|
STREAM out;
|
|
|
|
|
|
|
|
/* in_uint8s(in, 4); unknown */
|
2006-02-08 13:10:41 +01:00
|
|
|
in_uint16_le(in, tick1);
|
|
|
|
in_uint16_le(in, tick2);
|
2003-09-30 11:11:08 +02:00
|
|
|
|
2006-02-08 13:10:41 +01:00
|
|
|
out = rdpsnd_init_packet(RDPSND_SERVERTICK | 0x2300, 4);
|
|
|
|
out_uint16_le(out, tick1);
|
|
|
|
out_uint16_le(out, tick2);
|
2003-09-30 11:11:08 +02:00
|
|
|
s_mark_end(out);
|
|
|
|
rdpsnd_send(out);
|
|
|
|
}
|
|
|
|
|
2004-04-17 09:24:22 +02:00
|
|
|
static void
|
2003-07-01 11:31:25 +02:00
|
|
|
rdpsnd_process(STREAM s)
|
|
|
|
{
|
2003-09-30 11:11:08 +02:00
|
|
|
uint8 type;
|
|
|
|
uint16 datalen;
|
2003-10-13 18:09:45 +02:00
|
|
|
uint32 volume;
|
2003-09-30 11:11:08 +02:00
|
|
|
static uint16 tick, format;
|
|
|
|
static uint8 packet_index;
|
|
|
|
static BOOL awaiting_data_packet;
|
2006-09-17 22:06:37 +02:00
|
|
|
static unsigned char missing_bytes[4] = { 0, 0, 0, 0 };
|
2003-09-30 11:11:08 +02:00
|
|
|
|
|
|
|
#ifdef RDPSND_DEBUG
|
|
|
|
printf("RDPSND recv:\n");
|
2003-10-15 16:01:32 +02:00
|
|
|
hexdump(s->p, s->end - s->p);
|
2003-09-30 11:11:08 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (awaiting_data_packet)
|
|
|
|
{
|
|
|
|
if (format >= MAX_FORMATS)
|
|
|
|
{
|
|
|
|
error("RDPSND: Invalid format index\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!device_open || (format != current_format))
|
|
|
|
{
|
2006-09-17 13:04:50 +02:00
|
|
|
if (!device_open && !current_driver->wave_out_open())
|
2003-09-30 11:11:08 +02:00
|
|
|
{
|
|
|
|
rdpsnd_send_completion(tick, packet_index);
|
|
|
|
return;
|
|
|
|
}
|
2006-09-17 13:04:50 +02:00
|
|
|
if (!current_driver->wave_out_set_format(&formats[format]))
|
2003-09-30 11:11:08 +02:00
|
|
|
{
|
|
|
|
rdpsnd_send_completion(tick, packet_index);
|
2006-09-17 13:04:50 +02:00
|
|
|
current_driver->wave_out_close();
|
2003-09-30 11:11:08 +02:00
|
|
|
device_open = False;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
device_open = True;
|
|
|
|
current_format = format;
|
|
|
|
}
|
|
|
|
|
2006-09-17 22:06:37 +02:00
|
|
|
/* Insert the 4 missing bytes retrieved from last RDPSND_WRITE */
|
|
|
|
memcpy(s->data, missing_bytes, 4);
|
|
|
|
|
2006-09-17 20:08:51 +02:00
|
|
|
current_driver->
|
|
|
|
wave_out_write(rdpsnd_dsp_process
|
|
|
|
(s, current_driver, &formats[current_format]), tick,
|
|
|
|
packet_index);
|
2003-09-30 11:11:08 +02:00
|
|
|
awaiting_data_packet = False;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
in_uint8(s, type);
|
2003-10-15 16:01:32 +02:00
|
|
|
in_uint8s(s, 1); /* unknown? */
|
2003-09-30 11:11:08 +02:00
|
|
|
in_uint16_le(s, datalen);
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
2003-10-15 16:01:32 +02:00
|
|
|
case RDPSND_WRITE:
|
|
|
|
in_uint16_le(s, tick);
|
|
|
|
in_uint16_le(s, format);
|
|
|
|
in_uint8(s, packet_index);
|
2006-09-17 22:06:37 +02:00
|
|
|
/* Here are our lost bytes, but why? */
|
|
|
|
memcpy(missing_bytes, s->end - 4, 4);
|
2003-10-15 16:01:32 +02:00
|
|
|
awaiting_data_packet = True;
|
|
|
|
break;
|
|
|
|
case RDPSND_CLOSE:
|
2006-09-17 13:04:50 +02:00
|
|
|
current_driver->wave_out_close();
|
2003-10-15 16:01:32 +02:00
|
|
|
device_open = False;
|
|
|
|
break;
|
|
|
|
case RDPSND_NEGOTIATE:
|
|
|
|
rdpsnd_process_negotiate(s);
|
|
|
|
break;
|
2006-02-08 13:10:41 +01:00
|
|
|
case RDPSND_SERVERTICK:
|
|
|
|
rdpsnd_process_servertick(s);
|
2003-10-15 16:01:32 +02:00
|
|
|
break;
|
|
|
|
case RDPSND_SET_VOLUME:
|
|
|
|
in_uint32(s, volume);
|
|
|
|
if (device_open)
|
|
|
|
{
|
2006-09-17 13:04:50 +02:00
|
|
|
current_driver->wave_out_volume((volume & 0xffff),
|
|
|
|
(volume & 0xffff0000) >> 16);
|
2003-10-15 16:01:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
unimpl("RDPSND packet type %d\n", type);
|
|
|
|
break;
|
2003-09-30 11:11:08 +02:00
|
|
|
}
|
2003-07-01 11:31:25 +02:00
|
|
|
}
|
|
|
|
|
2006-10-01 13:00:03 +02:00
|
|
|
static BOOL
|
2006-09-17 13:04:50 +02:00
|
|
|
rdpsnd_auto_open(void)
|
|
|
|
{
|
2006-09-18 23:42:50 +02:00
|
|
|
static BOOL failed = False;
|
|
|
|
|
|
|
|
if (!failed)
|
2006-09-17 13:04:50 +02:00
|
|
|
{
|
2006-09-18 23:42:50 +02:00
|
|
|
struct audio_driver *auto_driver = current_driver;
|
|
|
|
|
|
|
|
current_driver = drivers;
|
|
|
|
while (current_driver != NULL)
|
2006-09-17 13:04:50 +02:00
|
|
|
{
|
2006-09-18 23:42:50 +02:00
|
|
|
DEBUG(("trying %s...\n", current_driver->name));
|
|
|
|
if (current_driver->wave_out_open())
|
|
|
|
{
|
|
|
|
DEBUG(("selected %s\n", current_driver->name));
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
g_dsp_fd = 0;
|
|
|
|
current_driver = current_driver->next;
|
2006-09-17 13:04:50 +02:00
|
|
|
}
|
|
|
|
|
2006-09-18 23:42:50 +02:00
|
|
|
warning("no working audio-driver found\n");
|
|
|
|
failed = True;
|
|
|
|
current_driver = auto_driver;
|
|
|
|
}
|
2006-09-17 13:04:50 +02:00
|
|
|
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2006-10-01 13:00:03 +02:00
|
|
|
static void
|
2006-09-17 13:04:50 +02:00
|
|
|
rdpsnd_register_drivers(char *options)
|
|
|
|
{
|
|
|
|
struct audio_driver **reg;
|
|
|
|
|
|
|
|
/* The order of registrations define the probe-order
|
|
|
|
when opening the device for the first time */
|
|
|
|
reg = &drivers;
|
|
|
|
#if defined(RDPSND_ALSA)
|
|
|
|
*reg = alsa_register(options);
|
|
|
|
reg = &((*reg)->next);
|
|
|
|
#endif
|
|
|
|
#if defined(RDPSND_SUN)
|
|
|
|
*reg = sun_register(options);
|
|
|
|
reg = &((*reg)->next);
|
|
|
|
#endif
|
2006-09-17 21:08:14 +02:00
|
|
|
#if defined(RDPSND_OSS)
|
|
|
|
*reg = oss_register(options);
|
|
|
|
reg = &((*reg)->next);
|
|
|
|
#endif
|
2006-09-17 13:04:50 +02:00
|
|
|
#if defined(RDPSND_SGI)
|
|
|
|
*reg = sgi_register(options);
|
|
|
|
reg = &((*reg)->next);
|
|
|
|
#endif
|
|
|
|
#if defined(RDPSND_LIBAO)
|
|
|
|
*reg = libao_register(options);
|
|
|
|
reg = &((*reg)->next);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
2006-09-21 21:00:11 +02:00
|
|
|
rdpsnd_init(char *optarg)
|
2006-09-17 13:04:50 +02:00
|
|
|
{
|
|
|
|
static struct audio_driver auto_driver;
|
|
|
|
struct audio_driver *pos;
|
2006-09-21 21:00:11 +02:00
|
|
|
char *driver = NULL, *options = NULL;
|
2006-09-17 13:04:50 +02:00
|
|
|
|
|
|
|
drivers = NULL;
|
2006-09-21 21:00:11 +02:00
|
|
|
|
|
|
|
rdpsnd_channel =
|
|
|
|
channel_register("rdpsnd", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP,
|
|
|
|
rdpsnd_process);
|
|
|
|
|
|
|
|
if (rdpsnd_channel == NULL)
|
|
|
|
{
|
|
|
|
error("channel_register\n");
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (optarg != NULL && strlen(optarg) > 0)
|
|
|
|
{
|
|
|
|
driver = options = optarg;
|
|
|
|
|
|
|
|
while (*options != '\0' && *options != ':')
|
|
|
|
options++;
|
|
|
|
|
|
|
|
if (*options == ':')
|
|
|
|
{
|
|
|
|
*options = '\0';
|
|
|
|
options++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*options == '\0')
|
|
|
|
options = NULL;
|
|
|
|
}
|
|
|
|
|
2006-09-17 13:04:50 +02:00
|
|
|
rdpsnd_register_drivers(options);
|
|
|
|
|
|
|
|
if (!driver)
|
|
|
|
{
|
|
|
|
auto_driver.wave_out_open = &rdpsnd_auto_open;
|
|
|
|
current_driver = &auto_driver;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = drivers;
|
|
|
|
while (pos != NULL)
|
|
|
|
{
|
|
|
|
if (!strcmp(pos->name, driver))
|
|
|
|
{
|
|
|
|
DEBUG(("selected %s\n", pos->name));
|
|
|
|
current_driver = pos;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
pos = pos->next;
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rdpsnd_show_help(void)
|
|
|
|
{
|
|
|
|
struct audio_driver *pos;
|
|
|
|
|
|
|
|
rdpsnd_register_drivers(NULL);
|
|
|
|
|
|
|
|
pos = drivers;
|
|
|
|
while (pos != NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, " %s:\t%s\n", pos->name, pos->description);
|
|
|
|
pos = pos->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-01 12:56:39 +02:00
|
|
|
void
|
2006-09-17 13:04:50 +02:00
|
|
|
rdpsnd_play(void)
|
|
|
|
{
|
|
|
|
current_driver->wave_out_play();
|
|
|
|
}
|
|
|
|
|
2006-10-01 12:56:39 +02:00
|
|
|
inline void
|
2006-09-17 12:32:18 +02:00
|
|
|
rdpsnd_queue_write(STREAM s, uint16 tick, uint8 index)
|
|
|
|
{
|
|
|
|
struct audio_packet *packet = &packet_queue[queue_hi];
|
|
|
|
unsigned int next_hi = (queue_hi + 1) % MAX_QUEUE;
|
|
|
|
|
|
|
|
if (next_hi == queue_lo)
|
|
|
|
{
|
|
|
|
error("No space to queue audio packet\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
queue_hi = next_hi;
|
|
|
|
|
|
|
|
packet->s = *s;
|
|
|
|
packet->tick = tick;
|
|
|
|
packet->index = index;
|
|
|
|
|
|
|
|
if (!g_dsp_busy)
|
2006-09-17 13:04:50 +02:00
|
|
|
current_driver->wave_out_play();
|
2006-09-17 12:32:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline struct audio_packet *
|
|
|
|
rdpsnd_queue_current_packet(void)
|
|
|
|
{
|
|
|
|
return &packet_queue[queue_lo];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline BOOL
|
|
|
|
rdpsnd_queue_empty(void)
|
|
|
|
{
|
|
|
|
return (queue_lo == queue_hi);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
rdpsnd_queue_init(void)
|
|
|
|
{
|
|
|
|
queue_lo = queue_hi = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
rdpsnd_queue_next(void)
|
|
|
|
{
|
2006-09-17 16:41:16 +02:00
|
|
|
xfree(packet_queue[queue_lo].s.data);
|
2006-09-17 12:32:18 +02:00
|
|
|
queue_lo = (queue_lo + 1) % MAX_QUEUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int
|
|
|
|
rdpsnd_queue_next_tick(void)
|
|
|
|
{
|
|
|
|
if (((queue_lo + 1) % MAX_QUEUE) != queue_hi)
|
|
|
|
{
|
|
|
|
return packet_queue[(queue_lo + 1) % MAX_QUEUE].tick;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return (packet_queue[queue_lo].tick + 65535) % 65536;
|
|
|
|
}
|
|
|
|
}
|