def call_backend(cmd, waitmsg, mode, params)
pipe = Tempfile.new("boohpipe")
- Thread.critical = true
path = pipe.path
pipe.close!
system("mkfifo #{path}")
- Thread.critical = false
cmd += " --info-pipe #{path}"
button, w8 = backend_wait_message($main_window, waitmsg, path, mode)
pid = nil
$orig_filename = $filename
$main_window.title = 'booh - ' + File.basename($orig_filename)
tmp = Tempfile.new("boohtemp")
- Thread.critical = true
$filename = tmp.path
tmp.close!
#- for security
ios = File.open($filename, File::RDWR|File::CREAT|File::EXCL)
- Thread.critical = false
ios.close
$tempfiles << $filename << "#{$filename}.backup"
else
gen_thumbnails(orig, allow_background, dests, xmldirorelem, type + '-')
end
+ $video_thumbnail_directory_lock = Monitor.new
+
def gen_video_thumbnail(orig, colorswap, seektime)
if colorswap
#- ignored for the moment. is mplayer subject to blue faces problem?
#- it's not possible to specify a basename for the output jpeg file with mplayer (file will be named 00000001.jpg); as this can
#- be called from multiple threads, we must come up with a unique directory where to put the file
tmpfile = Tempfile.new("boohvideotmp")
- Thread.critical = true
- tmpdirname = tmpfile.path
- tmpfile.close!
- begin
- Dir.mkdir(tmpdirname)
- rescue Errno::EEXIST
- raise "Tmp directory #{tmpdirname} already exists"
- ensure
- Thread.critical = false
- end
+ $video_thumbnail_directory_lock.synchronize {
+ tmpdirname = tmpfile.path
+ tmpfile.close!
+ begin
+ Dir.mkdir(tmpdirname)
+ rescue Errno::EEXIST
+ raise "Tmp directory #{tmpdirname} already exists"
+ end
+ }
cmd = "mplayer '#{orig}' -nosound -vo jpeg:outdir='#{tmpdirname}' -frames 1 -ss #{seektime} -slave >/dev/null 2>/dev/null"
sys(cmd)
if ! File.exists?("#{tmpdirname}/00000001.jpg")
#################################################
def attribute( name, namespace=nil )
- prefix = nil
- prefix = namespaces.index(namespace) if namespace
- attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
+ prefix = nil
+ if namespaces.respond_to? :key
+ prefix = namespaces.key(namespace) if namespace
+ else
+ prefix = namespaces.index(namespace) if namespace
+ end
+ attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
end
# Evaluates to +true+ if this element has any attributes set, false