ruby-alsa 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe ALSA::PCM::Native do
4
+
5
+ it "should provide the STREAM_CAPTURE constant" do
6
+ ALSA::PCM::Native::STREAM_CAPTURE.should == 1
7
+ end
8
+
9
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe ALSA::PCM::Playback do
4
+
5
+ let(:device) { "default" }
6
+
7
+ def pending_if_no_device
8
+ pending("requires a real alsa device") unless File.exists?("/proc/asound")
9
+ end
10
+
11
+ describe "#write_buffer" do
12
+
13
+ let(:playback) { ALSA::PCM::Playback.new }
14
+
15
+ it "should raise an error when playback isn't opened" do
16
+ lambda { playback.write_buffer(nil, 0) }.should raise_error
17
+ end
18
+
19
+ it "should play given samples (buffer and frame count)" do
20
+ pending_if_no_device
21
+
22
+ FFI::MemoryPointer.new(:char, 1024) do |buffer|
23
+ playback.open(device) do |playback|
24
+ playback.write_buffer buffer, 100
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe ALSA::PCM::Stream do
4
+
5
+ describe "native_constant" do
6
+
7
+ it "should be ALSA::PCM::Native::STREAM_CAPTURE for Capture" do
8
+ ALSA::PCM::Capture.new.native_constant.should == ALSA::PCM::Native::STREAM_CAPTURE
9
+ end
10
+
11
+ it "should be ALSA::PCM::Native::STREAM_PLAYBACK for Playback" do
12
+ ALSA::PCM::Playback.new.native_constant.should == ALSA::PCM::Native::STREAM_PLAYBACK
13
+ end
14
+
15
+ end
16
+
17
+ end
data/spec/alsa_spec.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe ALSA, "try_to" do
4
+
5
+ it "should log in debug the given message" do
6
+ ALSA.logger.should_receive(:debug)
7
+ ALSA::try_to("dummy") {}
8
+ end
9
+
10
+ it "should execute the given block and return its value" do
11
+ ALSA::try_to("dummy") { 0 }.should == 0
12
+ end
13
+
14
+ context "when block returns a negative value" do
15
+
16
+ it "should raise an error (with strerror of error code)" do
17
+ ALSA::Native.stub!(:strerror).and_return("error string")
18
+ lambda { ALSA::try_to("dummy") { -1 } }.should raise_error("cannot dummy (error string)")
19
+ end
20
+
21
+ end
22
+
23
+ end
data/spec/spec_helper.rb CHANGED
@@ -10,3 +10,5 @@ end
10
10
 
11
11
  $:.unshift(File.dirname(__FILE__) + '/../lib')
12
12
  require 'alsa'
13
+
14
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
@@ -0,0 +1,6 @@
1
+ require 'fileutils'
2
+ FileUtils.mkdir "log" unless File.exists?("log")
3
+
4
+ ALSA.logger = Logger.new("log/test.log").tap do |logger|
5
+ logger.level = Logger::DEBUG
6
+ end
@@ -0,0 +1 @@
1
+ task :buildbot => ["spec"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alban Peignier
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-24 00:00:00 +02:00
17
+ date: 2010-04-25 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -70,18 +70,42 @@ extra_rdoc_files:
70
70
  - History.txt
71
71
  - Manifest.txt
72
72
  files:
73
+ - .autotest
74
+ - COPYING
75
+ - COPYRIGHT
73
76
  - Gemfile
74
77
  - History.txt
75
78
  - Manifest.txt
76
79
  - README.rdoc
77
80
  - Rakefile
78
81
  - lib/alsa.rb
82
+ - lib/alsa/logger.rb
83
+ - lib/alsa/native.rb
84
+ - lib/alsa/pcm/capture.rb
85
+ - lib/alsa/pcm/hw_parameters.rb
86
+ - lib/alsa/pcm/native.rb
87
+ - lib/alsa/pcm/playback.rb
88
+ - lib/alsa/pcm/stream.rb
89
+ - log/test.log
90
+ - ruby-alsa.gemspec
79
91
  - script/console
80
92
  - script/destroy
81
93
  - script/generate
94
+ - script/play
95
+ - script/record
96
+ - spec.html
97
+ - spec/alsa/logger_spec.rb
98
+ - spec/alsa/native_spec.rb
99
+ - spec/alsa/pcm/capture_spec.rb
100
+ - spec/alsa/pcm/native_spec.rb
101
+ - spec/alsa/pcm/playback_spec.rb
102
+ - spec/alsa/pcm/stream_spec.rb
82
103
  - spec/alsa/pcm_spec.rb
104
+ - spec/alsa_spec.rb
83
105
  - spec/spec.opts
84
106
  - spec/spec_helper.rb
107
+ - spec/support/logger.rb
108
+ - tasks/buildbot.rake
85
109
  - tasks/rspec.rake
86
110
  has_rdoc: true
87
111
  homepage: http://projects.tryphon.eu/ruby-alsa