lib/oboe/config.rb in oboe-2.1.4 vs lib/oboe/config.rb in oboe-2.2.0
- old
+ new
@@ -41,10 +41,13 @@
# Setup an empty host blacklist (see: Oboe::API::Util.blacklisted?)
@@config[:blacklist] = []
update!(data)
+
+ # For Initialization, mark this as the default SampleRate
+ @@config[:sample_source] = 2 # OBOE_SAMPLE_RATE_SOURCE_DEFAULT
end
def self.update!(data)
data.each do |key, value|
self[key] = value
@@ -55,9 +58,38 @@
@@config[key.to_sym]
end
def self.[]=(key, value)
@@config[key.to_sym] = value
+
+ if key == :sample_rate
+ # When setting SampleRate, note that it's been manually set
+ # OBOE_SAMPLE_RATE_SOURCE_FILE == 1
+ @@config[:sample_source] = 1
+
+ # Validate :sample_rate value
+ unless value.between?(1, 1e6)
+ raise "oboe :sample_rate must be between 1 and 1000000 (1m)"
+ end
+
+ # Update liboboe with the new SampleRate value
+ Oboe::Context.setDefaultSampleRate(value)
+ end
+
+ # Update liboboe if updating :tracing_mode
+ if key == :tracing_mode
+ case value.downcase
+ when 'never'
+ # OBOE_TRACE_NEVER
+ Oboe::Context.setTracingMode(0)
+ when 'always'
+ # OBOE_TRACE_ALWAYS
+ Oboe::Context.setTracingMode(1)
+ else
+ # OBOE_TRACE_THROUGH
+ Oboe::Context.setTracingMode(2)
+ end
+ end
end
def self.method_missing(sym, *args)
if sym.to_s =~ /(.+)=$/
self[$1] = args.first