Stefan Sayer writes:
> I just had a look at the code which takes the prompts for voicemail
> application from DB, and it seems to me that on every call the local
> file in /tmp is overwritten. Is that how it was meant to be? If the file
> is played from at that very moment, I am not sure how filesystem behaves
> in that case; the prompt might change right in the middle of it playing
> if the prompt is changed in DB.
yes, looks like that could happen. announcements are not changed very
frequently, so i though that it would not matter.
i think i did it because i wanted to be able to reuse rest of the code
and thus wrote announcement to a file.
> If it is read from DB each time anyway, I would suggest using a
> tmpfile(3), write the audio from DB there, and pass it to the
> AnswerMachineDialog as the greeting_fp. It will then get freed on
> close(2) which AmAudioFile does when it finished playing.
yes, that would be a better solution. after adding db support to
voicemail app, i stopped using it myself and wrote voicemail as an ivr
app. there i do as you suggest and use os.tmpfile():
def findAudioMsg(self, msg, start):
wav = IvrAudioFile()
try:
cursor = self.db.cursor()
cursor.execute("SELECT audio FROM user_audio WHERE application='" +
self.application + "' AND message='" + msg + "' AND domain='" +
self.dialog.domain + "' AND userid='" + self.dialog.user + "'")
if cursor.rowcount > 0:
self.getFromTemp(cursor.fetchone()[0], msg, wav)
cursor.close()
return True
cursor.execute("SELECT audio FROM default_audio WHERE
application='" + self.application + "' AND message='" + msg + "' AND
language='" + (self.language) + "'")
if cursor.rowcount > 0:
self.getFromTemp(cursor.fetchone()[0], msg, wav)
cursor.close()
return True
else:
error(APPLICATION + ": default " + msg + " is missing!")
cursor.close()
return False
except MySQLdb.Error, e:
error(APPLICATION + ": error in accessing database: " +\
str(e.args[0]) + ":" + e.args[1])
return False
def getFromTemp(self, audio, msg, wav):
debug("Found audio file of length " + str(len(audio)))
fp = os.tmpfile()
fp.write(audio)
fp.seek(0)
wav.fpopen("tmp.wav", AUDIO_READ, fp)
self.audio[msg] = wav
perhaps it is too late now to invest effort in improving c++ voicemail,
but try to write a new one using dsm.
-- juha
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev