Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apk
Commits
e5382430
Commit
e5382430
authored
Mar 23, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove main thread block before recording audio
parent
433f59c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
20 deletions
+43
-20
MediaController.java
...src/main/java/org/telegram/messenger/MediaController.java
+28
-19
ChatActivity.java
...sagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+15
-1
No files found.
TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
View file @
e5382430
...
...
@@ -75,6 +75,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public
final
static
int
audioProgressDidChanged
=
50001
;
public
final
static
int
audioDidReset
=
50002
;
public
final
static
int
recordProgressChanged
=
50003
;
public
final
static
int
recordStarted
=
50004
;
public
final
static
int
recordStartError
=
50005
;
private
HashMap
<
String
,
ArrayList
<
WeakReference
<
FileDownloadProgressListener
>>>
loadingFileObservers
=
new
HashMap
<
String
,
ArrayList
<
WeakReference
<
FileDownloadProgressListener
>>>();
private
HashMap
<
Integer
,
String
>
observersByTag
=
new
HashMap
<
Integer
,
String
>();
...
...
@@ -782,10 +784,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
return
isPaused
;
}
public
boolean
startRecording
(
final
long
dialog_id
)
{
final
Semaphore
semaphore
=
new
Semaphore
(
0
);
final
Boolean
[]
result
=
new
Boolean
[
1
];
public
void
startRecording
(
final
long
dialog_id
)
{
try
{
Vibrator
v
=
(
Vibrator
)
ApplicationLoader
.
applicationContext
.
getSystemService
(
Context
.
VIBRATOR_SERVICE
);
v
.
vibrate
(
20
);
...
...
@@ -797,8 +796,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
@Override
public
void
run
()
{
if
(
audioRecorder
!=
null
)
{
result
[
0
]
=
false
;
semaphore
.
release
();
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationCenter
.
getInstance
().
postNotificationName
(
recordStartError
);
}
});
return
;
}
...
...
@@ -813,8 +816,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
try
{
if
(
startRecord
(
recordingAudioFile
.
getAbsolutePath
())
==
0
)
{
result
[
0
]
=
false
;
semaphore
.
release
();
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationCenter
.
getInstance
().
postNotificationName
(
recordStartError
);
}
});
return
;
}
audioRecorder
=
new
AudioRecord
(
MediaRecorder
.
AudioSource
.
MIC
,
16000
,
AudioFormat
.
CHANNEL_IN_MONO
,
AudioFormat
.
ENCODING_PCM_16BIT
,
recordBufferSize
*
10
);
...
...
@@ -870,22 +877,24 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
}
result
[
0
]
=
false
;
semaphore
.
release
();
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationCenter
.
getInstance
().
postNotificationName
(
recordStartError
);
}
});
return
;
}
recordQueue
.
postRunnable
(
recordRunnable
);
result
[
0
]
=
true
;
semaphore
.
release
();
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationCenter
.
getInstance
().
postNotificationName
(
recordStarted
);
}
});
}
},
120
);
try
{
semaphore
.
acquire
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
return
result
[
0
];
},
100
);
}
private
void
stopRecordingInternal
(
final
boolean
send
)
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
View file @
e5382430
...
...
@@ -342,6 +342,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
NotificationCenter
.
getInstance
().
addObserver
(
this
,
MediaController
.
audioProgressDidChanged
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
MediaController
.
audioDidReset
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
MediaController
.
recordProgressChanged
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
MediaController
.
recordStarted
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
MediaController
.
recordStartError
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
997
);
loading
=
true
;
...
...
@@ -388,6 +390,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
NotificationCenter
.
getInstance
().
removeObserver
(
this
,
MediaController
.
audioProgressDidChanged
);
NotificationCenter
.
getInstance
().
removeObserver
(
this
,
MediaController
.
audioDidReset
);
NotificationCenter
.
getInstance
().
removeObserver
(
this
,
MediaController
.
recordProgressChanged
);
NotificationCenter
.
getInstance
().
removeObserver
(
this
,
MediaController
.
recordStarted
);
NotificationCenter
.
getInstance
().
removeObserver
(
this
,
MediaController
.
recordStartError
);
NotificationCenter
.
getInstance
().
removeObserver
(
this
,
997
);
if
(
sizeNotifierRelativeLayout
!=
null
)
{
sizeNotifierRelativeLayout
.
delegate
=
null
;
...
...
@@ -677,7 +681,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
public
boolean
onTouch
(
View
view
,
MotionEvent
motionEvent
)
{
if
(
motionEvent
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
startedDraggingX
=
-
1
;
recordingAudio
=
MediaController
.
getInstance
().
startRecording
(
dialog_id
);
MediaController
.
getInstance
().
startRecording
(
dialog_id
);
updateAudioRecordIntefrace
();
}
else
if
(
motionEvent
.
getAction
()
==
MotionEvent
.
ACTION_UP
||
motionEvent
.
getAction
()
==
MotionEvent
.
ACTION_CANCEL
)
{
startedDraggingX
=
-
1
;
...
...
@@ -2229,6 +2233,16 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
mActionMode
.
finish
();
mActionMode
=
null
;
}
}
else
if
(
id
==
MediaController
.
recordStartError
)
{
if
(
recordingAudio
)
{
recordingAudio
=
false
;
updateAudioRecordIntefrace
();
}
}
else
if
(
id
==
MediaController
.
recordStarted
)
{
if
(!
recordingAudio
)
{
recordingAudio
=
true
;
updateAudioRecordIntefrace
();
}
}
}
...
...
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