mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Add synchronization protection for send_frame API functions
This commit is contained in:
parent
7972db5c41
commit
87828a1b42
@ -492,6 +492,10 @@ error for send_frame {
|
||||
* This client is currently not in a call with the friend.
|
||||
*/
|
||||
FRIEND_NOT_IN_CALL,
|
||||
/**
|
||||
* Synchronization error occurred.
|
||||
*/
|
||||
SYNC,
|
||||
/**
|
||||
* One of the frame parameters was invalid. E.g. the resolution may be too
|
||||
* small or too large, or the audio sampling rate may be unsupported.
|
||||
|
@ -649,7 +649,11 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc
|
||||
goto END;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(av->mutex);
|
||||
if (pthread_mutex_trylock(av->mutex) != 0) {
|
||||
rc = TOXAV_ERR_SEND_FRAME_SYNC;
|
||||
goto END;
|
||||
}
|
||||
|
||||
call = call_get(av, friend_number);
|
||||
|
||||
if (call == NULL || !call->active || call->msi_call->state != msi_CallActive) {
|
||||
@ -728,7 +732,11 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
|
||||
goto END;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(av->mutex);
|
||||
if (pthread_mutex_trylock(av->mutex) != 0) {
|
||||
rc = TOXAV_ERR_SEND_FRAME_SYNC;
|
||||
goto END;
|
||||
}
|
||||
|
||||
call = call_get(av, friend_number);
|
||||
|
||||
if (call == NULL || !call->active || call->msi_call->state != msi_CallActive) {
|
||||
|
@ -565,6 +565,10 @@ typedef enum TOXAV_ERR_SEND_FRAME {
|
||||
* This client is currently not in a call with the friend.
|
||||
*/
|
||||
TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL,
|
||||
/**
|
||||
* Synchronization error occurred.
|
||||
*/
|
||||
TOXAV_ERR_SEND_FRAME_SYNC,
|
||||
/**
|
||||
* One of the frame parameters was invalid. E.g. the resolution may be too
|
||||
* small or too large, or the audio sampling rate may be unsupported.
|
||||
|
Loading…
x
Reference in New Issue
Block a user