CVS: rdesktop rdpsnd_sun.c,1.32,1.33

Pierre Ossman <[email protected]> Fri, 08 Feb 2008 02:36:30 -0800
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv17659

Modified Files:
	rdpsnd_sun.c 
Log Message:
Fondle the device a bit more carefully when recording to guarantee that we
properly sync up with the data stream. This is crucial to get reliable
behaviour on multi-byte frames.


Index: rdpsnd_sun.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_sun.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** rdpsnd_sun.c	22 Jan 2008 10:42:55 -0000	1.32
--- rdpsnd_sun.c	8 Feb 2008 10:36:28 -0000	1.33
***************
*** 58,61 ****
--- 58,96 ----
  void sun_record(void);
  
+ static int
+ sun_pause(void)
+ {
+ 	audio_info_t info;
+ 
+ 	AUDIO_INITINFO(&info);
+ 
+ 	info.record.pause = 1;
+ 
+ 	if (ioctl(dsp_fd, AUDIO_SETINFO, &info) == -1)
+ 		return -1;
+ 
+ #if defined I_FLUSH && defined FLUSHR
+ 	if (ioctl(dsp_fd, I_FLUSH, FLUSHR) == -1)
+ 		return -1;
+ #endif
+ 
+ 	return 0;
+ }
+ 
+ static int
+ sun_resume(void)
+ {
+ 	audio_info_t info;
+ 
+ 	AUDIO_INITINFO(&info);
+ 
+ 	info.record.pause = 0;
+ 
+ 	if (ioctl(dsp_fd, AUDIO_SETINFO, &info) == -1)
+ 		return -1;
+ 
+ 	return 0;
+ }
+ 
  void
  sun_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv)
***************
*** 131,134 ****
--- 166,182 ----
  	}
  
+ 	/*
+ 	 * Pause recording until we actually start using it.
+ 	 */
+ 	if (dsp_mode != O_WRONLY)
+ 	{
+ 		if (sun_pause() == -1)
+ 		{
+ 			close(dsp_fd);
+ 			dsp_fd = -1;
+ 			return False;
+ 		}
+ 	}
+ 
  	dsp_refs++;
  
***************
*** 182,188 ****
--- 230,253 ----
  sun_open_in(void)
  {
+ #if ! (defined I_FLUSH && defined FLUSHR)
+ 	/*
+ 	 * It is not possible to reliably use the recording without
+ 	 * flush operations.
+ 	 */
+ 	return False;
+ #endif
+ 
  	if (!sun_open(O_RDONLY))
  		return False;
  
+ 	/*
+ 	 * Unpause the stream now that we have someone using it.
+ 	 */
+ 	if (sun_resume() == -1)
+ 	{
+ 		sun_close();
+ 		return False;
+ 	}
+ 
  	dsp_in = True;
  
***************
*** 193,196 ****
--- 258,266 ----
  sun_close_in(void)
  {
+ 	/*
+ 	 * Repause the stream when the user goes away.
+ 	 */
+ 	sun_pause();
+ 
  	sun_close();
  
***************
*** 235,238 ****
--- 305,310 ----
  	}
  
+ 	sun_pause();
+ 
  	if (pwfx->wBitsPerSample == 8)
  	{
***************
*** 280,283 ****
--- 352,358 ----
  	dsp_configured = True;
  
+ 	if (dsp_in)
+ 		sun_resume();
+ 
  	return True;
  }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/