[Asterisk-Dev] say.c cleanup

Luigi Rizzo rizzo at icir.org
Wed Jul 13 01:32:12 MST 2005


say.c has the following sequence repeated a zillion times:

	if(!ast_streamfile(chan, fn, language)) {
	    if ((audiofd  > -1) && (ctrlfd > -1))
		res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
	    else
		res = ast_waitstream(chan, ints);
	} 
	ast_stopstream(chan);

which obviously deserves to be changed into a function.
There is actually a similar one, ast_play_and_wait(), which
apart from the extra audiofd and ctrlfd has a difference
that caught my attention:


    int ast_play_and_wait(struct ast_channel *chan, const char *fn)
    {
        int d;
        d = ast_streamfile(chan, fn, chan->language);
        if (d)
                return d;   
        d = ast_waitstream(chan, AST_DIGIT_ANY);
        ast_stopstream(chan);
        return d;
    }

as you see, if ast_streamfile() fails, ast_stopstream() is not called.
Can someone explain which way is correct or whether they
are equivalent ?

	thanks
	luigi



More information about the asterisk-dev mailing list