From: <do...@us...> - 2007-12-14 04:49:01
|
Revision: 1308 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1308&view=rev Author: dohpaz Date: 2007-12-13 20:49:05 -0800 (Thu, 13 Dec 2007) Log Message: ----------- Merge up to trunk r1307. Modified Paths: -------------- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c branches/team/elbunce/iaxclient/lib/video.c Modified: branches/team/elbunce/iaxclient/lib/iaxclient_lib.c =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-12-12 22:19:44 UTC (rev 1307) +++ branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-12-14 04:49:05 UTC (rev 1308) @@ -139,8 +139,13 @@ MUTEXLOCK(&iaxc_lock); } +int try_iaxc_lock() +{ + return MUTEXTRYLOCK(&iaxc_lock); +} + // Unlock the library and post any events that were queued in the meantime -static void put_iaxc_lock() +void put_iaxc_lock() { iaxc_event *prev, *event; Modified: branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h =================================================================== --- branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h 2007-12-12 22:19:44 UTC (rev 1307) +++ branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h 2007-12-14 04:49:05 UTC (rev 1308) @@ -17,6 +17,9 @@ #if defined(_MSC_VER) /* disable zero-sized array in struct/union warning */ #pragma warning(disable:4200) +#endif + +#ifdef WIN32 #define socklen_t int #endif Modified: branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c =================================================================== --- branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c 2007-12-12 22:19:44 UTC (rev 1307) +++ branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c 2007-12-14 04:49:05 UTC (rev 1308) @@ -908,7 +908,7 @@ struct sockaddr_in sin; socklen_t sinlen; int flags; - int bufsize = 256 * 1024; + int bufsize = 128 * 1024; if (netfd > -1) { @@ -998,10 +998,18 @@ if (setsockopt(netfd, SOL_SOCKET, SO_RCVBUF, (char *)&bufsize, sizeof(bufsize)) < 0) { - DEBU(G "Unable to set buffer size."); - IAXERROR "Unable to set buffer size."); + DEBU(G "Unable to set receive buffer size."); + IAXERROR "Unable to set receive buffer size."); } + /* set send buffer size too */ + if (setsockopt(netfd, SOL_SOCKET, SO_SNDBUF, (char *)&bufsize, + sizeof(bufsize)) < 0) + { + DEBU(G "Unable to set send buffer size."); + IAXERROR "Unable to set send buffer size."); + } + portno = ntohs(sin.sin_port); DEBU(G "Started on port %d\n", portno); } Modified: branches/team/elbunce/iaxclient/lib/video.c =================================================================== --- branches/team/elbunce/iaxclient/lib/video.c 2007-12-12 22:19:44 UTC (rev 1307) +++ branches/team/elbunce/iaxclient/lib/video.c 2007-12-14 04:49:05 UTC (rev 1308) @@ -124,6 +124,10 @@ extern int test_mode; extern struct iaxc_call * calls; +/* to prevent clearing a call while in capture callback */ +extern __inline int try_iaxc_lock(); +extern __inline void put_iaxc_lock(); + EXPORT unsigned int iaxc_get_video_prefs(void) { return vinfo.prefs; @@ -644,20 +648,35 @@ 0); /* timestamp (ms) */ } + /* Don't block waiting for this lock. If the main thread has the lock + * for the purpose of dumping the call, it may request that video + * capture stop - which would block until this callback returned. + */ + if ( try_iaxc_lock() ) + { + /* give it a second try */ + iaxc_millisleep(5); + if ( try_iaxc_lock() ) + { + fprintf(stderr, "skipping processing of a video frame\n"); + return 0; + } + } + if ( selected_call < 0 ) - return 0; + goto callback_done; call = &calls[selected_call]; if ( !call || !(call->state & (IAXC_CALL_STATE_COMPLETE | IAXC_CALL_STATE_OUTGOING)) ) { - return 0; + goto callback_done; } if ( call->vformat == 0 ) { - return -1; + goto callback_failed; } if ( !need_encode ) @@ -674,7 +693,7 @@ call->vencoder = 0; } - return 0; + goto callback_done; } else { @@ -693,7 +712,8 @@ fprintf(stderr, "ERROR: failed to create codec " "for format 0x%08x\n", call->vformat); - return -1; + + goto callback_failed; } fprintf(stderr, "created encoder codec %s\n", @@ -705,7 +725,7 @@ &slice_set) ) { fprintf(stderr, "failed to encode captured video\n"); - return -1; + goto callback_failed; } } @@ -724,7 +744,7 @@ if ( !call->session ) { fprintf(stderr, "not sending video to sessionless call\n"); - return -1; + goto callback_failed; } for ( i = 0; i < slice_set.num_slices; ++i ) @@ -752,7 +772,7 @@ fprintf(stderr, "failed sending slice call %d " "size %d\n", selected_call, slice_set.size[i]); - return -1; + goto callback_failed; } /* More statistics */ @@ -768,7 +788,13 @@ maybe_send_stats(call); +callback_done: + put_iaxc_lock(); return 0; + +callback_failed: + put_iaxc_lock(); + return -1; } static int prepare_for_capture() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |