Hello,
I have also faced similar situations and created a Posix thread to read data
asynchronously from device. I have used posix mutex as synchronisation
primitive for a shared Ring buffer. Instead of writing to a file, I am
writing to a Ring buffer, from where my application is reading. The result
is that it shows the video frames with delay. I doubt it is because of
RunLoop which is running in my posix thread to read the data from my device
or its because of locks which is not time bounded?
thanks,
Sheetal.
----- Original Message -----
From: "Michael Krugman" <email@hidden>
To: <email@hidden>
Sent: Thursday, April 28, 2005 5:41 AM
Subject: Re: Guidance for doing USB reads on a separate thread
> Hi Juan:
>
> I have had similar problems in the past and the way I resolved it was
> to initialize the USB(open ports, configure device, etc.) from the main
> program and spawn a thread when I needed to read a USB pipe and write
> the data to a file. If you are calling a lot of methods from within
> the thread, make sure they don't overload the stack (I learned that one
> the hard way). This should free the system to enable the user to do
> other things. HTH.
>
> Mike Krugman
> On Apr 27, 2005, at 5:36 PM, Juan Pablo Pertierra wrote:
>
> > Hello,
> >
> > Right now my cocoa application can read from the USB port and do
> > exactly what i need it to do, except for the fact that while it is
> > reading from the USB port everything else freezes, waiting to return
> > from the RunLoop. I have based my USB code on the USB SImpleExample.
> > In the end I want it to read from the USB port and write what is read
> > to a file, while the user can still perform some simple functions on
> > the UI of the application.
> >
> > So, first of all, is there any way to add the ReadAsync notifications
> > to the cocoa application's RunLoop without explicitly having to call
> > CFRunLoop and wait for it to return? It seems that the cocoa
> > application must already have it's own runloop?
> >
> > If not, i'm thinking I need to just fire up another thread to do all
> > the USB reading/writing to disk. I know the basics of NSThread, but I
> > am unsure how to mix the USB code with a new thread. Should all the
> > USB initialization be done on the separate thread, or can I initialize
> > the USB(open ports, configure device, etc) on the main program and
> > then just spawn the thread when I need to read?
> >
> > I'm sure this has been done before, so generally how should I do this?
> >
> > Thanks,
> > Juan
> >
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > Usb mailing list (email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> > http://lists.apple.com/mailman/options/usb/email@hidden
> >
> > This email sent to email@hidden
> >
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Usb mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/usb/email@hidden
>
> This email sent to email@hidden
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden
This email sent to email@hidden