Permalink
Browse files

Managed to record audio

  • Loading branch information...
1 parent 868a3b1 commit 6dec7822c279ae9f7a57627b13e96cbd4063e7f5 @wedesoft committed Nov 15, 2010
Showing with 10 additions and 11 deletions.
  1. +1 −1 Rakefile
  2. +5 −6 ext/alsainput.cc
  3. +1 −1 ext/alsainput.hh
  4. +1 −1 ext/alsaoutput.hh
  5. +1 −1 lib/hornetseye-alsa/alsainput.rb
  6. +1 −1 lib/hornetseye-alsa/alsaoutput.rb
View
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
require 'rbconfig'
PKG_NAME = 'hornetseye-alsa'
-PKG_VERSION = '0.1.2'
+PKG_VERSION = '0.2.0'
CFG = RbConfig::CONFIG
CXX = ENV[ 'CXX' ] || 'g++'
RB_FILES = FileList[ 'lib/**/*.rb' ]
View
@@ -28,7 +28,7 @@ AlsaInput::AlsaInput( const string &pcmName, unsigned int rate,
snd_pcm_hw_params_t *hwParams;
snd_pcm_hw_params_alloca( &hwParams );
int err = snd_pcm_open( &m_pcmHandle, m_pcmName.c_str(), SND_PCM_STREAM_CAPTURE,
- SND_PCM_NONBLOCK );
+ 0 );
ERRORMACRO( err >= 0, Error, , "Error opening PCM device \"" << m_pcmName
<< "\": " << snd_strerror( err ) );
err = snd_pcm_hw_params_any( m_pcmHandle, hwParams );
@@ -82,17 +82,16 @@ SequencePtr AlsaInput::read( int samples ) throw (Error)
{
ERRORMACRO( m_pcmHandle != NULL, Error, , "PCM device \"" << m_pcmName
<< "\" is not open. Did you call \"close\" before?" );
- int n = samples * 2 * m_channels;
- SequencePtr frame( new Sequence( n ) );
+ SequencePtr frame( new Sequence( (int)( samples * 2 * m_channels ) ) );
int err;
while ( ( err = snd_pcm_readi( m_pcmHandle, (short int *)frame->data(),
- n ) ) < 0 ) {
+ samples ) ) < 0 ) {
err = snd_pcm_recover( m_pcmHandle, err, 1 );
ERRORMACRO( err >= 0, Error, , "Error reading audio frames from PCM device \""
<< m_pcmName << "\": " << snd_strerror( err ) );
};
- ERRORMACRO( n == err, Error, , "Only managed to read " << err << " of " << n
- << " frames from PCM device \"" << m_pcmName << "\"" );
+ ERRORMACRO( samples == err, Error, , "Only managed to read " << err << " of "
+ << samples << " frames from PCM device \"" << m_pcmName << "\"" );
return frame;
}
View
@@ -26,7 +26,7 @@ class AlsaInput
{
public:
AlsaInput( const std::string &pcmName = "default:0",
- unsigned int rate = 44100, unsigned int channels = 2,
+ unsigned int rate = 48000, unsigned int channels = 2,
int periods = 16, snd_pcm_uframes_t frames = 1024 ) throw (Error);
virtual ~AlsaInput(void);
void close(void);
View
@@ -26,7 +26,7 @@ class AlsaOutput
{
public:
AlsaOutput( const std::string &pcmName = "default:0",
- unsigned int rate = 44100, unsigned int channels = 2,
+ unsigned int rate = 48000, unsigned int channels = 2,
int periods = 16, snd_pcm_uframes_t frames = 1024 ) throw (Error);
virtual ~AlsaOutput(void);
void close(void);
@@ -23,7 +23,7 @@ class << self
alias_method :orig_new, :new
- def new( pcm_name = 'default:0', rate = 44100, channels = 2, periods = 16,
+ def new( pcm_name = 'default:0', rate = 48000, channels = 2, periods = 16,
frames = 1024 )
orig_new pcm_name, rate, channels, periods, frames
end
@@ -23,7 +23,7 @@ class << self
alias_method :orig_new, :new
- def new( pcm_name = 'default:0', rate = 44100, channels = 2, periods = 16,
+ def new( pcm_name = 'default:0', rate = 48000, channels = 2, periods = 16,
frames = 1024 )
orig_new pcm_name, rate, channels, periods, frames
end

0 comments on commit 6dec782

Please sign in to comment.