Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
53dc39a0
Commit
53dc39a0
authored
15 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[#2333] Add debug message and test condition on starting playback and capture
parent
00a2fd07
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sflphone-common/src/audio/alsa/alsalayer.cpp
+67
-31
67 additions, 31 deletions
sflphone-common/src/audio/alsa/alsalayer.cpp
sflphone-common/src/audio/pulseaudio/pulselayer.cpp
+1
-11
1 addition, 11 deletions
sflphone-common/src/audio/pulseaudio/pulselayer.cpp
with
68 additions
and
42 deletions
sflphone-common/src/audio/alsa/alsalayer.cpp
+
67
−
31
View file @
53dc39a0
...
@@ -136,10 +136,15 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize,
...
@@ -136,10 +136,15 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize,
void
void
AlsaLayer
::
startStream
(
void
)
AlsaLayer
::
startStream
(
void
)
{
{
_debug
(
"
Start ALSA s
tream
s
\n
"
);
_debug
(
"
AlsaLayer:: startS
tream
\n
"
);
prepareCaptureStream
();
prepareCaptureStream
();
_debug
(
"------------------------------
\n
"
);
preparePlaybackStream
();
_debug
(
"------------------------------
\n
"
);
startCaptureStream
();
startCaptureStream
();
_debug
(
"------------------------------
\n
"
);
startPlaybackStream
();
startPlaybackStream
();
_debug
(
"------------------------------
\n
"
);
_urgentRingBuffer
.
flush
();
_urgentRingBuffer
.
flush
();
_mainBuffer
.
flush
();
_mainBuffer
.
flush
();
...
@@ -150,9 +155,9 @@ AlsaLayer::startStream (void)
...
@@ -150,9 +155,9 @@ AlsaLayer::startStream (void)
void
void
AlsaLayer
::
stopStream
(
void
)
AlsaLayer
::
stopStream
(
void
)
{
{
_debug
(
"AlsaLayer::stopS
tream :: Stop ALSA s
tream
s
\n
"
);
_debug
(
"AlsaLayer::
stopStream
\n
"
);
stopCaptureStream
();
stopCaptureStream
();
//
stopPlaybackStream ();
stopPlaybackStream
();
/* Flush the ring buffers */
/* Flush the ring buffers */
flushUrgent
();
flushUrgent
();
...
@@ -227,8 +232,10 @@ void AlsaLayer::stopCaptureStream (void)
...
@@ -227,8 +232,10 @@ void AlsaLayer::stopCaptureStream (void)
int
err
;
int
err
;
if
(
_CaptureHandle
)
{
if
(
_CaptureHandle
)
{
err
=
snd_pcm_drop
(
_CaptureHandle
);
_debug
(
"AlsaLayer:: stop Alsa capture
\n
"
);
if
((
err
=
snd_pcm_drop
(
_CaptureHandle
))
<
0
)
_debug
(
"AlsaLayer:: Error stopping ALSA capture: %s
\n
"
,
snd_strerror
(
err
));
else
stop_capture
();
stop_capture
();
}
}
...
@@ -236,31 +243,42 @@ void AlsaLayer::stopCaptureStream (void)
...
@@ -236,31 +243,42 @@ void AlsaLayer::stopCaptureStream (void)
void
AlsaLayer
::
closeCaptureStream
(
void
)
void
AlsaLayer
::
closeCaptureStream
(
void
)
{
{
_debug
(
"Close Capture Stream
\n
"
);
int
err
;
_debug
(
"AlsaLayer:: close ALSA capture
\n
"
);
if
(
is_capture_prepared
()
==
true
&&
is_capture_running
()
==
true
)
if
(
is_capture_prepared
()
==
true
&&
is_capture_running
()
==
true
)
stopCaptureStream
();
stopCaptureStream
();
if
(
is_capture_open
())
if
(
is_capture_open
())
{
snd_pcm_close
(
_CaptureHandle
);
if
((
err
=
snd_pcm_close
(
_CaptureHandle
))
<
0
)
_debug
(
"Error closing ALSA capture: %s
\n
"
,
snd_strerror
(
err
));
else
close_capture
();
close_capture
();
}
}
}
void
AlsaLayer
::
startCaptureStream
(
void
)
void
AlsaLayer
::
startCaptureStream
(
void
)
{
{
if
(
_CaptureHandle
)
{
int
err
;
_debug
(
"Start the capture
\n
"
);
snd_pcm_start
(
_CaptureHandle
);
if
(
_CaptureHandle
&&
!
is_capture_running
())
{
_debug
(
"AlsaLayer:: start ALSA capture
\n
"
);
if
((
err
=
snd_pcm_start
(
_CaptureHandle
))
<
0
)
_debug
(
"Error starting ALSA capture: %s
\n
"
,
snd_strerror
(
err
));
else
start_capture
();
start_capture
();
}
}
}
}
void
AlsaLayer
::
prepareCaptureStream
(
void
)
void
AlsaLayer
::
prepareCaptureStream
(
void
)
{
{
if
(
is_capture_open
())
{
int
err
;
if
(
snd_pcm_prepare
(
_CaptureHandle
)
<
0
)
_debug
(
""
);
if
(
is_capture_open
()
&&
!
is_capture_prepared
())
{
_debug
(
"AlsaLayer:: prepare ALSA capture
\n
"
);
if
((
err
=
snd_pcm_prepare
(
_CaptureHandle
))
<
0
)
_debug
(
"Error preparing ALSA capture: %s
\n
"
,
snd_strerror
(
err
));
else
else
prepare_capture
();
prepare_capture
();
}
}
...
@@ -268,8 +286,13 @@ void AlsaLayer::prepareCaptureStream (void)
...
@@ -268,8 +286,13 @@ void AlsaLayer::prepareCaptureStream (void)
void
AlsaLayer
::
stopPlaybackStream
(
void
)
void
AlsaLayer
::
stopPlaybackStream
(
void
)
{
{
if
(
_PlaybackHandle
)
{
int
err
;
snd_pcm_drop
(
_PlaybackHandle
);
if
(
_PlaybackHandle
&&
is_playback_running
())
{
_debug
(
"AlsaLayer:: stop ALSA playback
\n
"
);
if
((
err
=
snd_pcm_drop
(
_PlaybackHandle
))
<
0
)
_debug
(
"Error stopping ALSA playback: %s
\n
"
,
snd_strerror
(
err
));
else
stop_playback
();
stop_playback
();
}
}
}
}
...
@@ -277,28 +300,41 @@ void AlsaLayer::stopPlaybackStream (void)
...
@@ -277,28 +300,41 @@ void AlsaLayer::stopPlaybackStream (void)
void
AlsaLayer
::
closePlaybackStream
(
void
)
void
AlsaLayer
::
closePlaybackStream
(
void
)
{
{
int
err
;
if
(
is_playback_prepared
()
==
true
&&
is_playback_running
()
==
true
)
if
(
is_playback_prepared
()
==
true
&&
is_playback_running
()
==
true
)
stopPlaybackStream
();
stopPlaybackStream
();
if
(
is_playback_open
())
if
(
is_playback_open
())
{
snd_pcm_close
(
_PlaybackHandle
);
if
((
err
=
snd_pcm_close
(
_PlaybackHandle
))
<
0
)
_debug
(
"Error closing ALSA playback: %s
\n
"
,
snd_strerror
(
err
));
else
close_playback
();
close_playback
();
}
}
}
void
AlsaLayer
::
startPlaybackStream
(
void
)
void
AlsaLayer
::
startPlaybackStream
(
void
)
{
{
if
(
_PlaybackHandle
)
{
int
err
;
snd_pcm_start
(
_PlaybackHandle
);
if
(
_PlaybackHandle
&&
!
is_playback_running
())
{
_debug
(
"AlsaLayer:: start ALSA playback
\n
"
);
if
((
err
=
snd_pcm_start
(
_PlaybackHandle
))
<
0
)
_debug
(
"Error starting ALSA playback: %s
\n
"
,
snd_strerror
(
err
));
else
start_playback
();
start_playback
();
}
}
}
}
void
AlsaLayer
::
preparePlaybackStream
(
void
)
void
AlsaLayer
::
preparePlaybackStream
(
void
)
{
{
if
(
is_playback_open
())
{
int
err
;
if
(
snd_pcm_prepare
(
_PlaybackHandle
)
<
0
)
_debug
(
"Error preparing the device
\n
"
);
if
(
is_playback_open
()
&&
!
is_playback_prepared
())
{
_debug
(
"AlsaLayer:: prepare playback stream
\n
"
);
if
((
err
=
snd_pcm_prepare
(
_PlaybackHandle
))
<
0
)
_debug
(
"Error preparing the device: %s
\n
"
,
snd_strerror
(
err
));
else
prepare_playback
();
prepare_playback
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
sflphone-common/src/audio/pulseaudio/pulselayer.cpp
+
1
−
11
View file @
53dc39a0
...
@@ -25,7 +25,7 @@ int framesPerBuffer = 2048;
...
@@ -25,7 +25,7 @@ int framesPerBuffer = 2048;
static
void
playback_callback
(
pa_stream
*
s
,
size_t
bytes
,
void
*
userdata
)
static
void
playback_callback
(
pa_stream
*
s
,
size_t
bytes
,
void
*
userdata
)
{
{
_debug
(
"playback_callback
\n
"
);
//
_debug("playback_callback\n");
assert
(
s
&&
bytes
);
assert
(
s
&&
bytes
);
assert
(
bytes
>
0
);
assert
(
bytes
>
0
);
...
@@ -448,7 +448,6 @@ void PulseLayer::writeToSpeaker (void)
...
@@ -448,7 +448,6 @@ void PulseLayer::writeToSpeaker (void)
if
(
urgentAvailBytes
>
0
)
{
if
(
urgentAvailBytes
>
0
)
{
_debug
(
"Urgent Avail?????????????????????
\n
"
);
toGet
=
(
urgentAvailBytes
<
(
int
)
(
framesPerBuffer
*
sizeof
(
SFLDataFormat
)))
?
urgentAvailBytes
:
framesPerBuffer
*
sizeof
(
SFLDataFormat
);
toGet
=
(
urgentAvailBytes
<
(
int
)
(
framesPerBuffer
*
sizeof
(
SFLDataFormat
)))
?
urgentAvailBytes
:
framesPerBuffer
*
sizeof
(
SFLDataFormat
);
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
toGet
*
sizeof
(
SFLDataFormat
));
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
toGet
*
sizeof
(
SFLDataFormat
));
...
@@ -469,7 +468,6 @@ void PulseLayer::writeToSpeaker (void)
...
@@ -469,7 +468,6 @@ void PulseLayer::writeToSpeaker (void)
if
(
playback
->
getStreamState
()
==
PA_STREAM_READY
)
if
(
playback
->
getStreamState
()
==
PA_STREAM_READY
)
{
{
_debug
(
"Play Tone!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\n
"
);
toGet
=
framesPerBuffer
;
toGet
=
framesPerBuffer
;
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
toGet
*
sizeof
(
SFLDataFormat
));
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
toGet
*
sizeof
(
SFLDataFormat
));
...
@@ -485,8 +483,6 @@ void PulseLayer::writeToSpeaker (void)
...
@@ -485,8 +483,6 @@ void PulseLayer::writeToSpeaker (void)
if
(
playback
->
getStreamState
()
==
PA_STREAM_READY
)
if
(
playback
->
getStreamState
()
==
PA_STREAM_READY
)
{
{
_debug
(
"Play File Tone!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\n
"
);
toGet
=
framesPerBuffer
;
toGet
=
framesPerBuffer
;
toPlay
=
(
(
int
)
(
toGet
*
sizeof
(
SFLDataFormat
))
>
framesPerBuffer
)
?
framesPerBuffer
:
toGet
*
sizeof
(
SFLDataFormat
);
toPlay
=
(
(
int
)
(
toGet
*
sizeof
(
SFLDataFormat
))
>
framesPerBuffer
)
?
framesPerBuffer
:
toGet
*
sizeof
(
SFLDataFormat
);
_debug
(
"toPlay: %i
\n
"
,
toPlay
);
_debug
(
"toPlay: %i
\n
"
,
toPlay
);
...
@@ -494,11 +490,7 @@ void PulseLayer::writeToSpeaker (void)
...
@@ -494,11 +490,7 @@ void PulseLayer::writeToSpeaker (void)
file_tone
->
getNext
(
out
,
toPlay
/
2
,
100
);
file_tone
->
getNext
(
out
,
toPlay
/
2
,
100
);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
toPlay
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
toPlay
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
_debug
(
"ok
\n
"
);
pa_xfree
(
out
);
pa_xfree
(
out
);
_debug
(
"end of play file
\n
"
);
}
}
}
else
{
}
else
{
...
@@ -555,8 +547,6 @@ void PulseLayer::writeToSpeaker (void)
...
@@ -555,8 +547,6 @@ void PulseLayer::writeToSpeaker (void)
if
((
tone
==
0
)
&&
(
file_tone
==
0
))
{
if
((
tone
==
0
)
&&
(
file_tone
==
0
))
{
_debug
(
"send zeros......................
\n
"
);
bzero
(
out
,
maxNbBytesToGet
);
bzero
(
out
,
maxNbBytesToGet
);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
maxNbBytesToGet
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
maxNbBytesToGet
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment