Permalink
Browse files

Added 'AlsaInput#drop'

  • Loading branch information...
1 parent 08a0d5e commit 5978429ec59a8e00dd5910252574459796448f61 @wedesoft committed Nov 16, 2012
Showing with 9 additions and 14 deletions.
  1. +1 −1 Rakefile
  2. +7 −12 ext/alsainput.cc
  3. +1 −1 ext/alsainput.hh
View
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
require 'rbconfig'
PKG_NAME = 'hornetseye-alsa'
-PKG_VERSION = '1.2.0'
+PKG_VERSION = '1.3.0'
CFG = RbConfig::CONFIG
CXX = ENV[ 'CXX' ] || 'g++'
RB_FILES = FileList[ 'lib/**/*.rb' ]
View
@@ -130,6 +130,10 @@ void AlsaInput::drop(void) throw (Error)
m_count = 0;
snd_pcm_drop(m_pcmHandle);
unlock();
+ if (m_threadInitialised) {
+ pthread_join(m_thread, NULL);
+ m_threadInitialised = false;
+ }
}
unsigned int AlsaInput::rate(void)
@@ -185,15 +189,6 @@ void AlsaInput::unlock(void)
pthread_mutex_unlock( &m_mutex );
}
-void AlsaInput::prepare(void) throw (Error)
-{
- ERRORMACRO( m_pcmHandle != NULL, Error, , "PCM device \"" << m_pcmName
- << "\" is not open. Did you call \"close\" before?" );
- int err = snd_pcm_prepare( m_pcmHandle );
- ERRORMACRO( err >= 0, Error, , "Error preparing PCM device \"" << m_pcmName
- << "\": " << snd_strerror( err ) );
-}
-
void AlsaInput::threadFunc(void)
{
bool quit = false;
@@ -247,7 +242,7 @@ VALUE AlsaInput::registerRubyClass( VALUE rbModule )
rb_define_method( cRubyClass, "rate", RUBY_METHOD_FUNC( wrapRate ), 0 );
rb_define_method( cRubyClass, "channels", RUBY_METHOD_FUNC( wrapChannels ), 0 );
rb_define_method( cRubyClass, "avail", RUBY_METHOD_FUNC( wrapAvail ), 0 );
- rb_define_method( cRubyClass, "prepare", RUBY_METHOD_FUNC( wrapPrepare ), 0 );
+ rb_define_method( cRubyClass, "drop", RUBY_METHOD_FUNC( wrapDrop ), 0 );
}
void AlsaInput::deleteRubyObject( void *ptr )
@@ -315,11 +310,11 @@ VALUE AlsaInput::wrapAvail( VALUE rbSelf )
return rbRetVal;
}
-VALUE AlsaInput::wrapPrepare( VALUE rbSelf )
+VALUE AlsaInput::wrapDrop( VALUE rbSelf )
{
try {
AlsaInputPtr *self; Data_Get_Struct( rbSelf, AlsaInputPtr, self );
- (*self)->prepare();
+ (*self)->drop();
} catch ( exception &e ) {
rb_raise( rb_eRuntimeError, "%s", e.what() );
};
View
@@ -47,7 +47,7 @@ public:
static VALUE wrapRate( VALUE rbSelf );
static VALUE wrapChannels( VALUE rbSelf );
static VALUE wrapAvail( VALUE rbSelf );
- static VALUE wrapPrepare( VALUE rbSelf );
+ static VALUE wrapDrop( VALUE rbSelf );
protected:
void readi(short int *data, int count);
void threadFunc(void);

0 comments on commit 5978429

Please sign in to comment.