AGI->stream_file problem

I’m running asterisk 1.4.2 on several OpenSUSE machines (10.0 and 10.2).
I’m trying to use (using Asterisk::AGI perl module) the stream_file function.
This is my agi script:

#!/usr/bin/perl

use strict;
use warnings;
use Asterisk::AGI;

my $AGI = new Asterisk::AGI;

# sound files in use
my $demoGsm  = "demo-instruct";

open LOGFILE, '>>', '/var/log/asterisk/streamFileTest.log';

playAudio($demoGsm, '0123456789');

close LOGFILE;

# -------------------------------------------------

sub playAudio
{
    # returns -2 for no digit pressed during play
    #         -1 for failure to play audio
    #         -3 for non-digit pressed
    #         digit pressed
    # (see http://www.voip-info.org/wiki/view/stream+file for return codes)

    my ($i_audio, $valid_digits) = @_;
    my $dir = "/var/lib/asterisk/sounds/";

    Log("Ready to play '$i_audio'");
    my $asc = $AGI->stream_file($i_audio, $valid_digits);
    Log("After, result of stream_file: $asc.");

    my ($msg, $dtmf_result);
    if (!$asc)
    {
        $dtmf_result = -2;
        $msg    = " No DTMF digit pressed!!!";
    }
    elsif ($asc == -1)
    {
        $dtmf_result = -1;
        $msg    = " (error or hangup)";
    }
    else
    {
        my $digit    = chr($asc);
        $msg      = " and received DTMF '$digit'";
        $dtmf_result   = ($digit =~ /\d/ ? $digit : -3);
    }
    Log("Finished playing '$i_audio' $msg");
    return $dtmf_result;
} # sub playAudio

# -------------------------------------------------

sub Log
{
    my $msg = shift;
    my $prefix = "[ " . localtime() . " ] ";
    $AGI->verbose($prefix . $msg);
    print LOGFILE ($prefix . $msg . "\n");
}

On some machines it works and on the console I get (with adi debug):


GOOD*CLI>
GOOD*CLI> agi debug

    -- Executing [1248@default:1] Answer("SIP/barak-081cd168", "") in new stack
    -- Executing [1248@default:2] AGI("SIP/barak-081cd168", "bg_streamfile.agi") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/bg_streamfile.agi
AGI Tx >> agi_request: bg_streamfile.agi
AGI Tx >> agi_channel: SIP/barak-081cd168
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1215433422.4
AGI Tx >> agi_callerid: barak
AGI Tx >> agi_calleridname: Barak Ginat
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 1248
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: default
AGI Tx >> agi_extension: 1248
AGI Tx >> agi_priority: 2
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>

AGI Rx << VERBOSE "[ Mon Jul  7 15:23:42 2008 ] Ready to play 'demo-instruct'"
  bg_streamfile.agi: [ Mon Jul  7 15:23:42 2008 ] Ready to play 'demo-instruct'
AGI Tx >> 200 result=1
AGI Rx << STREAM FILE demo-instruct 0123456789
    -- Playing 'demo-instruct' (escape_digits=0123456789) (sample_offset 0)
AGI Tx >> 200 result=50 endpos=9920
AGI Rx << VERBOSE "[ Mon Jul  7 15:23:43 2008 ] After, result of stream_file: 50."
  bg_streamfile.agi: [ Mon Jul  7 15:23:43 2008 ] After, result of stream_file: 50.
AGI Tx >> 200 result=1
AGI Rx << VERBOSE "[ Mon Jul  7 15:23:43 2008 ] Finished playing 'demo-instruct'  and received DTMF '2'"
  bg_streamfile.agi: [ Mon Jul  7 15:23:43 2008 ] Finished playing 'demo-instruct'  and received DTMF '2'
AGI Tx >> 200 result=1

    -- AGI Script bg_streamfile.agi completed, returning 0
    -- Executing [1248@default:3] Hangup("SIP/barak-081cd168", "") in new stack
  == Spawn extension (default, 1248, 3) exited non-zero on 'SIP/barak-081cd168'
GOOD*CLI>

On other machines the stream_file returns immediately and the return value is “undef”:


STRANGE*CLI>
STRANGE*CLI> agi debug
    -- Executing [1248@incoming:1] Goto("SIP/97229924549-081eedb0", "default|1248|1") in new stack
    -- Goto (default,1248,1)
    -- Executing [1248@default:1] Answer("SIP/97229924549-081eedb0", "") in new stack
    -- Executing [1248@default:2] AGI("SIP/97229924549-081eedb0", "bg_streamfile.agi") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/bg_streamfile.agi
AGI Tx >> agi_request: bg_streamfile.agi
AGI Tx >> agi_channel: SIP/97229924549-081eedb0
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1215430419.2
AGI Tx >> agi_callerid: 97229924549
AGI Tx >> agi_calleridname: 97229924549
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 1248
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: default
AGI Tx >> agi_extension: 1248
AGI Tx >> agi_priority: 2
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >> lnx-wst*CLI>

AGI Rx << VERBOSE "[ Mon Jul  7 14:33:39 2008 ] Ready to play 'demo-instruct' -- 1st time; escape digits: 0123456789."
  bg_streamfile.agi: [ Mon Jul  7 14:33:39 2008 ] Ready to play 'demo-instruct' -- 1st time; escape digits: 0123456789.
AGI Tx >> 200 result=1
AGI Rx << STREAM FILE demo-instruct 0123456789
    -- Playing 'demo-instruct' (escape_digits=0123456789) (sample_offset 0)
AGI Rx << VERBOSE "[ Mon Jul  7 14:33:39 2008 ] After, result of stream_file: ."
  bg_streamfile.agi: [ Mon Jul  7 14:33:39 2008 ] After, result of stream_file: .
AGI Tx >> 200 result=1

AGI Rx << VERBOSE "[ Mon Jul  7 14:33:39 2008 ] Finished playing 'demo-instruct'  No DTMF digit pressed!!!"
  bg_streamfile.agi: [ Mon Jul  7 14:33:39 2008 ] Finished playing 'demo-instruct'  No DTMF digit pressed!!!
AGI Tx >> 200 result=1

    -- AGI Script bg_streamfile.agi completed, returning 0
    -- Executing [1248@default:3] Hangup("SIP/97229924549-081eedb0", "") in new stack
  == Spawn extension (default, 1248, 3) exited non-zero on 'SIP/97229924549-081eedb0'
Really destroying SIP dialog '3E0EE57D-A974-4C26-8071-D837A3156008@172.16.50.92' Method: ACK
STRANGE*CLI> 

TIA
Barak