Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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-client-android
Commits
ed43b825
Commit
ed43b825
authored
4 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
tv conversation: avoid recorder crash
Change-Id: I30cecf052ea69807d6e5982499a3e7e1a00b6677
parent
335b9967
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ring-android/app/src/main/java/cx/ring/tv/conversation/TvConversationFragment.java
+39
-25
39 additions, 25 deletions
.../java/cx/ring/tv/conversation/TvConversationFragment.java
with
39 additions
and
25 deletions
ring-android/app/src/main/java/cx/ring/tv/conversation/TvConversationFragment.java
+
39
−
25
View file @
ed43b825
...
...
@@ -462,6 +462,12 @@ public class TvConversationFragment extends BaseSupportFragment<TvConversationPr
requireActivity
().
invalidateOptionsMenu
();
}
@Override
public
void
onStop
()
{
releaseRecorder
();
super
.
onStop
();
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
...
...
@@ -507,30 +513,33 @@ public class TvConversationFragment extends BaseSupportFragment<TvConversationPr
}
private
void
startRecording
()
{
try
{
fileName
=
AndroidFileUtils
.
createAudioFile
(
getContext
());
}
catch
(
IOException
e
)
{
if
(
recorder
!=
null
)
{
return
;
}
recorder
=
new
MediaRecorder
();
recorder
.
setAudioSource
(
MediaRecorder
.
AudioSource
.
MIC
);
recorder
.
setOutputFile
(
fileName
.
getAbsolutePath
());
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
recorder
.
setOutputFormat
(
MediaRecorder
.
OutputFormat
.
OGG
);
recorder
.
setAudioEncoder
(
MediaRecorder
.
AudioEncoder
.
OPUS
);
}
else
{
recorder
.
setOutputFormat
(
MediaRecorder
.
OutputFormat
.
MPEG_4
);
recorder
.
setAudioEncoder
(
MediaRecorder
.
AudioEncoder
.
AAC
);
}
try
{
fileName
=
AndroidFileUtils
.
createAudioFile
(
requireContext
());
recorder
=
new
MediaRecorder
();
recorder
.
setAudioSource
(
MediaRecorder
.
AudioSource
.
MIC
);
recorder
.
setOutputFile
(
fileName
.
getAbsolutePath
());
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
recorder
.
setOutputFormat
(
MediaRecorder
.
OutputFormat
.
OGG
);
recorder
.
setAudioEncoder
(
MediaRecorder
.
AudioEncoder
.
OPUS
);
}
else
{
recorder
.
setOutputFormat
(
MediaRecorder
.
OutputFormat
.
MPEG_4
);
recorder
.
setAudioEncoder
(
MediaRecorder
.
AudioEncoder
.
AAC
);
}
recorder
.
prepare
();
}
catch
(
IOException
e
)
{
Log
.
e
(
LOG_TAG
,
"prepare() failed"
);
recorder
.
start
();
}
catch
(
Exception
e
)
{
Toast
.
makeText
(
requireContext
(),
"Error starting recording: "
+
e
.
getLocalizedMessage
(),
Toast
.
LENGTH_LONG
).
show
();
if
(
recorder
!=
null
)
{
recorder
.
release
();
recorder
=
null
;
}
return
;
}
recorder
.
start
();
mAudioButton
.
setImageResource
(
R
.
drawable
.
lb_ic_stop
);
mTextAudio
.
setText
(
R
.
string
.
tv_audio_recording
);
Animation
anim
=
new
AlphaAnimation
(
0.0f
,
1.0f
);
...
...
@@ -541,18 +550,23 @@ public class TvConversationFragment extends BaseSupportFragment<TvConversationPr
mTextAudio
.
startAnimation
(
anim
);
}
private
void
stopRecording
()
{
if
(
recorder
==
null
)
{
return
;
private
void
releaseRecorder
()
{
if
(
recorder
!=
null
)
{
try
{
recorder
.
stop
();
}
catch
(
Exception
e
)
{
Log
.
w
(
TAG
,
"Exception stopping recorder"
);
}
recorder
.
release
();
recorder
=
null
;
}
recorder
.
stop
();
recorder
.
release
();
recorder
=
null
;
}
private
void
stopRecording
()
{
releaseRecorder
();
mAudioButton
.
setImageResource
(
R
.
drawable
.
baseline_mic_24
);
mTextAudio
.
setText
(
R
.
string
.
tv_send_audio
);
mTextAudio
.
clearAnimation
();
createAudioDialog
();
}
...
...
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