Check-in [e360dfbef1]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixed locking bug in tclwmf
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e360dfbef15f4e6c2fd93cc2c5dd4e41464c7e7f
User & Date: chw 2016-07-06 20:15:57.052
Context
2016-07-07
03:31
documentation added for zbar tcl interface check-in: 7561700b80 user: chw tags: trunk
2016-07-06
20:15
fixed locking bug in tclwmf check-in: e360dfbef1 user: chw tags: trunk
14:34
improved tclwmf w.r.t. frame size and documentation check-in: 298fb7cf26 user: chw tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to undroid/tclwmf/tclwmf.c.
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
};

/*
 *-------------------------------------------------------------------------
 *
 * ImageCallback --
 *
 *	Call as do-when-idle handler from the async event handler
 *	when a new image is available or image capture was stopped
 *	due to an error.
 *
 *-------------------------------------------------------------------------
 */

static void







|







525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
};

/*
 *-------------------------------------------------------------------------
 *
 * ImageCallback --
 *
 *	Called as do-when-idle handler from the (async) event handler
 *	when a new image is available or image capture was stopped
 *	due to an error.
 *
 *-------------------------------------------------------------------------
 */

static void
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606

607
608
609
610
611
612
613
}

/*
 *-------------------------------------------------------------------------
 *
 * SignalBuffer --
 *
 *	Async event handler called when an image became ready.
 *	Requests next frame and schedules do-when-idle handler
 *	for performing the Tcl callback established on open.
 *
 *-------------------------------------------------------------------------
 */

static int
#ifdef USE_ASYNC_HANDLER
SignalBuffer(ClientData clientData, Tcl_Interp *interp, int code)
#else
SignalBuffer(Tcl_Event *evPtr, int flags)
#endif
{
#ifdef USE_ASYNC_HANDLER
    WMFC *wmfc = (WMFC *) clientData;
#else
    WMFEVT *wevPtr = (WMFEVT *) evPtr;
    WMFC *wmfc = wevPtr->wmfc;
    int code = 1;
#endif
    HRESULT hr;
    int bufok = 0, dostop = 0, doread = 0;

    if (wmfc->srcReader == NULL) {
	return code;
    }
#ifndef USE_ASYNC_HANDLER
    if (wmfc->tid == NULL) {
	return code;
    }
#endif

    if (wmfc->counters[3] > 25) {
	/* stop after consecutive memory errors */
	dostop = 1;
    } else if (wmfc->frameQueued >= 0) {
	bufok = wmfc->frame[wmfc->frameQueued].ready > 0;
	if (bufok) {
	    if ((wmfc->frameReady >= 0) &&







|


















|












>







568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
}

/*
 *-------------------------------------------------------------------------
 *
 * SignalBuffer --
 *
 *	(Async) event handler called when an image became ready.
 *	Requests next frame and schedules do-when-idle handler
 *	for performing the Tcl callback established on open.
 *
 *-------------------------------------------------------------------------
 */

static int
#ifdef USE_ASYNC_HANDLER
SignalBuffer(ClientData clientData, Tcl_Interp *interp, int code)
#else
SignalBuffer(Tcl_Event *evPtr, int flags)
#endif
{
#ifdef USE_ASYNC_HANDLER
    WMFC *wmfc = (WMFC *) clientData;
#else
    WMFEVT *wevPtr = (WMFEVT *) evPtr;
    WMFC *wmfc = wevPtr->wmfc;
    int code = 1;	/* event was handled */
#endif
    HRESULT hr;
    int bufok = 0, dostop = 0, doread = 0;

    if (wmfc->srcReader == NULL) {
	return code;
    }
#ifndef USE_ASYNC_HANDLER
    if (wmfc->tid == NULL) {
	return code;
    }
#endif
    EnterCriticalSection(&wmfc->srcb.lock);
    if (wmfc->counters[3] > 25) {
	/* stop after consecutive memory errors */
	dostop = 1;
    } else if (wmfc->frameQueued >= 0) {
	bufok = wmfc->frame[wmfc->frameQueued].ready > 0;
	if (bufok) {
	    if ((wmfc->frameReady >= 0) &&
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
}

/*
 *-------------------------------------------------------------------------
 *
 * GetFormat --
 *
 *	Get information about the media format (width, height etc.)
 *	and try to switch MJPG source to YUY2 or NV12 format.
 *
 *-------------------------------------------------------------------------
 */

static int
GetFormat(WMFC *wmfc)
{







|
<







835
836
837
838
839
840
841
842

843
844
845
846
847
848
849
}

/*
 *-------------------------------------------------------------------------
 *
 * GetFormat --
 *
 *	Get information about the media format (width, height etc.).

 *
 *-------------------------------------------------------------------------
 */

static int
GetFormat(WMFC *wmfc)
{
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919

/*
 *-------------------------------------------------------------------------
 *
 * StartCapture --
 *
 *	Start capture of frames. A media source is created if not
 *	already available. The asynchronous event handler is established
 *	and the initial read of the first frame is performed. Later
 *	frames are requested by the asynchronous event handler.
 *
 *-------------------------------------------------------------------------
 */

static int
StartCapture(WMFC *wmfc)
{







|

|







903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919

/*
 *-------------------------------------------------------------------------
 *
 * StartCapture --
 *
 *	Start capture of frames. A media source is created if not
 *	already available. The (async) event handler is established
 *	and the initial read of the first frame is performed. Later
 *	frames are requested by the (async) event handler.
 *
 *-------------------------------------------------------------------------
 */

static int
StartCapture(WMFC *wmfc)
{
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
}

/*
 *-------------------------------------------------------------------------
 *
 * StopCapture --
 *
 *      Stop capture if running. The async event handler is removed and
 *	a pending idle call to ImageCallback is cancelled, too.
 *
 *-------------------------------------------------------------------------
 */

static int
StopCapture(WMFC *wmfc)







|







1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
}

/*
 *-------------------------------------------------------------------------
 *
 * StopCapture --
 *
 *      Stop capture if running. The (async) event handler is removed and
 *	a pending idle call to ImageCallback is cancelled, too.
 *
 *-------------------------------------------------------------------------
 */

static int
StopCapture(WMFC *wmfc)
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
}

/*
 *-------------------------------------------------------------------------
 *
 * WmfObjCmdDeleted --
 *
 *	Destructor of "wmf" Tcl command. Closes all device and
 *	releases all resources.
 *
 *-------------------------------------------------------------------------
 */

static void
WmfObjCmdDeleted(ClientData clientData)







|







1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
}

/*
 *-------------------------------------------------------------------------
 *
 * WmfObjCmdDeleted --
 *
 *	Destructor of "wmf" Tcl command. Closes all open devices and
 *	releases all resources.
 *
 *-------------------------------------------------------------------------
 */

static void
WmfObjCmdDeleted(ClientData clientData)