[FFmpeg-devel] [PATCH WIPv2 2/2] avdev: add sdl2 device

Michael Niedermayer michael at niedermayer.cc
Sun May 22 00:27:20 CEST 2016


On Sat, May 21, 2016 at 11:39:01PM +0200, Michael Niedermayer wrote:
> On Sat, May 21, 2016 at 07:35:04PM +0100, Josh de Kock wrote:
> > Hi Marton,
> > 
> > Sorry for not updating it after we last spoke, I lost my source for the
> > patch so I was force to do it again. Anyways, here it is. I'm using
> > SDL_Events for sending the packets, using SDL_WaitEvent to throttle it,
> > and Conditions to make sure that the queue doesn't build up. Is there
> > anything I missed?
> > 
> > There's still an issue with the window freezing up though, and on quit
> > there are "uncommitted CATransaction[s]" (an OSX thing, but I'm sure
> > that it would still impact other systems if it is a problem on OSX).
> > 
> > I spoke to some of the people in the #sdl IRC channel on freenode, and
> > they said that, even with most of the SDL functions in the separate
> > thread, it shouldn't work.
> > 
> > Any and all help would be much appreciated,
> > 
> > Josh
> > 
> > ---
> >  libavdevice/Makefile     |   1 +
> >  libavdevice/alldevices.c |   1 +
> >  libavdevice/sdl2.c       | 458 +++++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 460 insertions(+)
> >  create mode 100644 libavdevice/sdl2.c
> 
> breaks build
> make distclean ; ./configure && make -j12
> 
> libavdevice/sdl2.c:40:5: error: unknown type name ‘SDL_Window’
> libavdevice/sdl2.c:41:5: error: unknown type name ‘SDL_Renderer’
> libavdevice/sdl2.c:47:5: error: unknown type name ‘SDL_Texture’
> libavdevice/sdl2.c:64:24: error: ‘SDL_PIXELFORMAT_RGB332’ undeclared here (not in a function)
> libavdevice/sdl2.c:65:26: error: ‘SDL_PIXELFORMAT_RGB444’ undeclared here (not in a function)
> libavdevice/sdl2.c:66:26: error: ‘SDL_PIXELFORMAT_RGB555’ undeclared here (not in a function)
> libavdevice/sdl2.c:67:26: error: ‘SDL_PIXELFORMAT_BGR555’ undeclared here (not in a function)
> libavdevice/sdl2.c:78:26: error: ‘SDL_PIXELFORMAT_RGB565’ undeclared here (not in a function)
> libavdevice/sdl2.c:79:26: error: ‘SDL_PIXELFORMAT_BGR565’ undeclared here (not in a function)
> libavdevice/sdl2.c:80:25: error: ‘SDL_PIXELFORMAT_RGB24’ undeclared here (not in a function)
> libavdevice/sdl2.c:81:25: error: ‘SDL_PIXELFORMAT_BGR24’ undeclared here (not in a function)
> libavdevice/sdl2.c:82:25: error: ‘SDL_PIXELFORMAT_RGB888’ undeclared here (not in a function)
> libavdevice/sdl2.c:83:24: error: ‘SDL_PIXELFORMAT_RGBX8888’ undeclared here (not in a function)
> libavdevice/sdl2.c:84:25: error: ‘SDL_PIXELFORMAT_BGR888’ undeclared here (not in a function)
> libavdevice/sdl2.c:85:24: error: ‘SDL_PIXELFORMAT_BGRX8888’ undeclared here (not in a function)
> libavdevice/sdl2.c:86:24: error: ‘SDL_PIXELFORMAT_ARGB8888’ undeclared here (not in a function)
> libavdevice/sdl2.c:87:24: error: ‘SDL_PIXELFORMAT_RGBA8888’ undeclared here (not in a function)
> libavdevice/sdl2.c:88:24: error: ‘SDL_PIXELFORMAT_ABGR8888’ undeclared here (not in a function)
> libavdevice/sdl2.c:89:24: error: ‘SDL_PIXELFORMAT_BGRA8888’ undeclared here (not in a function)
> libavdevice/sdl2.c:93:27: error: ‘SDL_PIXELFORMAT_IYUV’ undeclared here (not in a function)
> libavdevice/sdl2.c:94:27: error: ‘SDL_PIXELFORMAT_YUY2’ undeclared here (not in a function)
> libavdevice/sdl2.c:95:27: error: ‘SDL_PIXELFORMAT_UYVY’ undeclared here (not in a function)
> libavdevice/sdl2.c: In function ‘event_thread’:
> libavdevice/sdl2.c:167:17: error: ‘SDL_WINDOW_RESIZABLE’ undeclared (first use in this function)
> libavdevice/sdl2.c:167:17: note: each undeclared identifier is reported only once for each function it appears in
> libavdevice/sdl2.c:167:17: error: invalid operands to binary | (have ‘int’ and ‘const struct sdl_texture_pix_fmt_entry *’)
> libavdevice/sdl2.c:167:60: error: ‘SDL_WINDOW_FULLSCREEN’ undeclared (first use in this function)
> libavdevice/sdl2.c:167:32: error: invalid operands to binary | (have ‘const struct sdl_texture_pix_fmt_entry *’ and ‘const struct sdl_texture_pix_fmt_entry *’)
> libavdevice/sdl2.c:168:60: error: ‘SDL_WINDOW_BORDERLESS’ undeclared (first use in this function)
> libavdevice/sdl2.c:167:87: error: invalid operands to binary | (have ‘const struct sdl_texture_pix_fmt_entry *’ and ‘const struct sdl_texture_pix_fmt_entry *’)
> libavdevice/sdl2.c:167:17: warning: initialization makes integer from pointer without a cast [enabled by default]
> libavdevice/sdl2.c:181:5: error: implicit declaration of function ‘SDL_CreateWindowAndRenderer’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c:188:5: error: implicit declaration of function ‘SDL_SetWindowTitle’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c:190:5: error: implicit declaration of function ‘SDL_CreateTexture’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c:190:71: error: ‘SDL_TEXTUREACCESS_STREAMING’ undeclared (first use in this function)
> libavdevice/sdl2.c:190:18: warning: assignment makes pointer from integer without a cast [enabled by default]
> libavdevice/sdl2.c:235:18: error: ‘SDL_WINDOWEVENT’ undeclared (first use in this function)
> libavdevice/sdl2.c:236:29: error: ‘SDL_Event’ has no member named ‘window’
> libavdevice/sdl2.c:236:36: error: request for member ‘event’ in something not a structure or union
> libavdevice/sdl2.c:237:26: error: ‘SDL_WINDOWEVENT_RESIZED’ undeclared (first use in this function)
> libavdevice/sdl2.c:238:26: error: ‘SDL_WINDOWEVENT_SIZE_CHANGED’ undeclared (first use in this function)
> libavdevice/sdl2.c:239:51: error: ‘SDL_Event’ has no member named ‘window’
> libavdevice/sdl2.c:239:58: error: request for member ‘data1’ in something not a structure or union
> libavdevice/sdl2.c:239:44: warning: assignment makes integer from pointer without a cast [enabled by default]
> libavdevice/sdl2.c:240:51: error: ‘SDL_Event’ has no member named ‘window’
> libavdevice/sdl2.c:240:58: error: request for member ‘data2’ in something not a structure or union
> libavdevice/sdl2.c:240:44: warning: assignment makes integer from pointer without a cast [enabled by default]
> libavdevice/sdl2.c:255:17: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
> libavdevice/sdl2.c:262:25: error: implicit declaration of function ‘SDL_UpdateYUVTexture’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c:296:25: error: implicit declaration of function ‘SDL_UpdateTexture’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c:303:17: error: implicit declaration of function ‘SDL_RenderClear’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c:304:17: error: implicit declaration of function ‘SDL_RenderCopy’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c:305:17: error: implicit declaration of function ‘SDL_RenderPresent’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c:315:9: error: implicit declaration of function ‘SDL_DestroyTexture’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c:319:9: error: implicit declaration of function ‘SDL_DestroyRenderer’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c:323:9: error: implicit declaration of function ‘SDL_DestroyWindow’ [-Werror=implicit-function-declaration]
> libavdevice/sdl2.c: In function ‘sdl2_write_header’:
> libavdevice/sdl2.c:383:5: warning: passing argument 2 of ‘SDL_CreateThread’ discards ‘const’ qualifier from pointer target type [enabled by default]
> /usr/include/SDL/SDL_thread.h:93:38: note: expected ‘void *’ but argument is of type ‘const char *’
> libavdevice/sdl2.c:383:5: error: too many arguments to function ‘SDL_CreateThread’
> /usr/include/SDL/SDL_thread.h:93:38: note: declared here
> libavdevice/sdl2.c: In function ‘sdl2_write_packet’:
> libavdevice/sdl2.c:414:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
> libavdevice/sdl2.c:416:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
> CC      libavdevice/xv.o
> cc1: some warnings being treated as errors
> make: *** [libavdevice/sdl2.o] Error 1
> make: *** Waiting for unfinished jobs....

