Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
frameworks_wilhelm
Commits
6cdc967a
Commit
6cdc967a
authored
11 years ago
by
Glenn Kasten
Browse files
Options
Download
Email Patches
Plain Diff
Audio recorder missing a callback protector
Bug: 14291968 Change-Id: I620d5e82f58e57e87097984a649b5c3a25c42963
parent
a62c3572
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
0 deletions
+33
-0
src/android/AudioRecorder_to_android.cpp
src/android/AudioRecorder_to_android.cpp
+24
-0
src/android/AudioRecorder_to_android.h
src/android/AudioRecorder_to_android.h
+2
-0
src/classes.h
src/classes.h
+1
-0
src/itf/IEngine.c
src/itf/IEngine.c
+2
-0
src/objects/CAudioRecorder.c
src/objects/CAudioRecorder.c
+4
-0
No files found.
src/android/AudioRecorder_to_android.cpp
View file @
6cdc967a
...
...
@@ -212,6 +212,12 @@ static void audioRecorder_callback(int event, void* user, void *info) {
//SL_LOGV("audioRecorder_callback(%d, %p, %p) entering", event, user, info);
CAudioRecorder
*
ar
=
(
CAudioRecorder
*
)
user
;
if
(
!
android
::
CallbackProtector
::
enterCbIfOk
(
ar
->
mCallbackProtector
))
{
// it is not safe to enter the callback (the track is about to go away)
return
;
}
void
*
callbackPContext
=
NULL
;
switch
(
event
)
{
...
...
@@ -289,6 +295,8 @@ static void audioRecorder_callback(int event, void* user, void *info) {
break
;
}
ar
->
mCallbackProtector
->
exitCb
();
}
...
...
@@ -312,6 +320,7 @@ SLresult android_audioRecorder_create(CAudioRecorder* ar) {
// microphone to simple buffer queue
ar
->
mAndroidObjType
=
AUDIORECORDER_FROM_MIC_TO_PCM_BUFFERQUEUE
;
ar
->
mAudioRecord
.
clear
();
ar
->
mCallbackProtector
=
new
android
::
CallbackProtector
();
ar
->
mRecordSource
=
AUDIO_SOURCE_DEFAULT
;
}
else
{
result
=
SL_RESULT_CONTENT_UNSUPPORTED
;
...
...
@@ -429,15 +438,30 @@ SLresult android_audioRecorder_realize(CAudioRecorder* ar, SLboolean async) {
}
//-----------------------------------------------------------------------------
/**
* Called with a lock on AudioRecorder, and blocks until safe to destroy
*/
void
android_audioRecorder_preDestroy
(
CAudioRecorder
*
ar
)
{
object_unlock_exclusive
(
&
ar
->
mObject
);
if
(
ar
->
mCallbackProtector
!=
0
)
{
ar
->
mCallbackProtector
->
requestCbExitAndWait
();
}
object_lock_exclusive
(
&
ar
->
mObject
);
}
//-----------------------------------------------------------------------------
void
android_audioRecorder_destroy
(
CAudioRecorder
*
ar
)
{
SL_LOGV
(
"android_audioRecorder_destroy(%p) entering"
,
ar
);
if
(
ar
->
mAudioRecord
!=
0
)
{
ar
->
mAudioRecord
->
stop
();
ar
->
mAudioRecord
.
clear
();
}
// explicit destructor
ar
->
mAudioRecord
.
~
sp
();
ar
->
mCallbackProtector
.
~
sp
();
#ifdef MONITOR_RECORDING
if
(
NULL
!=
gMonitorFp
)
{
...
...
This diff is collapsed.
Click to expand it.
src/android/AudioRecorder_to_android.h
View file @
6cdc967a
...
...
@@ -45,6 +45,8 @@ extern SLresult android_audioRecorder_getConfig(CAudioRecorder* ar, const SLchar
extern
SLresult
android_audioRecorder_realize
(
CAudioRecorder
*
ar
,
SLboolean
async
);
extern
void
android_audioRecorder_preDestroy
(
CAudioRecorder
*
ar
);
extern
void
android_audioRecorder_destroy
(
CAudioRecorder
*
ar
);
/**************************************************************************************************
...
...
This diff is collapsed.
Click to expand it.
src/classes.h
View file @
6cdc967a
...
...
@@ -150,6 +150,7 @@
// FIXME consolidate the next several variables into ARecorder class to avoid placement new
enum
AndroidObjectType
mAndroidObjType
;
android
::
sp
<
android
::
AudioRecord
>
mAudioRecord
;
android
::
sp
<
android
::
CallbackProtector
>
mCallbackProtector
;
audio_source_t
mRecordSource
;
#endif
}
/*CAudioRecorder*/
;
...
...
This diff is collapsed.
Click to expand it.
src/itf/IEngine.c
View file @
6cdc967a
...
...
@@ -453,6 +453,8 @@ static SLresult IEngine_CreateAudioRecorder(SLEngineItf self, SLObjectItf *pReco
// FIXME unnecessary once those fields are encapsulated in one class, rather
// than a structure
(
void
)
new
(
&
thiz
->
mAudioRecord
)
android
::
sp
<
android
::
AudioRecord
>
();
(
void
)
new
(
&
thiz
->
mCallbackProtector
)
android
::
sp
<
android
::
CallbackProtector
>
();
thiz
->
mRecordSource
=
AUDIO_SOURCE_DEFAULT
;
#endif
...
...
This diff is collapsed.
Click to expand it.
src/objects/CAudioRecorder.c
View file @
6cdc967a
...
...
@@ -59,5 +59,9 @@ void CAudioRecorder_Destroy(void *self)
predestroy_t
CAudioRecorder_PreDestroy
(
void
*
self
)
{
CAudioRecorder
*
thiz
=
(
CAudioRecorder
*
)
self
;
#ifdef ANDROID
android_audioRecorder_preDestroy
(
thiz
);
#endif
return
predestroy_ok
;
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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