I used SDL in my v4l program with SDL_mixer, SDL_timer, SDL_thread. I create a SDL thread to grab video stream from bt878 by v4l2 and bitblt, update the video to screen, a timer loop bitblt and update to screen 10 times a second too. sometime the screen froze but the mp3 music still play. The program cannot quit. Can somebody help me? thanks
SDL documents that its video functions are not (in general) thread
safe, and on some platforms must be called from the main thread. You
might want to look into a producer/consumer model using the SDL_Event
system to facilitate inter-thread communications.On Wed, Dec 23, 2009 at 3:20 PM, antzhi wrote:
Hi, all
I used SDL in my v4l program with SDL_mixer, SDL_timer, SDL_thread. I create
a SDL thread to grab video stream from bt878 by v4l2 and bitblt, update the
video to screen, a timer loop bitblt and update to screen 10 times a second
too. sometime the screen froze but the mp3 music still play. The program
cannot quit. Can somebody help me? thanks
Thank you, I add a mutex to fix this problem, all is ok
Brian Barrett wrote:> SDL documents that its video functions are not (in general) thread
safe, and on some platforms must be called from the main thread. You
might want to look into a producer/consumer model using the SDL_Event
system to facilitate inter-thread communications.
On Wed, Dec 23, 2009 at 3:20 PM, antzhi <@antzhi> wrote:
Hi, all
I used SDL in my v4l program with SDL_mixer, SDL_timer, SDL_thread. I create
a SDL thread to grab video stream from bt878 by v4l2 and bitblt, update the
video to screen, a timer loop bitblt and update to screen 10 times a second
too. sometime the screen froze but the mp3 music still play. The program
cannot quit. Can somebody help me? thanks
Strictly speaking, SDL does not support blitting to the screen from
different threads, regardless of the presence of mutexes. If you want your
application to be portable, you will need a more robust solution.On Wed, Dec 23, 2009 at 8:24 PM, antzhi wrote:
Thank you, I add a mutex to fix this problem, all is ok
yes, maybe i need a “blit” thread to do all blitting
Brian Barrett wrote:> Strictly speaking, SDL does not support blitting to the screen from different threads, regardless of the presence of mutexes. If you want your application to be portable, you will need a more robust solution.
On Wed, Dec 23, 2009 at 8:24 PM, antzhi <@antzhi (@antzhi)> wrote:
Thank you, I add a mutex to fix this problem, all is ok