diff options
author | mannol <eniz_vukovic@hotmail.com> | 2014-07-05 17:36:12 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2014-07-05 17:36:12 +0200 |
commit | 9af7c335e7f198e6ac2ebe7554be2b30ffcbfbb4 (patch) | |
tree | 0a76a98410dc4221a618cfe5c305bfd25cd4c78f /toxav/toxav.c | |
parent | ebdc236d51b569b4817771fe0251ee86c1fee257 (diff) |
This might be causing problems
Diffstat (limited to 'toxav/toxav.c')
-rw-r--r-- | toxav/toxav.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c index 6ffef077..36053fd5 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -68,7 +68,7 @@ typedef struct _CallSpecific { | |||
68 | void *frame_buf; /* buffer for split video payloads */ | 68 | void *frame_buf; /* buffer for split video payloads */ |
69 | 69 | ||
70 | _Bool call_active; | 70 | _Bool call_active; |
71 | pthread_mutex_t mutex[1]; | 71 | pthread_mutex_t mutex; |
72 | } CallSpecific; | 72 | } CallSpecific; |
73 | 73 | ||
74 | 74 | ||
@@ -354,7 +354,7 @@ int toxav_prepare_transmission ( ToxAv *av, int32_t call_index, ToxAvCodecSettin | |||
354 | codec_settings->video_height, | 354 | codec_settings->video_height, |
355 | codec_settings->video_bitrate) )) { | 355 | codec_settings->video_bitrate) )) { |
356 | 356 | ||
357 | if ( pthread_mutex_init(call->mutex, NULL) != 0 ) goto error; | 357 | if ( pthread_mutex_init(&call->mutex, NULL) != 0 ) goto error; |
358 | 358 | ||
359 | call->call_active = 1; | 359 | call->call_active = 1; |
360 | 360 | ||
@@ -388,7 +388,7 @@ int toxav_kill_transmission ( ToxAv *av, int32_t call_index ) | |||
388 | 388 | ||
389 | CallSpecific *call = &av->calls[call_index]; | 389 | CallSpecific *call = &av->calls[call_index]; |
390 | 390 | ||
391 | pthread_mutex_lock(call->mutex); | 391 | pthread_mutex_lock(&call->mutex); |
392 | 392 | ||
393 | call->call_active = 0; | 393 | call->call_active = 0; |
394 | 394 | ||
@@ -397,8 +397,8 @@ int toxav_kill_transmission ( ToxAv *av, int32_t call_index ) | |||
397 | terminate_queue(call->j_buf); call->j_buf = NULL; | 397 | terminate_queue(call->j_buf); call->j_buf = NULL; |
398 | codec_terminate_session(call->cs); call->cs = NULL; | 398 | codec_terminate_session(call->cs); call->cs = NULL; |
399 | 399 | ||
400 | pthread_mutex_unlock(call->mutex); | 400 | pthread_mutex_unlock(&call->mutex); |
401 | pthread_mutex_destroy(call->mutex); | 401 | pthread_mutex_destroy(&call->mutex); |
402 | 402 | ||
403 | return ErrorNone; | 403 | return ErrorNone; |
404 | } | 404 | } |
@@ -534,7 +534,7 @@ inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **out | |||
534 | 534 | ||
535 | 535 | ||
536 | CallSpecific *call = &av->calls[call_index]; | 536 | CallSpecific *call = &av->calls[call_index]; |
537 | pthread_mutex_lock(call->mutex); | 537 | pthread_mutex_lock(&call->mutex); |
538 | 538 | ||
539 | uint8_t packet [RTP_PAYLOAD_SIZE]; | 539 | uint8_t packet [RTP_PAYLOAD_SIZE]; |
540 | int recved_size; | 540 | int recved_size; |
@@ -587,7 +587,7 @@ inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **out | |||
587 | 587 | ||
588 | *output = img; | 588 | *output = img; |
589 | 589 | ||
590 | pthread_mutex_unlock(call->mutex); | 590 | pthread_mutex_unlock(&call->mutex); |
591 | return ErrorNone; | 591 | return ErrorNone; |
592 | } | 592 | } |
593 | 593 | ||
@@ -608,9 +608,9 @@ inline__ int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *fr | |||
608 | } | 608 | } |
609 | 609 | ||
610 | 610 | ||
611 | pthread_mutex_lock(av->calls[call_index].mutex); | 611 | pthread_mutex_lock(&av->calls[call_index].mutex); |
612 | int rc = toxav_send_rtp_payload(av, call_index, TypeVideo, frame, frame_size); | 612 | int rc = toxav_send_rtp_payload(av, call_index, TypeVideo, frame, frame_size); |
613 | pthread_mutex_unlock(av->calls[call_index].mutex); | 613 | pthread_mutex_unlock(&av->calls[call_index].mutex); |
614 | 614 | ||
615 | return rc; | 615 | return rc; |
616 | } | 616 | } |
@@ -635,7 +635,7 @@ inline__ int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *d | |||
635 | 635 | ||
636 | 636 | ||
637 | CallSpecific *call = &av->calls[call_index]; | 637 | CallSpecific *call = &av->calls[call_index]; |
638 | pthread_mutex_lock(call->mutex); | 638 | pthread_mutex_lock(&call->mutex); |
639 | 639 | ||
640 | reconfigure_video_encoder_resolution(call->cs, input->d_w, input->d_h); | 640 | reconfigure_video_encoder_resolution(call->cs, input->d_w, input->d_h); |
641 | 641 | ||
@@ -643,7 +643,7 @@ inline__ int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *d | |||
643 | 643 | ||
644 | if ( rc != VPX_CODEC_OK) { | 644 | if ( rc != VPX_CODEC_OK) { |
645 | LOGGER_ERROR("Could not encode video frame: %s\n", vpx_codec_err_to_string(rc)); | 645 | LOGGER_ERROR("Could not encode video frame: %s\n", vpx_codec_err_to_string(rc)); |
646 | pthread_mutex_unlock(call->mutex); | 646 | pthread_mutex_unlock(&call->mutex); |
647 | return ErrorInternal; | 647 | return ErrorInternal; |
648 | } | 648 | } |
649 | 649 | ||
@@ -656,7 +656,7 @@ inline__ int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *d | |||
656 | while ( (pkt = vpx_codec_get_cx_data(&call->cs->v_encoder, &iter)) ) { | 656 | while ( (pkt = vpx_codec_get_cx_data(&call->cs->v_encoder, &iter)) ) { |
657 | if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) { | 657 | if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) { |
658 | if ( copied + pkt->data.frame.sz > dest_max ) { | 658 | if ( copied + pkt->data.frame.sz > dest_max ) { |
659 | pthread_mutex_unlock(call->mutex); | 659 | pthread_mutex_unlock(&call->mutex); |
660 | return ErrorPacketTooLarge; | 660 | return ErrorPacketTooLarge; |
661 | } | 661 | } |
662 | 662 | ||
@@ -665,7 +665,7 @@ inline__ int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *d | |||
665 | } | 665 | } |
666 | } | 666 | } |
667 | 667 | ||
668 | pthread_mutex_unlock(call->mutex); | 668 | pthread_mutex_unlock(&call->mutex); |
669 | return copied; | 669 | return copied; |
670 | } | 670 | } |
671 | 671 | ||
@@ -692,7 +692,7 @@ inline__ int toxav_recv_audio ( ToxAv *av, int32_t call_index, int frame_size, i | |||
692 | 692 | ||
693 | 693 | ||
694 | CallSpecific *call = &av->calls[call_index]; | 694 | CallSpecific *call = &av->calls[call_index]; |
695 | pthread_mutex_lock(call->mutex); | 695 | pthread_mutex_lock(&call->mutex); |
696 | 696 | ||
697 | uint8_t packet [RTP_PAYLOAD_SIZE]; | 697 | uint8_t packet [RTP_PAYLOAD_SIZE]; |
698 | 698 | ||
@@ -701,7 +701,7 @@ inline__ int toxav_recv_audio ( ToxAv *av, int32_t call_index, int frame_size, i | |||
701 | if ( recved_size == ErrorAudioPacketLost ) { | 701 | if ( recved_size == ErrorAudioPacketLost ) { |
702 | int dec_size = opus_decode(call->cs->audio_decoder, NULL, 0, dest, frame_size, 1); | 702 | int dec_size = opus_decode(call->cs->audio_decoder, NULL, 0, dest, frame_size, 1); |
703 | 703 | ||
704 | pthread_mutex_unlock(call->mutex); | 704 | pthread_mutex_unlock(&call->mutex); |
705 | 705 | ||
706 | if ( dec_size < 0 ) { | 706 | if ( dec_size < 0 ) { |
707 | LOGGER_WARNING("Decoding error: %s", opus_strerror(dec_size)); | 707 | LOGGER_WARNING("Decoding error: %s", opus_strerror(dec_size)); |
@@ -711,14 +711,14 @@ inline__ int toxav_recv_audio ( ToxAv *av, int32_t call_index, int frame_size, i | |||
711 | } else if ( recved_size ) { | 711 | } else if ( recved_size ) { |
712 | int dec_size = opus_decode(call->cs->audio_decoder, packet, recved_size, dest, frame_size, 0); | 712 | int dec_size = opus_decode(call->cs->audio_decoder, packet, recved_size, dest, frame_size, 0); |
713 | 713 | ||
714 | pthread_mutex_unlock(call->mutex); | 714 | pthread_mutex_unlock(&call->mutex); |
715 | 715 | ||
716 | if ( dec_size < 0 ) { | 716 | if ( dec_size < 0 ) { |
717 | LOGGER_WARNING("Decoding error: %s", opus_strerror(dec_size)); | 717 | LOGGER_WARNING("Decoding error: %s", opus_strerror(dec_size)); |
718 | return ErrorInternal; | 718 | return ErrorInternal; |
719 | } else return dec_size; | 719 | } else return dec_size; |
720 | } else { | 720 | } else { |
721 | pthread_mutex_unlock(call->mutex); | 721 | pthread_mutex_unlock(&call->mutex); |
722 | return 0; /* Nothing received */ | 722 | return 0; /* Nothing received */ |
723 | } | 723 | } |
724 | } | 724 | } |
@@ -742,9 +742,9 @@ inline__ int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *fr | |||
742 | } | 742 | } |
743 | 743 | ||
744 | 744 | ||
745 | pthread_mutex_lock(av->calls[call_index].mutex); | 745 | pthread_mutex_lock(&av->calls[call_index].mutex); |
746 | int rc = toxav_send_rtp_payload(av, call_index, TypeAudio, frame, frame_size); | 746 | int rc = toxav_send_rtp_payload(av, call_index, TypeAudio, frame, frame_size); |
747 | pthread_mutex_unlock(av->calls[call_index].mutex); | 747 | pthread_mutex_unlock(&av->calls[call_index].mutex); |
748 | 748 | ||
749 | return rc; | 749 | return rc; |
750 | } | 750 | } |
@@ -770,11 +770,11 @@ inline__ int toxav_prepare_audio_frame ( ToxAv *av, int32_t call_index, uint8_t | |||
770 | } | 770 | } |
771 | 771 | ||
772 | 772 | ||
773 | pthread_mutex_lock(av->calls[call_index].mutex); | 773 | pthread_mutex_lock(&av->calls[call_index].mutex); |
774 | 774 | ||
775 | int32_t rc = opus_encode(av->calls[call_index].cs->audio_encoder, frame, frame_size, dest, dest_max); | 775 | int32_t rc = opus_encode(av->calls[call_index].cs->audio_encoder, frame, frame_size, dest, dest_max); |
776 | 776 | ||
777 | pthread_mutex_unlock(av->calls[call_index].mutex); | 777 | pthread_mutex_unlock(&av->calls[call_index].mutex); |
778 | 778 | ||
779 | if (rc < 0) { | 779 | if (rc < 0) { |
780 | LOGGER_ERROR("Failed to encode payload: %s\n", opus_strerror(rc)); | 780 | LOGGER_ERROR("Failed to encode payload: %s\n", opus_strerror(rc)); |