CVS: rdesktop rdpsnd_oss.c,1.11,1.12

Michael Gernoth <[email protected]>
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16923

Modified Files:
	rdpsnd_oss.c 
Log Message:
much better playback with non-broken oss-drivers
no change for broken drivers...


Index: rdpsnd_oss.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_oss.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** rdpsnd_oss.c	3 Sep 2004 18:04:48 -0000	1.11
--- rdpsnd_oss.c	3 Sep 2004 22:35:08 -0000	1.12
***************
*** 34,37 ****
--- 34,38 ----
  static int g_snd_rate;
  static short g_samplewidth;
+ static BOOL g_driver_broken = False;
  
  static struct audio_packet
***************
*** 86,90 ****
  wave_out_set_format(WAVEFORMATEX * pwfx)
  {
! 	int stereo, format;
  
  	ioctl(g_dsp_fd, SNDCTL_DSP_RESET, NULL);
--- 87,91 ----
  wave_out_set_format(WAVEFORMATEX * pwfx)
  {
! 	int stereo, format, fragments;
  
  	ioctl(g_dsp_fd, SNDCTL_DSP_RESET, NULL);
***************
*** 130,133 ****
--- 131,158 ----
  	}
  
+ 	/* try to get 7 fragments of 2^12 bytes size */
+ 	fragments = (7 << 16) + 12;
+ 	ioctl(g_dsp_fd, SNDCTL_DSP_SETFRAGMENT, &fragments);
+ 
+ 	if (!g_driver_broken)
+ 	{
+ 		audio_buf_info info;
+ 
+ 		if (ioctl(g_dsp_fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
+ 		{
+ 			perror("SNDCTL_DSP_GETOSPACE");
+ 			close(g_dsp_fd);
+ 			return False;
+ 		}
+ 
+ 		if (info.fragments == 0 || info.fragstotal == 0 || info.fragsize == 0)
+ 		{
+ 			fprintf(stderr,
+ 				"Broken OSS-driver detected: fragments: %d, fragstotal: %d, fragsize: %d\n",
+ 				info.fragments, info.fragstotal, info.fragsize);
+ 			g_driver_broken = True;
+ 		}
+ 	}
+ 
  	return True;
  }
***************
*** 204,207 ****
--- 229,233 ----
  	static BOOL started = False;
  	struct timeval tv;
+ 	audio_buf_info info;
  
  	while (1)
***************
*** 224,228 ****
  		}
  
! 		len = write(g_dsp_fd, out->p, out->end - out->p);
  		if (len == -1)
  		{
--- 250,278 ----
  		}
  
! 		len = out->end - out->p;
! 
! 		if (!g_driver_broken)
! 		{
! 			if (ioctl(g_dsp_fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
! 			{
! 				perror("SNDCTL_DSP_GETOSPACE");
! 				return;
! 			}
! 
! 			if (info.fragments == 0)
! 			{
! 				g_dsp_busy = 1;
! 				return;
! 			}
! 
! 			if (info.fragments * info.fragsize < len
! 			    && info.fragments * info.fragsize > 0)
! 			{
! 				len = info.fragments * info.fragsize;
! 			}
! 		}
! 
! 
! 		len = write(g_dsp_fd, out->p, len);
  		if (len == -1)
  		{



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.