Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 76127 | Differences between
and this patch

Collapse All | Expand All

(-)pytsp/pyesd.c (-35 / +17 lines)
Lines 566-609 Link Here
566
566
567
void esd_stop_recording() {stop_recording=1;}
567
void esd_stop_recording() {stop_recording=1;}
568
568
569
char *esd_record_sound(int len, int rate_hz, int channelsd, int formatd) {
569
/*
570
	int nread=-1;
570
	function: esd_record_sound
571
	char rbuf[ESD_BUF_SIZE];   /* ESD_BUF_SIZE */
571
		rewritten for bug fixes and concise-ness 
572
	char *rbuf2=rbuf;
572
		by Marvin Otto - sivunguvungu at cox.net
573
	char buffer[len+1];
573
		on 9 April 2005.
574
	char *buffer_d=buffer;
574
	
575
	int cursor=1;
575
	output: returns a pointer to allocated memory or NULL if error
576
	int copyi;
576
				be sure to free it when finished.
577
	int space_left; 
577
*/
578
578
579
	/* FILE *target; */
579
char *esd_record_sound(int len, int rate_hz, int channelsd, int formatd) {
580
	space_left=len-cursor;
580
	char *buffer = NULL;
581
	int cursor = 0;
581
582
582
	if (init_esd_record( rate_hz,  channelsd,  formatd)) {
583
	if (init_esd_record( rate_hz,  channelsd,  formatd)) {
583
584
		buffer = malloc(len + 1);
584
		/* target = fopen( "aggy.raw", "w" );  */
585
		memset(buffer, 0, len + 1); // ZeroMemory
585
		sprintf(buffer,"%s","");
586
		stop_recording=0;
586
		stop_recording=0;
587
587
588
		while (space_left>0) {
588
		while (!stop_recording && (cursor += record(buffer + cursor, len - cursor)) < len)
589
			nread=record(rbuf,ESD_BUF_SIZE);
590
			if (! nread) {break;}
591
			copyi=nread;			
592
			if (copyi>space_left) {copyi=space_left;}
593
594
			/* fwrite( buf2, 1, nread, target );  */
595
			strncat(buffer,rbuf,copyi);
596
			cursor=cursor+copyi;
597
			space_left=len-cursor;  
598
			sleep(0.007);
589
			sleep(0.007);
599
			if (stop_recording==1) {break;}
590
	}
600
									      }
601
		/* fclose(target);  */
602
603
												
604
									   												} else {return NULL; }
605
591
606
	return buffer_d;
592
	return buffer;
607
}
593
}
608
594
609
595
Lines 667-673 Link Here
667
	free(myptr);
653
	free(myptr);
668
	return written;
654
	return written;
669
}
655
}
670
671
672
673
(-)pytsp/pytruespeech.c (-11 / +10 lines)
Lines 642-666 Link Here
642
	 recording_driver=1;
642
	 recording_driver=1;
643
643
644
	if (recorded != NULL) {
644
	if (recorded != NULL) {
645
		if (strlen(recorded)>=4096) {
645
	//	if (strlen(recorded)>=4096) {
646
			ofile=fopen(infile, "wb");
646
			ofile=fopen(infile, "wb");
647
			if (ofile) {
647
			if (ofile) {
648
648
649
				owritten=fwrite(recorded, 1, strlen(recorded), ofile);
649
				//owritten=fwrite(recorded, 1, strlen(recorded), ofile);
650
				owritten=fwrite(recorded, 1, ilen, ofile);
650
				fflush(ofile);
651
				fflush(ofile);
651
				fclose(ofile);
652
				fclose(ofile);
652
653
653
				if (owritten==strlen(recorded)) {
654
				//if (owritten==strlen(recorded)) {
655
				if (owritten==ilen){
654
656
655
					if (convertfile(infile, outfile, 8000, 16,1, 1)) { return outfile;}
657
					if (convertfile(infile, outfile, 8000, 16,1, 1)) { return outfile;}
656
													 			    }
658
				}
657
659
658
						  }
660
			}
659
		
661
	//	}
660
											  		  }
662
		free(recorded);
661
663
	}
662
								  }
663
	return "";
664
	return "";
664
}
665
}
665
666

Return to bug 76127