everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
d4c384cf963b4c767cc95051b565fd688f6bc8a3 blob 1405 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 
# Copyright (C) 2014, all contributors <dtas-all@nongnu.org>
# License: GPLv3 or later <https://www.gnu.org/licenses/gpl-3.0.txt>
begin
  require 'sleepy_penguin'
rescue LoadError
end

# used to restart DTAS::Source::SplitFX processing in dtas-player
# if the YAML file is edited
module DTAS::Watchable
  class InotifyReadableIter < SleepyPenguin::Inotify
    def self.new
      super(:CLOEXEC)
    end

    FLAGS = CLOSE_WRITE | MOVED_TO

    def readable_iter
      or_call = false
      while event = take(true) # drain the buffer
        if (event.mask & FLAGS) != 0 && @watching[1] == event.name
          or_call = true
        end
      end
      if or_call && @on_readable
        @on_readable.call
        :delete
      else
        :wait_readable
      end
    end

    # we must watch the directory, since
    def watch_file(path, blk)
      @on_readable = blk
      @watching = File.split(File.expand_path(path))
      add_watch(@watching[0], FLAGS)
    end
  end

  def watch_begin(blk)
    @ino = InotifyReadableIter.new
    @ino.watch_file(@infile, blk)
    @ino
  end

  # Closing the inotify descriptor (instead of using inotify_rm_watch)
  # is cleaner because it avoids EINVAL on race conditions in case
  # a directory is deleted: https://lkml.org/lkml/2007/7/9/3
  def watch_end(srv)
    srv.wait_ctl(@ino, :delete)
    @ino = @ino.close
  end
end if defined?(SleepyPenguin::Inotify)
debug log:

solving d4c384c ...
found d4c384c in https://80x24.org/dtas.git

Code repositories for project(s) associated with this inbox:

	../../../dtas.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).