with patches 1+2

git log -2
commit b8dd3fe28d2ba221e1862880ce4597e1354b87c8
Author: Josh de Kock <josh at itanimul.li>
Date:   Sat May 21 19:35:04 2016 +0100

    avdev: add sdl2 device

    Hi Marton,

    Sorry for not updating it after we last spoke, I lost my source for the
    patch so I was force to do it again. Anyways, here it is. I'm using
    SDL_Events for sending the packets, using SDL_WaitEvent to throttle it,
    and Conditions to make sure that the queue doesn't build up. Is there
    anything I missed?

    There's still an issue with the window freezing up though, and on quit
    there are "uncommitted CATransaction[s]" (an OSX thing, but I'm sure
    that it would still impact other systems if it is a problem on OSX).

    I spoke to some of the people in the #sdl IRC channel on freenode, and
    they said that, even with most of the SDL functions in the separate
    thread, it shouldn't work.

    Any and all help would be much appreciated,

    Josh

    Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

commit fa10dcacc4bbad46e58b8fc5c16c5f619061cd8a
Author: Marton Balint <cus at passwd.hu>
Date:   Tue May 17 18:00:22 2016 +0100

    ffplay: convert ffplay to use SDL2

    This patch looks mostly fine, there's just one thing though, which is
    the ALSA fix using envvars. There doesn't seem to be a replacement for
    these functions in SDL2, so I was wondering how else it could be done.
    Maybe through putenv()?

    Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

make distclean ; ./configure && make -j12

libavdevice/sdl2.c:40:5: error: unknown type name ‘SDL_Window’
libavdevice/sdl2.c:41:5: error: unknown type name ‘SDL_Renderer’
libavdevice/sdl2.c:47:5: error: unknown type name ‘SDL_Texture’
libavdevice/sdl2.c:64:24: error: ‘SDL_PIXELFORMAT_RGB332’ undeclared here (not in a function)
libavdevice/sdl2.c:65:26: error: ‘SDL_PIXELFORMAT_RGB444’ undeclared here (not in a function)
libavdevice/sdl2.c:66:26: error: ‘SDL_PIXELFORMAT_RGB555’ undeclared here (not in a function)
libavdevice/sdl2.c:67:26: error: ‘SDL_PIXELFORMAT_BGR555’ undeclared here (not in a function)
libavdevice/sdl2.c:78:26: error: ‘SDL_PIXELFORMAT_RGB565’ undeclared here (not in a function)
libavdevice/sdl2.c:79:26: error: ‘SDL_PIXELFORMAT_BGR565’ undeclared here (not in a function)
libavdevice/sdl2.c:80:25: error: ‘SDL_PIXELFORMAT_RGB24’ undeclared here (not in a function)
libavdevice/sdl2.c:81:25: error: ‘SDL_PIXELFORMAT_BGR24’ undeclared here (not in a function)
libavdevice/sdl2.c:82:25: error: ‘SDL_PIXELFORMAT_RGB888’ undeclared here (not in a function)
libavdevice/sdl2.c:83:24: error: ‘SDL_PIXELFORMAT_RGBX8888’ undeclared here (not in a function)
libavdevice/sdl2.c:84:25: error: ‘SDL_PIXELFORMAT_BGR888’ undeclared here (not in a function)
libavdevice/sdl2.c:85:24: error: ‘SDL_PIXELFORMAT_BGRX8888’ undeclared here (not in a function)
libavdevice/sdl2.c:86:24: error: ‘SDL_PIXELFORMAT_ARGB8888’ undeclared here (not in a function)
libavdevice/sdl2.c:87:24: error: ‘SDL_PIXELFORMAT_RGBA8888’ undeclared here (not in a function)
libavdevice/sdl2.c:88:24: error: ‘SDL_PIXELFORMAT_ABGR8888’ undeclared here (not in a function)
libavdevice/sdl2.c:89:24: error: ‘SDL_PIXELFORMAT_BGRA8888’ undeclared here (not in a function)
libavdevice/sdl2.c:93:27: error: ‘SDL_PIXELFORMAT_IYUV’ undeclared here (not in a function)
libavdevice/sdl2.c:94:27: error: ‘SDL_PIXELFORMAT_YUY2’ undeclared here (not in a function)
libavdevice/sdl2.c:95:27: error: ‘SDL_PIXELFORMAT_UYVY’ undeclared here (not in a function)
libavdevice/sdl2.c: In function ‘event_thread’:
libavdevice/sdl2.c:167:17: error: ‘SDL_WINDOW_RESIZABLE’ undeclared (first use in this function)
libavdevice/sdl2.c:167:17: note: each undeclared identifier is reported only once for each function it appears in
libavdevice/sdl2.c:167:17: error: invalid operands to binary | (have ‘int’ and ‘const struct sdl_texture_pix_fmt_entry *’)
libavdevice/sdl2.c:167:60: error: ‘SDL_WINDOW_FULLSCREEN’ undeclared (first use in this function)
libavdevice/sdl2.c:167:32: error: invalid operands to binary | (have ‘const struct sdl_texture_pix_fmt_entry *’ and ‘const struct sdl_texture_pix_fmt_entry *’)
libavdevice/sdl2.c:168:60: error: ‘SDL_WINDOW_BORDERLESS’ undeclared (first use in this function)
libavdevice/sdl2.c:167:87: error: invalid operands to binary | (have ‘const struct sdl_texture_pix_fmt_entry *’ and ‘const struct sdl_texture_pix_fmt_entry *’)
libavdevice/sdl2.c:167:17: warning: initialization makes integer from pointer without a cast [enabled by default]
libavdevice/sdl2.c:181:5: error: implicit declaration of function ‘SDL_CreateWindowAndRenderer’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c:188:5: error: implicit declaration of function ‘SDL_SetWindowTitle’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c:190:5: error: implicit declaration of function ‘SDL_CreateTexture’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c:190:71: error: ‘SDL_TEXTUREACCESS_STREAMING’ undeclared (first use in this function)
libavdevice/sdl2.c:190:18: warning: assignment makes pointer from integer without a cast [enabled by default]
libavdevice/sdl2.c:235:18: error: ‘SDL_WINDOWEVENT’ undeclared (first use in this function)
libavdevice/sdl2.c:236:29: error: ‘SDL_Event’ has no member named ‘window’
libavdevice/sdl2.c:236:36: error: request for member ‘event’ in something not a structure or union
libavdevice/sdl2.c:237:26: error: ‘SDL_WINDOWEVENT_RESIZED’ undeclared (first use in this function)
libavdevice/sdl2.c:238:26: error: ‘SDL_WINDOWEVENT_SIZE_CHANGED’ undeclared (first use in this function)
libavdevice/sdl2.c:239:51: error: ‘SDL_Event’ has no member named ‘window’
libavdevice/sdl2.c:239:58: error: request for member ‘data1’ in something not a structure or union
libavdevice/sdl2.c:239:44: warning: assignment makes integer from pointer without a cast [enabled by default]
libavdevice/sdl2.c:240:51: error: ‘SDL_Event’ has no member named ‘window’
libavdevice/sdl2.c:240:58: error: request for member ‘data2’ in something not a structure or union
libavdevice/sdl2.c:240:44: warning: assignment makes integer from pointer without a cast [enabled by default]
libavdevice/sdl2.c:255:17: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
libavdevice/sdl2.c:262:25: error: implicit declaration of function ‘SDL_UpdateYUVTexture’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c:296:25: error: implicit declaration of function ‘SDL_UpdateTexture’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c:303:17: error: implicit declaration of function ‘SDL_RenderClear’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c:304:17: error: implicit declaration of function ‘SDL_RenderCopy’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c:305:17: error: implicit declaration of function ‘SDL_RenderPresent’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c:315:9: error: implicit declaration of function ‘SDL_DestroyTexture’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c:319:9: error: implicit declaration of function ‘SDL_DestroyRenderer’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c:323:9: error: implicit declaration of function ‘SDL_DestroyWindow’ [-Werror=implicit-function-declaration]
libavdevice/sdl2.c: In function ‘sdl2_write_header’:
libavdevice/sdl2.c:383:5: warning: passing argument 2 of ‘SDL_CreateThread’ discards ‘const’ qualifier from pointer target type [enabled by default]
/usr/include/SDL/SDL_thread.h:93:38: note: expected ‘void *’ but argument is of type ‘const char *’
libavdevice/sdl2.c:383:5: error: too many arguments to function ‘SDL_CreateThread’
/usr/include/SDL/SDL_thread.h:93:38: note: declared here
libavdevice/sdl2.c: In function ‘sdl2_write_packet’:
libavdevice/sdl2.c:414:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
libavdevice/sdl2.c:416:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
cc1: some warnings being treated as errors
make: *** [libavdevice/sdl2.o] Error 1
make: *** Waiting for unfinished jobs....
CC      libavdevice/xv.o


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160522/ee94c6d6/attachment.sig>


More information about the ffmpeg-devel mailing list