Skip to content

Commit

Permalink
Change ToxAVCall struct mutex to a more distinct name.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Apr 7, 2020
1 parent 97fc2f4 commit 5f1bf4d
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions toxav/toxav.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ typedef struct ToxAVCall_s {
/** Required for monitoring changes in states */
uint8_t previous_self_capabilities;

pthread_mutex_t mutex[1];
pthread_mutex_t toxav_call_mutex[1];

struct ToxAVCall_s *prev;
struct ToxAVCall_s *next;
Expand Down Expand Up @@ -246,7 +246,7 @@ void toxav_iterate(ToxAV *av)

for (; i; i = i->next) {
if (i->active) {
pthread_mutex_lock(i->mutex);
pthread_mutex_lock(i->toxav_call_mutex);
pthread_mutex_unlock(av->mutex);

ac_iterate(i->audio);
Expand All @@ -266,7 +266,7 @@ void toxav_iterate(ToxAV *av)

uint32_t fid = i->friend_number;

pthread_mutex_unlock(i->mutex);
pthread_mutex_unlock(i->toxav_call_mutex);
pthread_mutex_lock(av->mutex);

/* In case this call is popped from container stop iteration */
Expand Down Expand Up @@ -459,16 +459,16 @@ bool toxav_call_control(ToxAV *av, uint32_t friend_number, Toxav_Call_Control co

case TOXAV_CALL_CONTROL_CANCEL: {
/* Hang up */
pthread_mutex_lock(call->mutex);
pthread_mutex_lock(call->toxav_call_mutex);

if (msi_hangup(call->msi_call) != 0) {
rc = TOXAV_ERR_CALL_CONTROL_SYNC;
pthread_mutex_unlock(call->mutex);
pthread_mutex_unlock(call->toxav_call_mutex);
goto RETURN;
}

call->msi_call = nullptr;
pthread_mutex_unlock(call->mutex);
pthread_mutex_unlock(call->toxav_call_mutex);

/* No mather the case, terminate the call */
call_kill_transmission(call);
Expand Down Expand Up @@ -592,15 +592,15 @@ bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t audio_
/* Audio sending is turned off; notify peer */
call->audio_bit_rate = 0;
} else {
pthread_mutex_lock(call->mutex);
pthread_mutex_lock(call->toxav_call_mutex);

if (call->audio_bit_rate == 0) {
LOGGER_DEBUG(av->m->log, "Turned on audio sending");

/* The audio has been turned off before this */
if (msi_change_capabilities(call->msi_call, call->
msi_call->self_capabilities | MSI_CAP_S_AUDIO) != 0) {
pthread_mutex_unlock(call->mutex);
pthread_mutex_unlock(call->toxav_call_mutex);
pthread_mutex_unlock(av->mutex);
rc = TOXAV_ERR_BIT_RATE_SET_SYNC;
goto RETURN;
Expand All @@ -610,7 +610,7 @@ bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t audio_
}

call->audio_bit_rate = audio_bit_rate;
pthread_mutex_unlock(call->mutex);
pthread_mutex_unlock(call->toxav_call_mutex);
}

pthread_mutex_unlock(av->mutex);
Expand Down Expand Up @@ -664,15 +664,15 @@ bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t video_

call->video_bit_rate = 0;
} else {
pthread_mutex_lock(call->mutex);
pthread_mutex_lock(call->toxav_call_mutex);

if (call->video_bit_rate == 0) {
LOGGER_DEBUG(av->m->log, "Turned on video sending");

/* The video has been turned off before this */
if (msi_change_capabilities(call->msi_call, call->
msi_call->self_capabilities | MSI_CAP_S_VIDEO) != 0) {
pthread_mutex_unlock(call->mutex);
pthread_mutex_unlock(call->toxav_call_mutex);
pthread_mutex_unlock(av->mutex);
rc = TOXAV_ERR_BIT_RATE_SET_SYNC;
goto RETURN;
Expand All @@ -682,7 +682,7 @@ bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t video_
}

call->video_bit_rate = video_bit_rate;
pthread_mutex_unlock(call->mutex);
pthread_mutex_unlock(call->toxav_call_mutex);
}

pthread_mutex_unlock(av->mutex);
Expand Down Expand Up @@ -1173,7 +1173,7 @@ static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *er
call->av = av;
call->friend_number = friend_number;

if (create_recursive_mutex(call->mutex)) {
if (create_recursive_mutex(call->toxav_call_mutex)) {
free(call);
call = nullptr;
rc = TOXAV_ERR_CALL_MALLOC;
Expand All @@ -1184,7 +1184,7 @@ static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *er
av->calls = (ToxAVCall **)calloc(sizeof(ToxAVCall *), friend_number + 1);

if (av->calls == nullptr) {
pthread_mutex_destroy(call->mutex);
pthread_mutex_destroy(call->toxav_call_mutex);
free(call);
call = nullptr;
rc = TOXAV_ERR_CALL_MALLOC;
Expand All @@ -1197,7 +1197,7 @@ static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *er
ToxAVCall **tmp = (ToxAVCall **)realloc(av->calls, sizeof(ToxAVCall *) * (friend_number + 1));

if (tmp == nullptr) {
pthread_mutex_destroy(call->mutex);
pthread_mutex_destroy(call->toxav_call_mutex);
free(call);
call = nullptr;
rc = TOXAV_ERR_CALL_MALLOC;
Expand Down Expand Up @@ -1261,7 +1261,7 @@ static ToxAVCall *call_remove(ToxAVCall *call)
call->msi_call->av_call = nullptr;
}

pthread_mutex_destroy(call->mutex);
pthread_mutex_destroy(call->toxav_call_mutex);
free(call);

if (prev) {
Expand Down Expand Up @@ -1387,8 +1387,8 @@ static void call_kill_transmission(ToxAVCall *call)
pthread_mutex_unlock(call->mutex_audio);
pthread_mutex_lock(call->mutex_video);
pthread_mutex_unlock(call->mutex_video);
pthread_mutex_lock(call->mutex);
pthread_mutex_unlock(call->mutex);
pthread_mutex_lock(call->toxav_call_mutex);
pthread_mutex_unlock(call->toxav_call_mutex);

bwc_kill(call->bwc);

Expand Down

0 comments on commit 5f1bf4d

Please sign in to comment.