Module: ALSA

Defined in:
lib/alsa.rb,
lib/alsa.rb,
lib/alsa/logger.rb,
lib/alsa/native.rb,
lib/alsa/version.rb

Defined Under Namespace

Modules: Native, PCM

Constant Summary collapse

VERSION =
"0.8"

Class Method Summary collapse

Class Method Details

.loggerObject



2
3
4
5
6
7
8
9
# File 'lib/alsa/logger.rb', line 2

def self.logger
  unless @logger
    @logger = Logger.new(STDERR)
    @logger.level = Logger::WARN
  end

  @logger
end

.logger=(logger) ⇒ Object



11
# File 'lib/alsa/logger.rb', line 11

def self.logger=(logger); @logger = logger; end

.try_to(message, &block) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/alsa.rb', line 25

def self.try_to(message, &block)
  logger.debug { message }
  if ALSA::Native::error_code?(response = yield)
    raise "cannot #{message} (#{ALSA::Native::strerror(response)})"
  else
    response
  end
end