class Knj::Amixer::Device
Public Class Methods
new(args)
click to toggle source
# File lib/knj/amixer.rb, line 35 def initialize(args) @args = args @mixers = {} end
Public Instance Methods
active?(args = {})
click to toggle source
Returns true if the device is active by looking in '/proc/asounc/card*/pcm*/sub*/status'.
# File lib/knj/amixer.rb, line 57 def active?(args = {}) proc_path = "/proc/asound/#{@args[:code]}" Dir.foreach(proc_path) do |file| next if file == "." or file == ".." or !file.match(/^pcm(\d+)[a-z]+$/) sub_path = "#{proc_path}/#{file}" info_path = "#{sub_path}/info" info_cont = File.read(info_path) if stream_match = info_cont.match(/stream: (.+?)\s+/) next if args.key?(:stream) and stream_match[1] != args[:stream] end Dir.foreach(sub_path) do |file_sub| next if file_sub == "." or file_sub == ".." or !file_sub.match(/^sub(\d+)$/) status_path = "#{sub_path}/#{file_sub}/status" cont = File.read(status_path) return true if cont.strip != "closed" end end return false end
amixer()
click to toggle source
# File lib/knj/amixer.rb, line 52 def amixer return @args[:amixer] end
code()
click to toggle source
# File lib/knj/amixer.rb, line 48 def code return @args[:code] end
id()
click to toggle source
# File lib/knj/amixer.rb, line 40 def id return @args[:id] end
mixers()
click to toggle source
Returns a hash of the various mixers.
# File lib/knj/amixer.rb, line 82 def mixers ret = %x[#{@args[:amixer].args[:amixer_bin]} -c #{@args[:id]} scontrols] ret.scan(/Simple mixer control '(.+)',0/) do |match| name = match[0] if !@mixers.key?(name) @mixers[name] = Knj::Amixer::Mixer.new( :amixer => @args[:amixer], :device => self, :name => name ) end end return @mixers end
name()
click to toggle source
# File lib/knj/amixer.rb, line 44 def name return @args[:name] end