From ea8c73a766e058fd6dbeee248c8e0ec9af0d05e4 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 5 Jan 2002 18:25:48 +0000 Subject: [PATCH] * ./src/audio_output/aout_s16.c: fixed a segfault. It may have unexpected side effects because I don't know this part of the code, but at least it doesn't crash anymore. * ./plugins/beos/beos.cpp: first attempt at porting the BeOS plugin to the new video output and module systems. Doesn't work nor even compile yet. * ./configure.in: we now check the gtk-config version. --- configure | 34 ++--- configure.in | 4 + plugins/beos/beos.cpp | 12 +- plugins/beos/vout_beos.cpp | 243 ++++++++++++++++++++---------------- src/audio_output/aout_s16.c | 12 +- 5 files changed, 170 insertions(+), 135 deletions(-) diff --git a/configure b/configure index 0fdd9b241c..8bd134d4c1 100755 --- a/configure +++ b/configure @@ -6964,6 +6964,10 @@ fi if test -x ${GTK_CONFIG} then + if expr 1.2.0 \> `$GTK_CONFIG --version` >/dev/null + then + { echo "configure: error: Your development package for Gtk+ is too old, you need at least version 1.2.0. Please upgrade and try again. Alternatively you can also configure with --disable-gtk." 1>&2; exit 1; } + fi CFLAGS_GTK="`${GTK_CONFIG} --cflags gtk`" LIB_GTK="`${GTK_CONFIG} --libs gtk | sed 's,-rdynamic,,'`" fi @@ -6975,17 +6979,17 @@ fi do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:6979: checking for $ac_hdr" >&5 +echo "configure:6983: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:6989: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6993: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -7042,17 +7046,17 @@ if test x$enable_x11 != xno && do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:7046: checking for $ac_hdr" >&5 +echo "configure:7050: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:7056: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:7060: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -7105,17 +7109,17 @@ if test x$enable_xvideo != xno && do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:7109: checking for $ac_hdr" >&5 +echo "configure:7113: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:7119: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:7123: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -7155,17 +7159,17 @@ if test "${enable_alsa+set}" = set; then then ac_safe=`echo "alsa/asoundlib.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for alsa/asoundlib.h""... $ac_c" 1>&6 -echo "configure:7159: checking for alsa/asoundlib.h" >&5 +echo "configure:7163: checking for alsa/asoundlib.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:7169: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:7173: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -7182,7 +7186,7 @@ fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for main in -lasound""... $ac_c" 1>&6 -echo "configure:7186: checking for main in -lasound" >&5 +echo "configure:7190: checking for main in -lasound" >&5 ac_lib_var=`echo asound'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7190,14 +7194,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lasound $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7205: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else diff --git a/configure.in b/configure.in index f61f58102c..362faf756c 100644 --- a/configure.in +++ b/configure.in @@ -1164,6 +1164,10 @@ then AC_PATH_PROG(GTK_CONFIG, gtk-config, no, $GTK_PATH) if test -x ${GTK_CONFIG} then + if expr 1.2.0 \> `$GTK_CONFIG --version` >/dev/null + then + AC_MSG_ERROR([Your development package for Gtk+ is too old, you need at least version 1.2.0. Please upgrade and try again. Alternatively you can also configure with --disable-gtk.]) + fi CFLAGS_GTK="`${GTK_CONFIG} --cflags gtk`" LIB_GTK="`${GTK_CONFIG} --libs gtk | sed 's,-rdynamic,,'`" fi diff --git a/plugins/beos/beos.cpp b/plugins/beos/beos.cpp index 4127595b3b..48be562800 100644 --- a/plugins/beos/beos.cpp +++ b/plugins/beos/beos.cpp @@ -2,7 +2,7 @@ * beos.cpp : BeOS plugin for vlc ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: beos.cpp,v 1.15 2001/12/30 07:09:54 sam Exp $ + * $Id: beos.cpp,v 1.16 2002/01/05 18:25:48 sam Exp $ * * Authors: Jean-Marc Dressler * Samuel Hocevar @@ -48,11 +48,11 @@ ADD_WINDOW( "Configuration for BeOS module" ) MODULE_CONFIG_STOP MODULE_INIT_START - p_module->i_capabilities = MODULE_CAPABILITY_NULL - | MODULE_CAPABILITY_AOUT - | MODULE_CAPABILITY_VOUT - | MODULE_CAPABILITY_INTF; - p_module->psz_longname = "BeOS standard API module"; + SET_DESCRIPTION( "BeOS standard API module" ) + ADD_CAPABILITY( INTF, 100 ) + ADD_CAPABILITY( VOUT, 100 ) + ADD_CAPABILITY( AOUT, 100 ) + ADD_SHORTCUT( "beos" ) MODULE_INIT_STOP MODULE_ACTIVATE_START diff --git a/plugins/beos/vout_beos.cpp b/plugins/beos/vout_beos.cpp index 7672747ad2..0d15c05b73 100644 --- a/plugins/beos/vout_beos.cpp +++ b/plugins/beos/vout_beos.cpp @@ -2,7 +2,7 @@ * vout_beos.cpp: beos video output display method ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: vout_beos.cpp,v 1.36 2001/12/30 07:09:54 sam Exp $ + * $Id: vout_beos.cpp,v 1.37 2002/01/05 18:25:48 sam Exp $ * * Authors: Jean-Marc Dressler * Samuel Hocevar @@ -48,8 +48,8 @@ extern "C" #include "VideoWindow.h" -#define BITS_PER_PLANE 32 -#define BYTES_PER_PIXEL 4 +#define BITS_PER_PLANE 16 +#define BYTES_PER_PIXEL 2 /***************************************************************************** * vout_sys_t: BeOS video output method descriptor @@ -59,11 +59,10 @@ extern "C" *****************************************************************************/ typedef struct vout_sys_s { - VideoWindow * p_window; + VideoWindow * p_window; - byte_t * pp_buffer[2]; - s32 i_width; - s32 i_height; + s32 i_width; + s32 i_height; } vout_sys_t; @@ -94,10 +93,8 @@ BWindow *beos_GetAppWindow(char *name) } /**************************************************************************** -* * DrawingThread : thread that really does the drawing - **************************************************************************** -*/ + ****************************************************************************/ int32 Draw(void *data) { //rudolf: sync init: @@ -161,16 +158,16 @@ bitmapWindow::~bitmapWindow() void bitmapWindow::FrameResized( float width, float height ) { - if (is_zoomed) - { - return; - } - float width_scale; - float height_scale; + if (is_zoomed) + { + return; + } + float width_scale; + float height_scale; - width_scale = width / origRect.Width(); - height_scale = height / origRect.Height(); - + width_scale = width / origRect.Width(); + height_scale = height / origRect.Height(); + /* if the width is proportionally smaller */ if (width_scale <= height_scale) { @@ -184,23 +181,23 @@ void bitmapWindow::FrameResized( float width, float height ) void bitmapWindow::Zoom(BPoint origin, float width, float height ) { - if(is_zoomed) - { - MoveTo(origRect.left, origRect.top); - ResizeTo(origRect.IntegerWidth(), origRect.IntegerHeight()); - be_app->ShowCursor(); - } - else - { - BScreen *screen; - screen = new BScreen(this); - BRect rect = screen->Frame(); - delete screen; - MoveTo(0,0); - ResizeTo(rect.IntegerWidth(), rect.IntegerHeight()); - be_app->HideCursor(); - } - is_zoomed = !is_zoomed; + if(is_zoomed) + { + MoveTo(origRect.left, origRect.top); + ResizeTo(origRect.IntegerWidth(), origRect.IntegerHeight()); + be_app->ShowCursor(); + } + else + { + BScreen *screen; + screen = new BScreen(this); + BRect rect = screen->Frame(); + delete screen; + MoveTo(0,0); + ResizeTo(rect.IntegerWidth(), rect.IntegerHeight()); + be_app->HideCursor(); + } + is_zoomed = !is_zoomed; } /***************************************************************************** @@ -226,16 +223,16 @@ void directWindow::DirectConnected(direct_buffer_info *info) void directWindow::FrameResized( float width, float height ) { - if (is_zoomed) - { - return; - } - float width_scale; - float height_scale; + if (is_zoomed) + { + return; + } + float width_scale; + float height_scale; - width_scale = width / origRect.Width(); - height_scale = height / origRect.Height(); - + width_scale = width / origRect.Width(); + height_scale = height / origRect.Height(); + /* if the width is proportionally smaller */ if (width_scale <= height_scale) { @@ -249,25 +246,25 @@ void directWindow::FrameResized( float width, float height ) void directWindow::Zoom(BPoint origin, float width, float height ) { - if(is_zoomed) - { - SetFullScreen(false); - MoveTo(origRect.left, origRect.top); - ResizeTo(origRect.IntegerWidth(), origRect.IntegerHeight()); - be_app->ShowCursor(); - } - else - { - SetFullScreen(true); - BScreen *screen; - screen = new BScreen(this); - BRect rect = screen->Frame(); - delete screen; - MoveTo(0,0); - ResizeTo(rect.IntegerWidth(), rect.IntegerHeight()); - be_app->HideCursor(); - } - is_zoomed = !is_zoomed; + if(is_zoomed) + { + SetFullScreen(false); + MoveTo(origRect.left, origRect.top); + ResizeTo(origRect.IntegerWidth(), origRect.IntegerHeight()); + be_app->ShowCursor(); + } + else + { + SetFullScreen(true); + BScreen *screen; + screen = new BScreen(this); + BRect rect = screen->Frame(); + delete screen; + MoveTo(0,0); + ResizeTo(rect.IntegerWidth(), rect.IntegerHeight()); + be_app->HideCursor(); + } + is_zoomed = !is_zoomed; } /***************************************************************************** @@ -279,29 +276,34 @@ VideoWindow::VideoWindow( int width, int height, if ( BDirectWindow::SupportsWindowMode() ) { voutWindow = new directWindow( BRect( 80, 50, - 80 + width, 50 + height ), this ); + 80 + width, 50 + height ), this ); } else { - voutWindow = new bitmapWindow( BRect( 80, 50, - 80 + width, 50 + height ), this ); - } + voutWindow = new bitmapWindow( BRect( 80, 50, + 80 + width, 50 + height ), this ); + } - /* set the VideoWindow variables */ + /* set the VideoWindow variables */ teardownwindow = false; - - /* create the view to do the display */ + + /* create the view to do the display */ view = new VLCView( voutWindow->Bounds() ); voutWindow->AddChild(view); /* Bitmap mode overlay not available */ - bitmap[0] = new BBitmap( voutWindow->Bounds(), B_RGB32); - bitmap[1] = new BBitmap( voutWindow->Bounds(), B_RGB32); - memset(bitmap[0]->Bits(), 0, bitmap[0]->BitsLength()); - memset(bitmap[1]->Bits(), 0, bitmap[1]->BitsLength()); +#if BITS_PER_PLANE == 32 + bitmap[0] = new BBitmap( voutWindow->Bounds(), B_RGB32); + bitmap[1] = new BBitmap( voutWindow->Bounds(), B_RGB32); +#else + bitmap[0] = new BBitmap( voutWindow->Bounds(), B_RGB32); + bitmap[1] = new BBitmap( voutWindow->Bounds(), B_RGB32); +#endif + memset(bitmap[0]->Bits(), 0, bitmap[0]->BitsLength()); + memset(bitmap[1]->Bits(), 0, bitmap[1]->BitsLength()); - i_width = bitmap[0]->Bounds().IntegerWidth(); - i_height = bitmap[0]->Bounds().IntegerHeight(); + i_width = bitmap[0]->Bounds().IntegerWidth(); + i_height = bitmap[0]->Bounds().IntegerHeight(); voutWindow->Show(); } @@ -316,8 +318,8 @@ VideoWindow::~VideoWindow() voutWindow->Quit(); teardownwindow = true; wait_for_thread(fDrawThreadID, &result); - delete bitmap[0]; - delete bitmap[1]; + delete bitmap[0]; + delete bitmap[1]; } void VideoWindow::resizeIfRequired( int newWidth, int newHeight ) @@ -339,10 +341,10 @@ void VideoWindow::resizeIfRequired( int newWidth, int newHeight ) void VideoWindow::drawBuffer(int bufferIndex) { - status_t status; - - i_buffer = bufferIndex; - + status_t status; + + i_buffer = bufferIndex; + fDrawThreadID = spawn_thread(Draw, "drawing_thread", B_DISPLAY_PRIORITY, (void*) this); wait_for_thread(fDrawThreadID, &status); @@ -353,7 +355,11 @@ void VideoWindow::drawBuffer(int bufferIndex) *****************************************************************************/ VLCView::VLCView(BRect bounds) : BView(bounds, "", B_FOLLOW_ALL, B_WILL_DRAW) { - SetViewColor(B_TRANSPARENT_32_BIT); +#if BITS_PER_PLANE == 32 + SetViewColor(B_TRANSPARENT_32_BIT); +#else + SetViewColor(B_TRANSPARENT_16_BIT); +#endif } /***************************************************************************** @@ -368,8 +374,8 @@ VLCView::~VLCView() *****************************************************************************/ void VLCView::MouseDown(BPoint point) { - BWindow *win = Window(); - win->Zoom(); + BWindow *win = Window(); + win->Zoom(); } extern "C" @@ -379,12 +385,13 @@ extern "C" * Local prototypes *****************************************************************************/ static int vout_Probe ( probedata_t *p_data ); -static int vout_Create ( struct vout_thread_s * ); -static int vout_Init ( struct vout_thread_s * ); -static void vout_End ( struct vout_thread_s * ); -static void vout_Destroy ( struct vout_thread_s * ); -static int vout_Manage ( struct vout_thread_s * ); -static void vout_Display ( struct vout_thread_s * ); +static int vout_Create ( vout_thread_t * ); +static int vout_Init ( vout_thread_t * ); +static void vout_End ( vout_thread_t * ); +static void vout_Destroy ( vout_thread_t * ); +static int vout_Manage ( vout_thread_t * ); +static void vout_Display ( vout_thread_t *, picture_t * ); +static void vout_Render ( vout_thread_t *, picture_t * ); static int BeosOpenDisplay ( vout_thread_t *p_vout ); static void BeosCloseDisplay( vout_thread_t *p_vout ); @@ -402,7 +409,7 @@ void _M( vout_getfunctions )( function_list_t * p_function_list ) p_function_list->functions.vout.pf_destroy = vout_Destroy; p_function_list->functions.vout.pf_manage = vout_Manage; p_function_list->functions.vout.pf_display = vout_Display; - p_function_list->functions.vout.pf_setpalette = NULL; + p_function_list->functions.vout.pf_render = vout_Render; } /***************************************************************************** @@ -434,9 +441,20 @@ int vout_Create( vout_thread_t *p_vout ) intf_ErrMsg( "error: %s", strerror(ENOMEM) ); return( 1 ); } - - /* force scaling off */ - p_vout->b_scale = false; + + if( p_vout->render.i_height * p_vout->render.i_aspect + >= p_vout->render.i_width * VOUT_ASPECT_FACTOR ) + { + p_vout->p_sys->i_width = p_vout->render.i_height + * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR; + p_vout->p_sys->i_height = p_vout->render.i_height; + } + else + { + p_vout->p_sys->i_width = p_vout->render.i_width; + p_vout->p_sys->i_height = p_vout->render.i_width + * VOUT_ASPECT_FACTOR / p_vout->render.i_aspect; + } /* Open and initialize device */ if( BeosOpenDisplay( p_vout ) ) @@ -457,8 +475,8 @@ int vout_Init( vout_thread_t *p_vout ) VideoWindow * p_win = p_vout->p_sys->p_window; if((p_win->bitmap[0] != NULL) && (p_win->bitmap[1] != NULL)) - { - p_vout->pf_setbuffers( p_vout, + { + p_vout->pf_setbuffers( p_vout, (byte_t *)p_win->bitmap[0]->Bits(), (byte_t *)p_win->bitmap[1]->Bits()); } @@ -470,7 +488,7 @@ int vout_Init( vout_thread_t *p_vout ) *****************************************************************************/ void vout_End( vout_thread_t *p_vout ) { - /* place code here to end the video */ + /* place code here to end the video */ } /***************************************************************************** @@ -497,7 +515,15 @@ int vout_Manage( vout_thread_t *p_vout ) p_win->resizeIfRequired(p_vout->p_buffer[p_vout->i_buffer_index].i_pic_width, p_vout->p_buffer[p_vout->i_buffer_index].i_pic_height); - return( 0 ); + return( 0 ); +} + +/***************************************************************************** + * vout_Render: render previously calculated output + *****************************************************************************/ +void vout_Render( vout_thread_t *p_vout, picture_t *p_pic ) +{ + ; } /***************************************************************************** @@ -506,17 +532,17 @@ int vout_Manage( vout_thread_t *p_vout ) * This function send the currently rendered image to BeOS image, waits until * it is displayed and switch the two rendering buffers, preparing next frame. *****************************************************************************/ -void vout_Display( vout_thread_t *p_vout ) +void vout_Display( vout_thread_t *p_vout, picture_t *p_pic ) { VideoWindow * p_win = p_vout->p_sys->p_window; /* draw buffer if required */ - if (!p_win->teardownwindow) - { + if (!p_win->teardownwindow) + { p_win->drawBuffer(p_vout->i_buffer_index); } /* change buffer */ - p_vout->i_buffer_index = ++p_vout->i_buffer_index & 1; + p_vout->i_buffer_index = ++p_vout->i_buffer_index & 1; } /* following functions are local */ @@ -541,16 +567,17 @@ static int BeosOpenDisplay( vout_thread_t *p_vout ) p_vout->p_sys->p_window = p_win; /* set the system to 32bits always let BeOS do all the work */ - p_vout->b_YCbr = false; + p_vout->p_sys->i_width = p_win->i_width + 1; + p_vout->p_sys->i_height = p_win->i_height + 1; +#if 0 p_vout->i_screen_depth = BITS_PER_PLANE; p_vout->i_bytes_per_pixel = BYTES_PER_PIXEL; - p_vout->i_width = p_win->i_width + 1; - p_vout->i_height = p_win->i_height + 1; - p_vout->i_bytes_per_line = p_vout->i_width * BYTES_PER_PIXEL; + p_vout->i_bytes_per_line = p_vout->p_sys->i_width * BYTES_PER_PIXEL; p_vout->i_red_mask = 0xff0000; p_vout->i_green_mask = 0x00ff00; p_vout->i_blue_mask = 0x0000ff; +#endif return( 0 ); } diff --git a/src/audio_output/aout_s16.c b/src/audio_output/aout_s16.c index 950e7df9a6..075a5e3ae0 100644 --- a/src/audio_output/aout_s16.c +++ b/src/audio_output/aout_s16.c @@ -133,7 +133,7 @@ static void S16StereoPlay( aout_thread_t * p_aout, aout_fifo_t * p_fifo ) } p_fifo->l_units -= p_aout->l_units; } - else + else /* p_fifo->l_units <= p_aout->l_units */ { /* p_aout->b_stereo == 1 */ while ( l_buffer < (p_fifo->l_units << 1) ) @@ -164,7 +164,7 @@ static void S16StereoPlay( aout_thread_t * p_aout, aout_fifo_t * p_fifo ) } p_fifo->l_units -= p_aout->l_units; } - else + else /* p_fifo->l_units <= p_aout->l_units */ { /* p_aout->b_stereo == 1 */ while ( l_buffer < (p_fifo->l_units << 1) ) @@ -216,10 +216,10 @@ static void S16StereoPlay( aout_thread_t * p_aout, aout_fifo_t * p_fifo ) p_fifo->l_units -= l_units; break; } - else + else /* p_fifo->l_units <= l_units */ { /* p_aout->b_stereo == 1 */ - l_buffer_limit = l_buffer + (p_fifo->l_units << 1); + l_buffer_limit = p_fifo->l_units << 1; while ( l_buffer < l_buffer_limit ) { @@ -287,10 +287,10 @@ static void S16StereoPlay( aout_thread_t * p_aout, aout_fifo_t * p_fifo ) p_fifo->l_units -= l_units; break; } - else + else /* p_fifo->l_units <= l_units */ { /* p_aout->b_stereo == 1 */ - l_buffer_limit = l_buffer + (p_fifo->l_units << 1); + l_buffer_limit = p_fifo->l_units << 1; while ( l_buffer < l_buffer_limit ) {