fix for pulseaudio

This commit is contained in:
rafael@riseup.net 2013-05-18 05:57:40 +00:00
parent df371146b5
commit 45246fd39b
2 changed files with 27 additions and 10 deletions

View File

@ -89,6 +89,8 @@ PulseAudioDspSource :: init ( const char * paSourceName ) throw ( Excep
ss.channels = getChannel(); ss.channels = getChannel();
ss.rate = getSampleRate(); ss.rate = getSampleRate();
running = 0;
//Supported for some bits per sample, both Big and Little endian //Supported for some bits per sample, both Big and Little endian
if (isBigEndian()) if (isBigEndian())
{ {
@ -153,6 +155,7 @@ PulseAudioDspSource :: strip ( void ) throw ( Exception )
bool bool
PulseAudioDspSource :: open ( void ) throw ( Exception ) PulseAudioDspSource :: open ( void ) throw ( Exception )
{ {
char client_name[255]; char client_name[255];
//to identify each darkice on pulseaudio server //to identify each darkice on pulseaudio server
@ -162,6 +165,8 @@ PulseAudioDspSource :: open ( void ) throw ( Exception )
throw Exception( __FILE__, __LINE__, ": pa_simple_new() failed: %s\n", pa_strerror(error)); throw Exception( __FILE__, __LINE__, ": pa_simple_new() failed: %s\n", pa_strerror(error));
} }
running = 1;
return true; return true;
} }
@ -173,17 +178,27 @@ bool
PulseAudioDspSource :: canRead ( unsigned int sec, PulseAudioDspSource :: canRead ( unsigned int sec,
unsigned int usec ) throw ( Exception ) unsigned int usec ) throw ( Exception )
{ {
//this seems to be a problem.
//to explore in the future /** Strange have to remove this, need to investigate... */
/* if ( !isOpen() ) { /* if ( !isOpen() ) {
return false; return false;
} }
*/ */
/* if (running == 0) {
* FIXME How to check if it can read? char client_name[255];
*/
return true; // bad!! //to identify each darkice on pulseaudio server
snprintf(client_name, 255, "darkice-%d", getpid());
if (!(s = pa_simple_new(NULL, client_name, PA_STREAM_RECORD, sourceName, "darkice record", &ss, NULL, NULL, &error))) {
throw Exception( __FILE__, __LINE__, ": pa_simple_new() failed: %s\n", pa_strerror(error));
}
running = 1;
}
return true;
} }
@ -215,6 +230,7 @@ PulseAudioDspSource :: close ( void ) throw ( Exception )
} }
pa_simple_free(s); pa_simple_free(s);
running = 0;
} }
#endif // HAVE_PULSEAUDIO_LIB #endif // HAVE_PULSEAUDIO_LIB

View File

@ -87,6 +87,7 @@ class PulseAudioDspSource : public AudioSource, public virtual Reporter
*/ */
pa_sample_spec ss; pa_sample_spec ss;
int running;
int error; int error;
protected: protected: