From: <as...@us...> - 2010-04-09 13:12:38
|
Revision: 1592 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1592&view=rev Author: astrand Date: 2010-04-09 13:12:31 +0000 (Fri, 09 Apr 2010) Log Message: ----------- Properly reset sound subsystem when reconnecting due to screen size change (RandR). Modified Paths: -------------- rdesktop/trunk/proto.h rdesktop/trunk/rdesktop.c rdesktop/trunk/rdpsnd.c Modified: rdesktop/trunk/proto.h =================================================================== --- rdesktop/trunk/proto.h 2010-04-09 12:51:14 UTC (rev 1591) +++ rdesktop/trunk/proto.h 2010-04-09 13:12:31 UTC (rev 1592) @@ -174,6 +174,7 @@ RD_BOOL rdpsnd_queue_empty(void); void rdpsnd_queue_next(unsigned long completed_in_us); int rdpsnd_queue_next_tick(void); +void rdpsnd_reset_state(void); /* secure.c */ void sec_hash_48(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2, uint8 salt); void sec_hash_16(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2); Modified: rdesktop/trunk/rdesktop.c =================================================================== --- rdesktop/trunk/rdesktop.c 2010-04-09 12:51:14 UTC (rev 1591) +++ rdesktop/trunk/rdesktop.c 2010-04-09 13:12:31 UTC (rev 1592) @@ -354,6 +354,9 @@ #ifdef WITH_SCARD scard_reset_state(); #endif +#ifdef WITH_RDPSND + rdpsnd_reset_state(); +#endif } static RD_BOOL Modified: rdesktop/trunk/rdpsnd.c =================================================================== --- rdesktop/trunk/rdpsnd.c 2010-04-09 12:51:14 UTC (rev 1591) +++ rdesktop/trunk/rdpsnd.c 2010-04-09 13:12:31 UTC (rev 1592) @@ -73,6 +73,7 @@ static void rdpsnd_queue_write(STREAM s, uint16 tick, uint8 index); static void rdpsnd_queue_init(void); +static void rdpsnd_queue_clear(void); static void rdpsnd_queue_complete_pending(void); static long rdpsnd_queue_next_completion(void); @@ -150,6 +151,16 @@ record_buffer_size = 0; } +static void +rdpsnd_clear_record(void) +{ + /* + * Silently drop everything we have in the record buffer as + * we've somehow gotten a reset in regard to the server. + */ + record_buffer_size = 0; +} + void rdpsnd_record(const void *data, unsigned int size) { @@ -727,6 +738,23 @@ } void +rdpsnd_reset_state(void) +{ + if (device_open) + current_driver->wave_out_close(); + device_open = False; + + rdpsnd_queue_clear(); + + if (rec_device_open) + current_driver->wave_in_close(); + rec_device_open = False; + + rdpsnd_clear_record(); +} + + +void rdpsnd_show_help(void) { struct audio_driver *pos; @@ -811,6 +839,23 @@ queue_pending = queue_lo = queue_hi = 0; } +static void +rdpsnd_queue_clear(void) +{ + struct audio_packet *packet; + + /* Go through everything, not just the pending packets */ + while (queue_pending != queue_hi) + { + packet = &packet_queue[queue_pending]; + xfree(packet->s.data); + queue_pending = (queue_pending + 1) % MAX_QUEUE; + } + + /* Reset everything back to the initial state */ + queue_pending = queue_lo = queue_hi = 0; +} + void rdpsnd_queue_next(unsigned long completed_in_us) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |