hornetseye-alsa 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/ext/alsaoutput.cc +24 -11
  3. metadata +3 -3
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
8
 
9
9
  PKG_NAME = 'hornetseye-alsa'
10
- PKG_VERSION = '0.1.1'
10
+ PKG_VERSION = '0.1.2'
11
11
  CXX = ENV[ 'CXX' ] || 'g++'
12
12
  STRIP = ENV[ 'STRIP' ] || 'strip'
13
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
data/ext/alsaoutput.cc CHANGED
@@ -83,10 +83,16 @@ void AlsaOutput::write( SequencePtr frame ) throw (Error)
83
83
  {
84
84
  ERRORMACRO( m_pcmHandle != NULL, Error, , "PCM device \"" << m_pcmName
85
85
  << "\" is not open. Did you call \"close\" before?" );
86
- int err = snd_pcm_writei( m_pcmHandle, (short int *)frame->data(),
87
- frame->size() / ( 2 * m_channels ) );
88
- ERRORMACRO( err >= 0, Error, , "Error writing audio frames to PCM device \""
89
- << m_pcmName << "\": " << snd_strerror( err ) );
86
+ int n = frame->size() / ( 2 * m_channels );
87
+ int err;
88
+ while ( ( err = snd_pcm_writei( m_pcmHandle, (short int *)frame->data(),
89
+ n ) ) < 0 ) {
90
+ err = snd_pcm_recover( m_pcmHandle, err, 1 );
91
+ ERRORMACRO( err >= 0, Error, , "Error writing audio frames to PCM device \""
92
+ << m_pcmName << "\": " << snd_strerror( err ) );
93
+ };
94
+ ERRORMACRO( n == err, Error, , "Only managed to write " << err << " of " << n
95
+ << " frames to PCM device \"" << m_pcmName << "\"" );
90
96
  }
91
97
 
92
98
  void AlsaOutput::drop(void) throw (Error)
@@ -122,10 +128,14 @@ int AlsaOutput::avail(void) throw (Error)
122
128
  {
123
129
  ERRORMACRO( m_pcmHandle != NULL, Error, , "PCM device \"" << m_pcmName
124
130
  << "\" is not open. Did you call \"close\" before?" );
125
- snd_pcm_sframes_t frames = snd_pcm_avail( m_pcmHandle );
126
- ERRORMACRO( frames >= 0, Error, , "Error querying number of available frames for "
131
+ snd_pcm_sframes_t frames;
132
+ int err = 0;
133
+ while ( ( frames = snd_pcm_avail( m_pcmHandle ) ) < 0 ) {
134
+ err = snd_pcm_recover( m_pcmHandle, frames, 1 );
135
+ ERRORMACRO( err >= 0, Error, , "Error querying number of available frames for "
127
136
  "update of PCM device \"" << m_pcmName << "\": "
128
- << snd_strerror( frames ) );
137
+ << snd_strerror( err ) );
138
+ };
129
139
  return frames;
130
140
  }
131
141
 
@@ -134,10 +144,13 @@ int AlsaOutput::delay(void) throw (Error)
134
144
  ERRORMACRO( m_pcmHandle != NULL, Error, , "PCM device \"" << m_pcmName
135
145
  << "\" is not open. Did you call \"close\" before?" );
136
146
  snd_pcm_sframes_t frames;
137
- int err = snd_pcm_delay( m_pcmHandle, &frames );
138
- ERRORMACRO( err >= 0, Error, , "Error querying number of available frames for "
139
- "update of PCM device \"" << m_pcmName << "\": "
140
- << snd_strerror( err ) );
147
+ int err;
148
+ while ( ( err = snd_pcm_delay( m_pcmHandle, &frames ) ) < 0 ) {
149
+ err = snd_pcm_recover( m_pcmHandle, err, 1 );
150
+ ERRORMACRO( err >= 0, Error, , "Error querying number of available frames for "
151
+ "update of PCM device \"" << m_pcmName << "\": "
152
+ << snd_strerror( err ) );
153
+ };
141
154
  return frames;
142
155
  }
143
156
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Wedekind
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-20 00:00:00 +01:00
17
+ date: 2010-10-21 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency