fix for pulseaudio
This commit is contained in:
parent
df371146b5
commit
45246fd39b
|
@ -88,6 +88,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,7 +210,7 @@ PulseAudioDspSource :: read ( void * buf,
|
||||||
unsigned int len ) throw ( Exception )
|
unsigned int len ) throw ( Exception )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = pa_simple_read(s, buf, len, &error);
|
ret = pa_simple_read(s, buf, len, &error);
|
||||||
if ( ret < 0) {
|
if ( ret < 0) {
|
||||||
throw Exception(__FILE__, __LINE__, ": pa_simple_read() failed: %s\n", pa_strerror(error));
|
throw Exception(__FILE__, __LINE__, ": pa_simple_read() failed: %s\n", pa_strerror(error));
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue