Threaded Video-Capture fails with SDL on X (Vol 12, Issue 32)

Dear All,

I tried the valgrid and could identify few coding mistakes.
Many thanks for your reply and help. It 's a worthy one.

But when I tried to execute a Threaded Multi capture application,
the apps hangs / Not respond and Gives Errors like,
Xlib: unexpected async reply (sequence 0x2fb)!
after executing for a few (5 or 20) seconds!!!
So In continuation to the following message2, I have few basic doubts now.
Please get any help if possible…

1). Is it possible to Implement a Video Display of multi channels, if the
capture function is SDL_Thread ?
I have read that threading is Not possible with SDL on X Window s/m, as the
X do not support Threaded in put.

  1. Does this disallow, to display multiple video in same window (SDL
    screen) with the help of multiple
    overlay rectangles, where the 16 channel refresh function is Done with 16
    thread.

  2. Is it possible to get a Threaded alplication for Multi Video Capture.

PLs Help./

Regards,
Ren.>


Message: 2
Date: Wed, 26 Dec 2007 12:42:24 +0530
From: “renjith kumar” <@renjith_kumar>
Subject: Re: [SDL] SDL Digest, Vol 12, Issue 32
To: sdl at lists.libsdl.org
Message-ID:

Content-Type: text/plain; charset=“iso-8859-1”

Hi ,

I am new to sdl and I wish to work more with SDL
I have a requirement of Displaying multiple video Streams (16 nos)
in to a single Window with the overlay Support.
I am thinking in this way, because I believe creating multiple window
(Each window for each Video In Channels ) can not be supported with SDL,
As I failed.

I am creating 16 Threads in the main file , each for Each channel capture.
each thread will create its own overlay and display into diff. rectangle
in
SDL Surface.

But this thread Creation end in Fail by giving X lib errors, I need
threading as the performance
w/o threading is Very Poor.
Please Share your ideas.
I get X lib errors as follows…

Open board… done.
Initialize board… done.
Set group slice controls… done.
press ESC to Quit.
Create capturing threads… 0 done.
Start capture video transfer…
0 *** glibc detected *** ./sample: free(): invalid pointer: 0xbf8242b8 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7c377cd]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7c3ae30]
/usr/lib/libSDL-1.2.so.0(SDL_WaitThread+0x44)[0xb7e29e44]
./sample[0x8049b02]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xdc)[0xb7be5ebc]
./sample[0x8048fc1]
======= Memory map: ========
08048000-0804c000 r-xp 00000000 08:06 979674
/opt/Hicap/hicap_sdk/sample
0804c000-0804d000 rw-p 00003000 08:06 979674
/opt/Hicap/hicap_sdk/sample
0804d000-08e15000 rw-p 0804d000 00:00 0 [heap]
b54fb000-b54fc000 —p b54fb000 00:00 0
b54fc000-b5cfc000 rw-p b54fc000 00:00 0
b5cfc000-b5cfd000 —p b5cfc000 00:00 0
b5cfd000-b64fd000 rw-p b5cfd000 00:00 0
b65ca000-b65d5000 r-xp 00000000 08:06 1697344 /lib/libgcc_s.so.1
b65d5000-b65d6000 rw-p 0000a000 08:06 1697344 /lib/libgcc_s.so.1
b65d6000-b65d7000 —p b65d6000 00:00 0
b65d7000-b6dd7000 rw-p b65d7000 00:00 0
b6dd7000-b6dec000 rw-s 00000000 00:08 3244051 /SYSV00000000 (deleted)
b6dec000-b6df0000 r-xp 00000000 08:06 1437451
/usr/lib/libXfixes.so.3.1.0
b6df0000-b6df1000 rw-p 00003000 08:06 1437451
/usr/lib/libXfixes.so.3.1.0
b6df1000-b6df9000 r-xp 00000000 08:06 1437441
/usr/lib/libXcursor.so.1.0.2
b6df9000-b6dfa000 rw-p 00007000 08:06 1437441
/usr/lib/libXcursor.so.1.0.2
b6dfa000-b6dff000 r-xp 00000000 08:06 1437469
/usr/lib/libXrandr.so.2.1.0
b6dff000-b6e00000 rw-p 00005000 08:06 1437469
/usr/lib/libXrandr.so.2.1.0
b6e00000-b6e07000 r-xp 00000000 08:06 1437471
/usr/lib/libXrender.so.1.3.0
b6e07000-b6e08000 rw-p 00006000 08:06 1437471
/usr/lib/libXrender.so.1.3.0
b6e08000-b7a68000 rw-s 00000000 00:0d 13502 /dev/video0
b7a68000-b7a6a000 rw-p b7a68000 00:00 0
b7a6a000-b7a6e000 r-xp 00000000 08:06 1437445
/usr/lib/libXdmcp.so.6.0.0
b7a6e000-b7a6f000 rw-p 00003000 08:06 1437445
/usr/lib/libXdmcp.so.6.0.0
b7a6f000-b7a71000 r-xp 00000000 08:06 1437434 /usr/lib/libXau.so.6.0.0
b7a71000-b7a72000 rw-p 00001000 08:06 1437434 /usr/lib/libXau.so.6.0.0
b7a72000-b7a73000 rw-p b7a72000 00:00 0
b7a73000-b7a81000 r-xp 00000000 08:06 1437584 /usr/lib/libdirect-
0.9.so.25.0.0
b7a81000-b7a82000 rw-p 0000e000 08:06 1437584 /usr/lib/libdirect-
0.9.so.25.0.0
b7a82000-b7a87000 r-xp 00000000 08:06 1437652 /usr/lib/libfusion-
0.9.so.25.0.0
b7a87000-b7a88000 rw-p 00004000 08:06 1437652 /usr/lib/libfusion-
0.9.so.25.0.0
b7a88000-b7add000 r-xp 00000000 08:06 1437586 /usr/lib/libdirectfb-
0.9.so.25.0.0
b7add000-b7adf000 rw-p 00055000 08:06 1437586 /usr/lib/libdirectfb-
0.9.so.25.0.0
b7adf000-b7ae1000 r-xp 00000000 08:06 1731208 /lib/tls/i686/cmov/libdl-
2.5.so
b7ae1000-b7ae3000 rw-p 00001000 08:06 1731208 /lib/tls/i686/cmov/libdl-
2.5.so
b7ae3000-b7b08000 r-xp 00000000 08:06 1731210 /lib/tls/i686/cmov/libm-
2.5.so
b7b08000-b7b0a000 rw-p 00024000 08:06 1731210 /lib/tls/i686/cmov/libm-
2.5.so
b7b0a000-b7bca000 r-xp 00000000 08:06 1437499
/usr/lib/libasound.so.2.0.0
b7bca000-b7bcf000 rw-p 000bf000 08:06 1437499
/usr/lib/libasound.so.2.0.0
b7bcf000-b7bd0000 rw-p b7bcf000 00:00 0
b7bd0000-b7d0b000 r-xp 00000000 08:06 1731202 /lib/tls/i686/cmov/libc-
2.5.so
b7d0b000-b7d0c000 r–p 0013b000 08:06 1731202 /lib/tls/i686/cmov/libc-
2.5.so
b7d0c000-b7d0e000 rw-p 0013c000 08:06 1731202 /lib/tls/i686/cmov/libc-
2.5.so
b7d0e000-b7d11000 rw-p b7d0e000 00:00 0
b7d11000-b7d15000 r-xp 00000000 08:06 1437485
/usr/lib/libXxf86vm.so.1.0.0
b7d15000-b7d16000 rw-p 00003000 08:06 1437485
/usr/lib/libXxf86vm.so.1.0.0
b7d16000-b7d1a000 r-xp 00000000 08:06 1437481
/usr/lib/libXxf86dga.so.1.0.0
b7d1a000-b7d1b000 rw-p 00004000 08:06 1437481
/usr/lib/libXxf86dga.so.1.0.0
b7d1b000-b7e08000 r-xp 00000000 08:06 1437428 /usr/lib/libX11.so.6.2.0
b7e08000-b7e0c000 rw-p 000ed000 08:06 1437428 /usr/lib/libX11.so.6.2.0
b7e0c000-b7e19000 r-xp 00000000 08:06 1437449 /usr/lib/libXext.so.6.4.0
b7e19000-b7e1a000 rw-p 0000d000 08:06 1437449 /usr/lib/libXext.so.6.4.0
b7e1a000-bAborted (core dumped)

-------------- next part --------------
An HTML attachment was scrubbed…
URL:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20071226/32aea388/attachment-0001.htm


Message: 3
Date: Wed, 26 Dec 2007 02:44:37 -0500
From: James Barrett
Subject: Re: [SDL] SDL Digest, Vol 12, Issue 32
To: “A list for developers using the SDL library. (includes
SDL-announce)”
Message-ID: <47720665.1060506 at gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

renjith kumar wrote:

*** glibc detected *** ./sample: free(): invalid pointer: 0xbf8242b8


I get this same error when my program exits. I’ve been ignoring it
because I thought maybe SDL_FreeSurface (or some other sdl free
function) was getting called more than once for the same pointer.

jim


Message: 4
Date: Wed, 26 Dec 2007 21:24:41 +0900
From: Scott Harper
Subject: Re: [SDL] OpenGL + Timing
To: “A list for developers using the SDL library. (includes
SDL-announce)”
Message-ID:
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

Both of those are valid options, and I think neither have any clear-
cut benefits over the other. Another option you may want to consider
is to have a second string running all the time (in the background) to
process your objects at a constant framerate, and then your rendering
thread either renders as fast as it can (you MAY end up with slightly
choppy movement if your processing thread is significantly slower than
your rendering thread); or you can put in a little extra work and have
the rendering thread interpolate the points between graphical
keyframes when determining where to draw your objects. (Hopefully
that made sense. There’s a really nice article out there that was
written as an argument for this approach and explains it both better
an in more detail than I just did.)

So basically, the choice is up to you. All of the choices end up
being useless if you go to low enough hardware specs, so whatever
works well for being straightforward enough for you (depending on your
experience making games) and working effectively for the game you’re
designing. The separate process thread is most ideal for games where
accurate jumping/timing is key to the experience/challenge of the
game, for instance. But if you’re making a turn-based strategy (or
even possibly a real-time strategy) game, then you may not need the
exact precision gained by doing it such.

– Scott

On Dec 26, 2007, at 12:16 PM, Jim Tink wrote:

Hello all,
I’m new to SDL and I’ve been through a lot of the tutorials listed on
the tutorial page at libsdl.org. But I’m having issues figuring out
when to handle rendering. Should I use a SDL_AddTimer to add a timer
function or should I use the delay function and render every 30 or so
ms?

Thanks for helping,
Jim Tink


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Message: 5
Date: Wed, 26 Dec 2007 14:02:05 +0100
From: Clemens Kirchgatterer <clemens at 1541.org>
Subject: Re: [SDL] SDL Digest, Vol 12, Issue 32
To: sdl at lists.libsdl.org
Message-ID: <20071226140205.67f4bc4d.clemens at 1541.org>
Content-Type: text/plain; charset=US-ASCII

James Barrett wrote:

renjith kumar wrote:

*** glibc detected *** ./sample: free(): invalid pointer:
0xbf8242b8 ***

I get this same error when my program exits. I’ve been ignoring it
because I thought maybe SDL_FreeSurface (or some other sdl free
function) was getting called more than once for the same pointer.

ignoring it is not very good practice, you have a bug in your code that
might come back at some later time and bite you.

i suggest the usage of valgrind (for both of you).

best regards …
clemens


Message: 6
Date: Wed, 26 Dec 2007 14:53:57 +0100
From: Christian Meyer
Subject: Re: [SDL] Blitting on 8 bit surfaces
To: sdl at libsdl.org
Message-ID: <fktmdl$5jb$1 at ger.gmane.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Sylvain Beucler schrieb:

Hi,

On Sun, Dec 23, 2007 at 11:27:56AM +0100, Christian Meyer wrote:

Thanks for your answer :slight_smile:

In my spezial case, I have surfaces where some indices have a spezial
meaning (e. g. marks areas where an animations will be displayed).

So if I understood this correctly, I have to do the following:

When all pixels with index n should be unchaged, I have to make sure,
that n points to the same RGB-value in both palettes.

I think this may not always work. For example, maybe the destination
palette has the same RGB-value than index ‘n’ twice: at index 'n’
and at another index. In that case, maybe the other index will be used.

I’m not sure if there’s an easy way to do that using BlitSurface. If
you only work with 8bit surfaces, maybe you could easily implement
your own Blit function (see
http://www.libsdl.org/cgi/docwiki.cgi/Pixel_20Access).

When the color of a pixel should be unchanged, I just have to make
sure,

that the RGB-Value exists in the dest palette.

This should work :slight_smile:

Yes, I think implementing my own blit function will be the easiest way.

Thanks yor your help, and merry Christmas :slight_smile:


Message: 7
Date: Wed, 26 Dec 2007 09:41:03 -0500
From: Jonathan Dearborn
Subject: Re: [SDL] Blitting on 8 bit surfaces
To: “A list for developers using the SDL library. (includes
SDL-announce)”
Message-ID:
Content-Type: text/plain; charset=“iso-8859-1”

Hey,

Just a note to make sure you don’t waste your time: There exist many
rewritten blitting routines already. I can only point you to the one I
worked on since I don’t know much about the others. Look for SPG_Blit in
the SPG_Surface.cpp file in my Sprig library at
http://pubpages.unh.edu/~jmb97

See ya,
Jonny D

To: sdl at libsdl.org
From: tvgenial at web.de
Date: Wed, 26 Dec 2007 14:53:57 +0100
Subject: Re: [SDL] Blitting on 8 bit surfaces

Sylvain Beucler schrieb:

Hi,

On Sun, Dec 23, 2007 at 11:27:56AM +0100, Christian Meyer wrote:

Thanks for your answer :slight_smile:

In my spezial case, I have surfaces where some indices have a spezial
meaning (e. g. marks areas where an animations will be displayed).

So if I understood this correctly, I have to do the following:

When all pixels with index n should be unchaged, I have to make sure,
that n points to the same RGB-value in both palettes.

I think this may not always work. For example, maybe the destination
palette has the same RGB-value than index ‘n’ twice: at index 'n’
and at another index. In that case, maybe the other index will be
used.

I’m not sure if there’s an easy way to do that using BlitSurface. If
you only work with 8bit surfaces, maybe you could easily implement
your own Blit function (see
http://www.libsdl.org/cgi/docwiki.cgi/Pixel_20Access).

When the color of a pixel should be unchanged, I just have to make
sure,

that the RGB-Value exists in the dest palette.

This should work :slight_smile:

Yes, I think implementing my own blit function will be the easiest way.

Thanks yor your help, and merry Christmas :slight_smile:


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Get the power of Windows + Web with the new Windows Live.
http://www.windowslive.com?ocid=TXT_TAGHM_Wave2_powerofwindows_122007
-------------- next part --------------
An HTML attachment was scrubbed…
URL:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20071226/758b4f45/attachment.html



SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

End of SDL Digest, Vol 12, Issue 35



Thanks’n Regards,
Renjith.