hallon-openal 1.0.0 → 1.0.1
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.
- data/CHANGELOG.md +3 -0
- data/ext/hallon/extconf.rb +1 -1
- data/ext/hallon/openal_ext.c +42 -24
- data/lib/hallon/openal/version.rb +1 -1
- metadata +23 -13
data/CHANGELOG.md
CHANGED
data/ext/hallon/extconf.rb
CHANGED
data/ext/hallon/openal_ext.c
CHANGED
@@ -103,8 +103,6 @@ static inline VALUE _oa_format_type(VALUE self)
|
|
103
103
|
|
104
104
|
static void oa_free(oa_struct_t *data_ptr)
|
105
105
|
{
|
106
|
-
int i;
|
107
|
-
|
108
106
|
// exit early if we have no data_ptr at all
|
109
107
|
if ( ! data_ptr) return;
|
110
108
|
|
@@ -139,7 +137,6 @@ static VALUE oa_allocate(VALUE klass)
|
|
139
137
|
static VALUE oa_initialize(VALUE self)
|
140
138
|
{
|
141
139
|
oa_struct_t *data_ptr;
|
142
|
-
ALenum error = AL_NO_ERROR;
|
143
140
|
|
144
141
|
// initialize openal
|
145
142
|
Data_Get_Struct(self, oa_struct_t, data_ptr);
|
@@ -174,6 +171,8 @@ static VALUE oa_initialize(VALUE self)
|
|
174
171
|
// generate our source
|
175
172
|
alGenSources(1, &data_ptr->source);
|
176
173
|
OA_CHECK_ERRORS("gen sources");
|
174
|
+
|
175
|
+
return self;
|
177
176
|
}
|
178
177
|
|
179
178
|
static VALUE oa_play(VALUE self)
|
@@ -220,29 +219,48 @@ static ALuint find_empty_buffer(VALUE self)
|
|
220
219
|
ALuint source = data_ptr->source;
|
221
220
|
ALuint *buffers = data_ptr->buffers;
|
222
221
|
|
223
|
-
|
224
|
-
|
225
|
-
|
222
|
+
struct timeval poll_time;
|
223
|
+
poll_time.tv_sec = 0;
|
224
|
+
poll_time.tv_usec = 100; /* 0.000100 sec */
|
226
225
|
|
227
|
-
|
228
|
-
|
229
|
-
empty_buffer = buffers[num_queued];
|
230
|
-
}
|
231
|
-
else
|
226
|
+
/* infinite loop until we break */
|
227
|
+
for (;;rb_thread_wait_for(poll_time))
|
232
228
|
{
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
poll_time.tv_usec = 100; /* 0.000100 sec */
|
229
|
+
ALint num_queued = 0;
|
230
|
+
alGetSourcei(source, AL_BUFFERS_QUEUED, &num_queued);
|
231
|
+
OA_CHECK_ERRORS("AL_BUFFERS_QUEUED");
|
237
232
|
|
238
|
-
|
233
|
+
if (num_queued < NUM_BUFFERS)
|
239
234
|
{
|
240
|
-
|
241
|
-
|
235
|
+
empty_buffer = buffers[num_queued];
|
236
|
+
DEBUG("Q/B: %d/%d\n", num_queued, NUM_BUFFERS);
|
237
|
+
break;
|
238
|
+
}
|
239
|
+
else
|
240
|
+
{
|
241
|
+
ALint state;
|
242
|
+
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
243
|
+
OA_CHECK_ERRORS("AL_SOURCE_STATE");
|
244
|
+
|
245
|
+
/* there is an openal bug that appears to assume
|
246
|
+
* all queued buffers are processed when the source
|
247
|
+
* is not playing */
|
248
|
+
if (state == AL_PLAYING)
|
249
|
+
{
|
250
|
+
int processed = 0;
|
251
|
+
|
252
|
+
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
253
|
+
OA_CHECK_ERRORS("AL_BUFFERS_PROCESSED");
|
254
|
+
|
255
|
+
if (processed > 0)
|
256
|
+
{
|
257
|
+
DEBUG("processed: %d\n", processed);
|
258
|
+
alSourceUnqueueBuffers(source, 1, &empty_buffer);
|
259
|
+
OA_CHECK_ERRORS("alSourceUnqueueBuffers");
|
260
|
+
break;
|
261
|
+
}
|
262
|
+
}
|
242
263
|
}
|
243
|
-
|
244
|
-
alSourceUnqueueBuffers(source, 1, &empty_buffer);
|
245
|
-
OA_CHECK_ERRORS("alSourceUnqueueBuffers");
|
246
264
|
}
|
247
265
|
|
248
266
|
return empty_buffer;
|
@@ -301,6 +319,9 @@ static VALUE oa_stream(VALUE self)
|
|
301
319
|
|
302
320
|
for (;;)
|
303
321
|
{
|
322
|
+
ALuint buffer = find_empty_buffer(self);
|
323
|
+
OA_CHECK_ERRORS("find_empty_buffer");
|
324
|
+
|
304
325
|
// pull some audio out of hallon
|
305
326
|
VALUE frames = rb_yield(INT2FIX(sample_ary_frames));
|
306
327
|
|
@@ -311,9 +332,6 @@ static VALUE oa_stream(VALUE self)
|
|
311
332
|
break;
|
312
333
|
}
|
313
334
|
|
314
|
-
ALuint buffer = find_empty_buffer(self);
|
315
|
-
OA_CHECK_ERRORS("find_empty_buffer");
|
316
|
-
|
317
335
|
// convert the frames from ruby to C
|
318
336
|
int num_current_samples = ((int) RARRAY_LEN(frames)) * f_channels;
|
319
337
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hallon-openal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,30 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hallon
|
16
|
-
|
17
|
-
|
16
|
+
prerelease: false
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0.13'
|
22
|
+
none: false
|
22
23
|
type: :runtime
|
23
|
-
|
24
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0.13'
|
29
|
+
none: false
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rspec
|
27
|
-
|
28
|
-
|
32
|
+
prerelease: false
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
31
36
|
- !ruby/object:Gem::Version
|
32
37
|
version: '2.7'
|
38
|
+
none: false
|
33
39
|
type: :development
|
34
|
-
|
35
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '2.7'
|
45
|
+
none: false
|
36
46
|
description:
|
37
47
|
email:
|
38
48
|
- kim@burgestrand.se
|
@@ -63,20 +73,20 @@ require_paths:
|
|
63
73
|
- lib
|
64
74
|
- ext
|
65
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
76
|
requirements:
|
68
77
|
- - ! '>='
|
69
78
|
- !ruby/object:Gem::Version
|
70
79
|
version: '0'
|
71
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
80
|
none: false
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
82
|
requirements:
|
74
83
|
- - ! '>='
|
75
84
|
- !ruby/object:Gem::Version
|
76
85
|
version: '0'
|
86
|
+
none: false
|
77
87
|
requirements: []
|
78
88
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.8.
|
89
|
+
rubygems_version: 1.8.24
|
80
90
|
signing_key:
|
81
91
|
specification_version: 3
|
82
92
|
summary: ! 'OpenAL audio drivers for Hallon: http://rubygems.org/gems/hallon'
|