Hello,

o Jason Penton [06/10/08 16:44]:
> Hi Stefan
> 
> Just a note to the list.
> 
> This worked perfectly - all I had to do was add the getters and setters 
> for autorewind to IvrAudio.cpp
for convenience can you send a patch made with
$ svn diff
?

thanks
Stefan

> 
> Thanks
> Cheers
> Jason
> 
> On Fri, May 30, 2008 at 12:36 AM, Stefan Sayer <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
>     Hello Jason,
> 
>     o Jason Penton [05/29/08 18:01]:
> 
>         Hi All
> 
>         I noticed a problem today when trying to enqueue audio files via
>         python:
> 
>         basically if I queue the same file more than once, the second
>         instance does not actually play. For example:
> 
>         for example
> 
>         (line 1) self.enqueue(self.voice_lib['yes'],None)
>         (line 2) self.enqueue(self.voice_lib['no'],None)
>         (line 3) self.enqueue(self.voice_lib['yes'],None)
> 
>         everything works fine, except line 3 never plays the second
>         'yes' file.
> 
>     yes, the file is already at its end.
> 
> 
>         It does however work if I flush the q before line 3 but surely the
>         above should work??????
> 
>         on investigation into the source code it appears that there is a
>         problem in AmPlaylist.cpp where the initial audio file is never
>         'rewound' to the beginning. The result is that the second play
>         of that file doesnt have any data as it is at the end of the file.
> 
>     if you use another IvrAudioFile object, that would work as well.
> 
> 
> 
>         I managed to solve this with the following code, but not sure if
>         there is a better solution. Possibly we need a variable to flag
>         if a file that has already been played within the queue so it
>         can be rewound instead of forcing a rewind for every file (which
>         is unnecessary)
> 
>     hm, what I do not like that much about this way to fix the problem
>     is that it is not possible to not have the AmAudio rewound before it
>     is played. If you for example are playing half of a file, then you
>     get to put something different in the queue, and then re-enqueue the
>     first file, it is played from the beginning.
> 
>     so, what about a property "auto-rewind" for
>     AmAudioFile/IvrAudioFile? you remember VCR - some players had this
>     feature to automatically rewind the tape and eject it, if you had
>     watched it to the end. so you did not have to pay extra at the video
>     shop. just that here this would be a switch on the cassette
>     'auto-rewind me if played to the end'.
> 
>     translated to code it might look like
> 
>     $ svn diff
>     Index: AmAudioFile.h
>     ===================================================================
>     --- AmAudioFile.h       (revision 994)
>     +++ AmAudioFile.h       (working copy)
>     @@ -106,6 +106,7 @@
> 
>      public:
>       AmSharedVar<bool> loop;
>     +  AmSharedVar<bool> autorewind;
> 
>       AmAudioFile();
>       ~AmAudioFile();
>     Index: AmAudioFile.cpp
>     ===================================================================
>     --- AmAudioFile.cpp     (revision 994)
>     +++ AmAudioFile.cpp     (working copy)
>     @@ -213,7 +213,7 @@
> 
>      AmAudioFile::AmAudioFile()
>       : AmBufferedAudio(0, 0, 0), data_size(0),
>     -    fp(0), begin(0), loop(false),
>     +    fp(0), begin(0), loop(false), autorewind(false),
>         on_close_done(false),
>         close_on_exit(true)
>      {
>     @@ -322,6 +322,11 @@
>           rewind();
>           goto read_block;
>           }
>     +
>     +    if (autorewind.get() && data_size>0){
>     +      DBG("autorewinding audio file...\n");
>     +      rewind();
>     +    }
> 
>         ret = -2; // eof
>       }
> 
>     The ivr functions would be like the getters/setters 'loop' function
>     in IvrAudio.cpp. What do you think?
> 
>     Stefan
> 
> 
>         code fix:
> 
>         void AmPlaylist::updateCurrentItem()
>         {
>          if(!cur_item){
>            items_mut.lock();
>            if(!items.empty()){
>              if (items.front()){
>                DBG("making sure the file to be played is rewound\n");
>                AmAudioFile * p = (AmAudioFile*)items.front()->play;
>                p->rewind();
>              }
>              cur_item = items.front();
>              items.pop_front();
>            }
>            items_mut.unlock();
>          }
>         }
> 
>         Cheers
>         Jason Penton
> 
> 
> 
> 
> 
>         
> ------------------------------------------------------------------------
> 
>         _______________________________________________
>         Semsdev mailing list
>         [email protected] <mailto:[email protected]>
>         http://lists.iptel.org/mailman/listinfo/semsdev
> 
> 
>     -- 
>     Stefan Sayer
>     VoIP Services
> 
>     [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>     www.iptego.com <http://www.iptego.com>
> 
>     iptego GmbH
>     Am Borsigturm 40
>     13507 Berlin
>     Germany
> 
>     Amtsgericht Charlottenburg, HRB 101010
>     Geschaeftsfuehrer: Alexander Hoffmann
> 
> 

-- 
Stefan Sayer
VoIP Services

[EMAIL PROTECTED]
www.iptego.com

iptego GmbH
Am Borsigturm 40
13507 Berlin
Germany

Amtsgericht Charlottenburg, HRB 101010
Geschaeftsfuehrer: Alexander Hoffmann
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to