rdpsnd_libao.c revision d65680efa46fa49e8bf14e67b29b782510ff934c
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync/* -*- c-basic-offset: 8 -*-
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync rdesktop: A Remote Desktop Protocol client.
1ce069685b24d243eb0464f46d4c56b250c64445vboxsync Sound Channel Process Functions - libao-driver
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync Copyright (C) Matthew Chapman 2003-2007
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync Copyright (C) GuoJunBo guojunbo@ict.ac.cn 2003
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync Copyright (C) Michael Gernoth mike@zerfleddert.de 2005-2007
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync This program is free software; you can redistribute it and/or modify
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync it under the terms of the GNU General Public License as published by
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync the Free Software Foundation; either version 2 of the License, or
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync (at your option) any later version.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync This program is distributed in the hope that it will be useful,
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync but WITHOUT ANY WARRANTY; without even the implied warranty of
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync GNU General Public License for more details.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync You should have received a copy of the GNU General Public License
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync along with this program; if not, write to the Free Software
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync * Sun GPL Disclaimer: For the avoidance of doubt, except that if any license choice
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync * other than GPL or LGPL is available it will apply instead, Sun elects to use only
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync * the General Public License version 2 (GPLv2) at this time for any software where
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync * a choice of GPL license versions is made available with the language indicating
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync * that GPLv2 or any later version may be used, or where a choice of which version
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync * of the GPL is applied is otherwise unspecified.
4328e87247f4a96449677e199c7e99ef516fc1cevboxsynclibao_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv)
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync /* We need to be called rather often... */
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync o_device = ao_open_live(default_driver, &format, NULL);
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync /* Ack all remaining packets */
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync o_device = ao_open_live(default_driver, &format, NULL);
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync if (rdpsnd_dsp_resample_set(44100, pwfx->wBitsPerSample, pwfx->nChannels) == False)
657b2c9f6d33f08001e5fa6f6e0572dcf0391013vboxsync unsigned int duration;
6fe1329154975472e055284198df7fa8e64dee3avboxsync /* We shouldn't be called if the queue is empty, but still */
6fe1329154975472e055284198df7fa8e64dee3avboxsync len = (WAVEOUTLEN > (out->end - out->p)) ? (out->end - out->p) : WAVEOUTLEN;
6fe1329154975472e055284198df7fa8e64dee3avboxsync duration = ((tv.tv_sec - prev_s) * 1000000 + (tv.tv_usec - prev_us)) / 1000;
6fe1329154975472e055284198df7fa8e64dee3avboxsync if ((out->p == out->end) || duration > next_tick - packet->tick + 500)
6fe1329154975472e055284198df7fa8e64dee3avboxsync unsigned int delay_us;
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync if (abs((next_tick - packet->tick) - duration) > 20)
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync DEBUG(("duration: %d, calc: %d, ", duration, next_tick - packet->tick));
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync DEBUG(("last: %d, is: %d, should: %d\n", packet->tick,
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync (packet->tick + duration) % 65536, next_tick % 65536));
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync libao_driver.description = "libao output driver, default device: system dependent";
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync libao_driver.wave_out_format_supported = rdpsnd_dsp_resample_supported;
4328e87247f4a96449677e199c7e99ef516fc1cevboxsync libao_driver.wave_out_set_format = libao_set_format;