Exemplo n.º 1
0
bool SSpStreamMixer::begin(SSpPlayTask* pTask, float fTime)
{
    // Does not check on number of channels - allowing crossfades
    sspAutoLock autolock(m_synch);
    sspDSbuffer* pBuf = new sspDSbuffer(
        m_nChannels,
        sspPool::Instance().values.getValue(pTask->getVolumeFactor())->getValue(),
        fTime);
    bool bExecuteOK = pTask->execute(true, m_pStream, pBuf);
    if (bExecuteOK && pTask->getResourceUsage(SSP_WAV) > 0) {
        DOUT1(_T("SSpStreamMixer begin %s successfully\n"), pTask->getName().c_str());
        m_pBuffers.push_back(pBuf);
    }
    else {
        DOUT1(_T("SSpStreamMixer begin %s failed\n"), pTask->getName().c_str());
        pTask->clearBuffer();
        delete pBuf;
    }
    return bExecuteOK;
}
Exemplo n.º 2
0
void SSpStreamMixer::end()
{
    sspAutoLock autolock(m_synch);
    DOUT1(_T("SSpStreamMixer end - current size: %d\n"), m_pBuffers.size());
    for (sspDSbufferElem i = m_pBuffers.begin(); i != m_pBuffers.end(); ++i) {
        if (!(*i)->isPlaying()) {
            delete (*i);
            m_pBuffers.erase(i);
            break;
        }
    }
}
Exemplo n.º 3
0
int main(int n,char **argv) {

	const char *fname = NULL;
	const char *ofile = NULL;
	FILE 	*fp;
	int	print_stat = 1;
	int 	ch;
	const char  *sm_radius_dir = NULL;

	progname = argv[0];

	fr_debug_flag = 0;

	while ((ch = getopt(n, argv, "d:i:xo:qvc")) != -1)
	 	switch (ch) {
	 		case 'd':
	 			sm_radius_dir = optarg;
				break;
			case 'i':
				fname = optarg;
				break;
			case 'x':
				fr_debug_flag++;
			case 'o':
				ofile = optarg;
				break;
			case 'q':
				print_stat = 0;
				break;
			case 'v':
				printf("%s: $Id: 3425c4d125ea93aeef03abbbca7dd4f156480d26 $ \n",progname);
				exit(0);
			case 'c':
				oflags = O_CREAT | O_TRUNC | O_RDWR;
				break;
			default: sm_usage();exit(1);
	 	}




	if ( sm_radius_dir == NULL ) sm_radius_dir = RADDBDIR;

	DOUT1("Use dictionary in: %s\n",sm_radius_dir);
	if (dict_init(sm_radius_dir, RADIUS_DICTIONARY) < 0 ) {
       		fr_perror("parser: init dictionary:");
                exit(1);
        }

	if ( fname == NULL || fname[0] == '-') {
		fp = stdin;
		fname = "STDIN";
	} else if ( ( fp = fopen(fname, "r") ) == NULL ) {
		fprintf( stderr,"%s: Couldn't open source file\n", progname);
		exit(1);
	}

	if ( ofile == NULL ) ofile = "sandy_db" ;
	if ( open_storage(ofile) ) {
	 	exit (1);
	}

	sm_parse_file(fp,fname);

	close_storage();

	if ( print_stat )
	  fprintf(stderr,"\nRecord loaded: %lu\nLines parsed: %lu\nRecord skiped: %lu\nWarnings: %lu\nErrors: %lu\n"
	  	,st_loaded,st_lines,st_skiped,st_warns,st_errors);

        return 0;
}
Exemplo n.º 4
0
static int sm_parse_file(FILE*fp,const char* fname) {
        FR_TOKEN tok;
        VALUE_PAIR *vp = NULL;
	sm_parse_state_t  parse_state = SMP_USER;
	unsigned long lino  = 0;
	char *p;
	char buff[MAX_BUFF_SIZE];
	char username[256];


	while( parse_state != SMP_INVALID && fgets(buff, sizeof(buff), fp) != NULL ) {

		lino ++;
		st_lines++;
		if ( strchr(buff, '\n') == NULL) {
			fprintf(stderr,"%s: %s[%lu]:Warning: line too long or not closed by \\n character. Skiped\n",progname,fname,lino);
			st_warns++;
			st_skiped++; /* _LINE_ skiped */
			continue;
		}

		DOUT2("Parseline: %s",buff);
		for ( p = buff; isspace((int) *p); p++);

		if ( *p == '#' || *p == 0 ) continue;

		/* userparse hack */
		if (  *p == ';' ) *p = '\n';
		p = buff;

		/* try to decide is this line new user or new pattern */
		if ( parse_state == SMP_PATTERN_OR_USER ) {
		     if ( isspace((int) buff[0]) ) parse_state = SMP_PATTERN;
		     	else {
		     		parse_state = SMP_USER;
		     		storecontent(username);
		     		st_users++;
		     	}
		 }

		if ( parse_state == SMP_USER ) {
		    tok = getuname(&p,username,sizeof(username));

		    /* check: is it include. not implemented */

		    if ( tok ) {
			fprintf(stderr ,"%s: %s[%lu]: error while expecting user name\n",progname,fname,lino);
			parse_state = SMP_INVALID;
			st_errors++;
		    } else {
		    	parse_state = SMP_PATTERN;
		    	DOUT1("Found user: %s\n",username);

		    }
		}
		if ( parse_state == SMP_PATTERN || parse_state == SMP_ACTION ) {

		    /* check for empty line */
		    while( *p && isspace((int) *p) ) p++;

		    if ( *p && ( *p != ';' ) ) tok = userparse(p,&vp);
		    else tok = T_EOL;  /* ';' - signs empty line */

		    switch(tok) {
		    	case T_EOL: /* add to content */
		    			addlinetocontent(vp);
		    			pairfree(&vp);
		    			if ( parse_state == SMP_PATTERN )
		    				parse_state = SMP_ACTION;
		    			else parse_state = SMP_PATTERN_OR_USER;

		    	case T_COMMA: break;  /* parse next line */
		    	default: /* error: we do  not expect anything else */
		    			fprintf(stderr ,"%s: %s[%lu]: syntax error\n",progname,fname,lino);
		    			fr_perror("Error");
		    			parse_state = SMP_INVALID;
		    			st_errors++;
		    }
		}
	}
	if ( feof(fp) ) switch (parse_state ) {
		case  SMP_USER: /* file is empty, last line is comment  */
			   			break;
		case  SMP_PATTERN: /* only username ?*/
				fprintf(stderr ,"%s: %s[%lu]: EOF while pattern line are expecting\n",progname,fname,lino);
				st_errors++;
				parse_state = SMP_INVALID;
				break;
		case  SMP_ACTION: /* looking for reply line */
				fprintf(stderr ,"%s: %s[%lu]: EOF while reply line are expecting\n",progname,fname,lino);
				st_errors++;
				parse_state = SMP_INVALID;
				break;
		case  SMP_PATTERN_OR_USER:
				storecontent(username);
				st_users++;
				break;
		default:break;
	} else if ( parse_state != SMP_INVALID ) {  /* file read error */
		fprintf(stderr ,"%s: error file reading from file\n",progname);
	}
	pairfree(&vp);

	return (parse_state == SMP_INVALID)?-1:0;
}