hornetseye-alsa 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/ext/alsaoutput.cc +26 -4
- data/ext/alsaoutput.hh +2 -0
- metadata +3 -3
data/Rakefile
CHANGED
data/ext/alsaoutput.cc
CHANGED
@@ -92,7 +92,7 @@ void AlsaOutput::write(SequencePtr frame) throw (Error)
|
|
92
92
|
int n = frame->size() / (2 * m_channels);
|
93
93
|
lock();
|
94
94
|
if (!m_data.get()) {
|
95
|
-
if (m_threadInitialised)
|
95
|
+
if (m_threadInitialised) pthread_join(m_thread, NULL);
|
96
96
|
while(m_size < n) m_size = 2 * m_size;
|
97
97
|
m_data = boost::shared_array<short int>(new short int[m_size * m_channels]);
|
98
98
|
m_start = 0;
|
@@ -145,6 +145,17 @@ void AlsaOutput::drain(void) throw (Error)
|
|
145
145
|
snd_pcm_drain(m_pcmHandle);
|
146
146
|
}
|
147
147
|
|
148
|
+
void AlsaOutput::prepare(void) throw (Error)
|
149
|
+
{
|
150
|
+
ERRORMACRO( m_pcmHandle != NULL, Error, , "PCM device \"" << m_pcmName
|
151
|
+
<< "\" is not open. Did you call \"close\" before?" );
|
152
|
+
|
153
|
+
int err = snd_pcm_prepare( m_pcmHandle );
|
154
|
+
ERRORMACRO( err >= 0, Error, , "Error preparing PCM device \"" << m_pcmName
|
155
|
+
<< "\": " << snd_strerror( err ) );
|
156
|
+
// pthread_mutex_lock( &m_mutex );
|
157
|
+
}
|
158
|
+
|
148
159
|
unsigned int AlsaOutput::rate(void)
|
149
160
|
{
|
150
161
|
return m_rate;
|
@@ -215,6 +226,7 @@ void AlsaOutput::threadFunc(void)
|
|
215
226
|
{
|
216
227
|
bool quit = false;
|
217
228
|
while (!quit) {
|
229
|
+
snd_pcm_wait(m_pcmHandle, 1000);
|
218
230
|
try {
|
219
231
|
lock();
|
220
232
|
int n = m_periodSize;
|
@@ -225,15 +237,13 @@ void AlsaOutput::threadFunc(void)
|
|
225
237
|
if (m_start + n > m_size) {
|
226
238
|
writei(m_data.get() + m_start * m_channels, m_size - m_start);
|
227
239
|
writei(m_data.get(), m_start + n - m_size);
|
228
|
-
} else
|
240
|
+
} else
|
229
241
|
writei(m_data.get() + m_start * m_channels, n);
|
230
|
-
};
|
231
242
|
m_start += n;
|
232
243
|
m_count -= n;
|
233
244
|
} else
|
234
245
|
quit = true;
|
235
246
|
unlock();
|
236
|
-
snd_pcm_wait(m_pcmHandle, 1000);
|
237
247
|
} catch (Error &e) {
|
238
248
|
quit = true;
|
239
249
|
unlock();
|
@@ -255,6 +265,7 @@ VALUE AlsaOutput::registerRubyClass( VALUE rbModule )
|
|
255
265
|
rb_define_method( cRubyClass, "write", RUBY_METHOD_FUNC( wrapWrite ), 1 );
|
256
266
|
rb_define_method( cRubyClass, "drop", RUBY_METHOD_FUNC( wrapDrop ), 0 );
|
257
267
|
rb_define_method( cRubyClass, "drain", RUBY_METHOD_FUNC( wrapDrain ), 0 );
|
268
|
+
rb_define_method( cRubyClass, "prepare", RUBY_METHOD_FUNC( wrapPrepare ), 0 );
|
258
269
|
rb_define_method( cRubyClass, "rate", RUBY_METHOD_FUNC( wrapRate ), 0 );
|
259
270
|
rb_define_method( cRubyClass, "channels", RUBY_METHOD_FUNC( wrapChannels ), 0 );
|
260
271
|
rb_define_method( cRubyClass, "delay", RUBY_METHOD_FUNC( wrapDelay ), 0 );
|
@@ -321,6 +332,17 @@ VALUE AlsaOutput::wrapDrain( VALUE rbSelf )
|
|
321
332
|
return rbSelf;
|
322
333
|
}
|
323
334
|
|
335
|
+
VALUE AlsaOutput::wrapPrepare( VALUE rbSelf )
|
336
|
+
{
|
337
|
+
try {
|
338
|
+
AlsaOutputPtr *self; Data_Get_Struct( rbSelf, AlsaOutputPtr, self );
|
339
|
+
(*self)->prepare();
|
340
|
+
} catch ( exception &e ) {
|
341
|
+
rb_raise( rb_eRuntimeError, "%s", e.what() );
|
342
|
+
};
|
343
|
+
return rbSelf;
|
344
|
+
}
|
345
|
+
|
324
346
|
VALUE AlsaOutput::wrapRate( VALUE rbSelf )
|
325
347
|
{
|
326
348
|
AlsaOutputPtr *self; Data_Get_Struct( rbSelf, AlsaOutputPtr, self );
|
data/ext/alsaoutput.hh
CHANGED
@@ -32,6 +32,7 @@ public:
|
|
32
32
|
void write( SequencePtr sequence ) throw (Error);
|
33
33
|
void drop(void) throw (Error);
|
34
34
|
void drain(void) throw (Error);
|
35
|
+
void prepare(void) throw (Error);
|
35
36
|
unsigned int rate(void);
|
36
37
|
unsigned int channels(void);
|
37
38
|
int delay(void) throw (Error);
|
@@ -46,6 +47,7 @@ public:
|
|
46
47
|
static VALUE wrapWrite( VALUE rbSelf, VALUE rbSequence );
|
47
48
|
static VALUE wrapDrop( VALUE rbSelf );
|
48
49
|
static VALUE wrapDrain( VALUE rbSelf );
|
50
|
+
static VALUE wrapPrepare( VALUE rbSelf );
|
49
51
|
static VALUE wrapRate( VALUE rbSelf );
|
50
52
|
static VALUE wrapChannels( VALUE rbSelf );
|
51
53
|
static VALUE wrapDelay( VALUE rbSelf );
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hornetseye-alsa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jan Wedekind
|