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
303da322
Commit
303da322
authored
Jul 27, 2019
by
Adrien Béraud
Browse files
opensl: avoid blocking on stop
Change-Id: I9cb774da618e1a6e0a31e4915035a9faaaa4569b
parent
01810bbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/media/audio/opensl/opensllayer.cpp
View file @
303da322
...
...
@@ -88,18 +88,18 @@ OpenSLLayer::startStream()
startAudioPlayback
();
startAudioCapture
();
JAMI_WARN
(
"OpenSL audio layer started"
);
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
status_
=
Status
::
Started
;
}
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
status_
=
Status
::
Started
;
startedCv_
.
notify_all
();
});
startedCv_
.
notify_all
();
}
void
OpenSLLayer
::
stopStream
()
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex_
);
startedCv_
.
wait
(
lock
,
[
this
]
{
return
status_
!=
Status
::
Starting
;
});
if
(
startThread_
.
joinable
())
{
startThread_
.
join
();
}
...
...
@@ -126,6 +126,7 @@ OpenSLLayer::stopStream()
recBufQueue_
.
clear
();
bufs_
.
clear
();
dcblocker_
.
reset
();
startedCv_
.
notify_all
();
}
std
::
vector
<
sample_buf
>
...
...
@@ -246,7 +247,7 @@ OpenSLLayer::engineServiceRing(bool waiting) {
void
OpenSLLayer
::
engineServiceRec
(
bool
/* waiting */
)
{
playCv
.
notify_one
();
//
playCv.notify_one();
recCv
.
notify_one
();
return
;
}
...
...
@@ -334,10 +335,10 @@ OpenSLLayer::startAudioCapture()
std
::
unique_lock
<
std
::
mutex
>
lck
(
recMtx
);
while
(
recorder_
)
{
recCv
.
wait
(
lck
);
while
(
true
)
{
sample_buf
*
buf
;
if
(
!
recBufQueue_
.
front
(
&
buf
))
break
;
if
(
not
recorder_
)
break
;
sample_buf
*
buf
;
while
(
recBufQueue_
.
front
(
&
buf
))
{
recBufQueue_
.
pop
();
if
(
buf
->
size_
>
0
)
{
auto
nb_samples
=
buf
->
size_
/
hardwareFormat_
.
getBytesPerFrame
();
...
...
@@ -394,8 +395,8 @@ OpenSLLayer::stopAudioCapture()
recorder_
.
reset
();
}
}
recCv
.
notify_all
();
if
(
recThread
.
joinable
())
{
recCv
.
notify_all
();
recThread
.
join
();
}
...
...
src/preferences.cpp
View file @
303da322
...
...
@@ -425,7 +425,7 @@ AudioPreference::createAudioLayer()
}
return
nullptr
;
#endif
#endif //
__ANDROID__
#endif //
HAVE_OPENSL
JAMI_WARN
(
"No audio layer provided"
);
return
nullptr
;
...
...
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