Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
5cf03fa3
Commit
5cf03fa3
authored
Feb 02, 2009
by
Emmanuel Milou
Browse files
Better handling of capture XRUNs
parent
d8aebd60
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/audio/alsalayer.cpp
View file @
5cf03fa3
...
...
@@ -124,16 +124,18 @@ AlsaLayer::stopStream(void)
AlsaLayer
::
canGetMic
()
{
int
avail
;
if
(
_CaptureHandle
)
{
avail
=
snd_pcm_avail_update
(
_CaptureHandle
);
//printf("%d\n", avail );
if
(
avail
>
0
)
return
avail
;
else
return
0
;
if
(
!
_CaptureHandle
)
return
0
;
avail
=
snd_pcm_avail_update
(
_CaptureHandle
);
if
(
avail
==
-
EPIPE
){
stop_capture
();
return
0
;
}
else
return
0
;
return
((
avail
<
0
)
?
0
:
avail
)
;
}
int
...
...
@@ -421,6 +423,7 @@ AlsaLayer::read( void* buffer, int toCopy)
if
(
snd_pcm_state
(
_CaptureHandle
)
==
SND_PCM_STATE_XRUN
)
{
_debug
(
"xrun caught before start
\n
"
);
prepareCaptureStream
();
startCaptureStream
();
}
...
...
@@ -432,7 +435,7 @@ AlsaLayer::read( void* buffer, int toCopy)
case
-
EPIPE
:
case
-
ESTRPIPE
:
case
-
EIO
:
//
_debugAlsa(" XRUN capture ignored (%s)\n", snd_strerror(samples));
_debugAlsa
(
" XRUN capture ignored (%s)
\n
"
,
snd_strerror
(
samples
));
handle_xrun_capture
();
samples
=
snd_pcm_readi
(
_CaptureHandle
,
buffer
,
frames
);
if
(
samples
<
0
)
samples
=
0
;
...
...
@@ -458,9 +461,9 @@ AlsaLayer::handle_xrun_capture( void )
int
res
=
snd_pcm_status
(
_CaptureHandle
,
status
);
if
(
res
<=
0
){
if
(
snd_pcm_status_get_state
(
status
)
==
SND_PCM_STATE_XRUN
){
stop
_c
apture
();
prepare
_c
apture
();
start
_c
apture
();
stop
C
apture
Stream
();
prepare
C
apture
Stream
();
start
C
apture
Stream
();
}
}
else
...
...
src/audio/alsalayer.h
View file @
5cf03fa3
...
...
@@ -139,6 +139,8 @@ class AlsaLayer : public AudioLayer {
void
audioCallback
(
void
);
bool
isCaptureActive
(
void
)
{
return
is_capture_running
();
}
private:
// Copy Constructor
...
...
src/audio/audiolayer.h
View file @
5cf03fa3
...
...
@@ -147,6 +147,7 @@ class AudioLayer {
*/
void
flushMic
();
virtual
bool
isCaptureActive
(
void
)
=
0
;
/**
* Write accessor to the error state
...
...
src/audio/pulselayer.h
View file @
5cf03fa3
...
...
@@ -76,6 +76,8 @@ class PulseLayer : public AudioLayer {
static
void
stream_state_callback
(
pa_stream
*
s
,
void
*
user_data
);
static
void
context_state_callback
(
pa_context
*
c
,
void
*
user_data
);
bool
isCaptureActive
(
void
){
return
true
;}
/**
* UNUSED in pulseaudio layer
*/
...
...
src/iaxvoiplink.cpp
View file @
5cf03fa3
...
...
@@ -333,16 +333,6 @@ IAXVoIPLink::sendRegister(AccountID id)
if
(
!
_regSession
)
{
_debug
(
"Error when generating new session for register"
);
}
else
{
// refresh
// last reg
//char host[_host.length()+1];
//strcpy(host, _host.c_str());
//char user[_user.length()+1];
//strcpy(user, _user.c_str());
//char pass[_pass.length()+1];
//strcpy(pass, _pass.c_str());
// iax_register doesn't use const char*
_debug
(
"IAX Sending registration to %s with user %s
\n
"
,
account
->
getHostname
().
c_str
()
,
account
->
getUsername
().
c_str
()
);
int
val
=
iax_register
(
_regSession
,
account
->
getHostname
().
data
(),
account
->
getUsername
().
data
(),
account
->
getPassword
().
data
(),
120
);
_debug
(
"Return value: %d
\n
"
,
val
);
...
...
@@ -647,10 +637,8 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
break
;
case
IAX_EVENT_VOICE
:
//_debug("Should have a decent value!!!!!! = %i\n" , call -> getAudioCodec());
//TODO Check this method
//if( !audiolayer -> is_capture_running())
//audiolayer->startStream();
if
(
!
audiolayer
->
isCaptureActive
())
audiolayer
->
startStream
();
iaxHandleVoiceEvent
(
event
,
call
);
break
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment