Commit 9d3b03de authored by Eric Petit's avatar Eric Petit

+ input/decoder.c: detach decoder after vout_Request(...,0,0,0,0)ing

     so AttachSPU can still reach p_input
 + src/video_output/*: init mouse variable before attaching p_vout so
     dvdnav can't add callbacks on those before there're created
 + beos/VideoOutput.cpp: removed tabs, sanity check
parent 2c6dfafb
......@@ -2,7 +2,7 @@
* vout_beos.cpp: beos video output display method
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: VideoOutput.cpp,v 1.29 2003/12/28 01:49:12 titer Exp $
* $Id$
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -51,7 +51,7 @@
#include <vlc/vout.h>
#include <vlc_keys.h>
#include "InterfaceWindow.h" // for load/save_settings()
#include "InterfaceWindow.h" // for load/save_settings()
#include "DrawingTidbits.h"
#include "MsgVals.h"
......@@ -76,8 +76,8 @@ struct vout_sys_t
};
#define MOUSE_IDLE_TIMEOUT 2000000 // two seconds
#define MIN_AUTO_VSYNC_REFRESH 61 // Hz
#define MOUSE_IDLE_TIMEOUT 2000000 // two seconds
#define MIN_AUTO_VSYNC_REFRESH 61 // Hz
#define DEFAULT_SCREEN_SHOT_FORMAT 'PNG '
#define DEFAULT_SCREEN_SHOT_PATH "/boot/home/vlc screenshot"
......@@ -167,42 +167,42 @@ static int ConvertKeyToVLC( int key )
BWindow*
get_interface_window()
{
return beos_GetAppWindow( "VLC " PACKAGE_VERSION );
return beos_GetAppWindow( "VLC " PACKAGE_VERSION );
}
class BackgroundView : public BView
{
public:
BackgroundView(BRect frame, VLCView* view)
: BView(frame, "background",
B_FOLLOW_ALL, B_FULL_UPDATE_ON_RESIZE),
fVideoView(view)
{
SetViewColor(kBlack);
}
virtual ~BackgroundView() {}
virtual void MouseDown(BPoint where)
{
// convert coordinates
where = fVideoView->ConvertFromParent(where);
// let him handle it
fVideoView->MouseDown(where);
}
virtual void MouseMoved(BPoint where, uint32_t transit,
const BMessage* dragMessage)
{
// convert coordinates
where = fVideoView->ConvertFromParent(where);
// let him handle it
fVideoView->MouseMoved(where, transit, dragMessage);
// notice: It might look like transit should be
// B_OUTSIDE_VIEW regardless, but leave it like this,
// otherwise, unwanted things will happen!
}
BackgroundView(BRect frame, VLCView* view)
: BView(frame, "background",
B_FOLLOW_ALL, B_FULL_UPDATE_ON_RESIZE),
fVideoView(view)
{
SetViewColor(kBlack);
}
virtual ~BackgroundView() {}
virtual void MouseDown(BPoint where)
{
// convert coordinates
where = fVideoView->ConvertFromParent(where);
// let him handle it
fVideoView->MouseDown(where);
}
virtual void MouseMoved(BPoint where, uint32_t transit,
const BMessage* dragMessage)
{
// convert coordinates
where = fVideoView->ConvertFromParent(where);
// let him handle it
fVideoView->MouseMoved(where, transit, dragMessage);
// notice: It might look like transit should be
// B_OUTSIDE_VIEW regardless, but leave it like this,
// otherwise, unwanted things will happen!
}
private:
VLCView* fVideoView;
VLCView* fVideoView;
};
......@@ -210,65 +210,65 @@ class BackgroundView : public BView
* VideoSettings constructor and destructor
*****************************************************************************/
VideoSettings::VideoSettings()
: fVideoSize( SIZE_100 ),
fFlags( FLAG_CORRECT_RATIO ),
fSettings( new BMessage( 'sett' ) )
: fVideoSize( SIZE_100 ),
fFlags( FLAG_CORRECT_RATIO ),
fSettings( new BMessage( 'sett' ) )
{
// read settings from disk
status_t ret = load_settings( fSettings, "video_settings", "VideoLAN Client" );
if ( ret == B_OK )
{
uint32_t flags;
if ( fSettings->FindInt32( "flags", (int32*)&flags ) == B_OK )
SetFlags( flags );
uint32_t size;
if ( fSettings->FindInt32( "video size", (int32*)&size ) == B_OK )
SetVideoSize( size );
}
else
{
// figure out if we should use vertical sync by default
BScreen screen(B_MAIN_SCREEN_ID);
if (screen.IsValid())
{
display_mode mode;
screen.GetMode(&mode);
float refresh = (mode.timing.pixel_clock * 1000)
/ ((mode.timing.h_total)* (mode.timing.v_total));
if (refresh < MIN_AUTO_VSYNC_REFRESH)
AddFlags(FLAG_SYNC_RETRACE);
}
}
// read settings from disk
status_t ret = load_settings( fSettings, "video_settings", "VideoLAN Client" );
if ( ret == B_OK )
{
uint32_t flags;
if ( fSettings->FindInt32( "flags", (int32*)&flags ) == B_OK )
SetFlags( flags );
uint32_t size;
if ( fSettings->FindInt32( "video size", (int32*)&size ) == B_OK )
SetVideoSize( size );
}
else
{
// figure out if we should use vertical sync by default
BScreen screen(B_MAIN_SCREEN_ID);
if (screen.IsValid())
{
display_mode mode;
screen.GetMode(&mode);
float refresh = (mode.timing.pixel_clock * 1000)
/ ((mode.timing.h_total)* (mode.timing.v_total));
if (refresh < MIN_AUTO_VSYNC_REFRESH)
AddFlags(FLAG_SYNC_RETRACE);
}
}
}
VideoSettings::VideoSettings( const VideoSettings& clone )
: fVideoSize( clone.VideoSize() ),
fFlags( clone.Flags() ),
fSettings( NULL )
: fVideoSize( clone.VideoSize() ),
fFlags( clone.Flags() ),
fSettings( NULL )
{
}
VideoSettings::~VideoSettings()
{
if ( fSettings )
{
// we are the default settings
// and write our settings to disk
if (fSettings->ReplaceInt32( "video size", VideoSize() ) != B_OK)
fSettings->AddInt32( "video size", VideoSize() );
if (fSettings->ReplaceInt32( "flags", Flags() ) != B_OK)
fSettings->AddInt32( "flags", Flags() );
save_settings( fSettings, "video_settings", "VideoLAN Client" );
delete fSettings;
}
else
{
// we are just a clone of the default settings
fDefaultSettings.SetVideoSize( VideoSize() );
fDefaultSettings.SetFlags( Flags() );
}
if ( fSettings )
{
// we are the default settings
// and write our settings to disk
if (fSettings->ReplaceInt32( "video size", VideoSize() ) != B_OK)
fSettings->AddInt32( "video size", VideoSize() );
if (fSettings->ReplaceInt32( "flags", Flags() ) != B_OK)
fSettings->AddInt32( "flags", Flags() );
save_settings( fSettings, "video_settings", "VideoLAN Client" );
delete fSettings;
}
else
{
// we are just a clone of the default settings
fDefaultSettings.SetVideoSize( VideoSize() );
fDefaultSettings.SetFlags( Flags() );
}
}
/*****************************************************************************
......@@ -277,7 +277,7 @@ VideoSettings::~VideoSettings()
VideoSettings*
VideoSettings::DefaultSettings()
{
return &fDefaultSettings;
return &fDefaultSettings;
}
/*****************************************************************************
......@@ -286,7 +286,7 @@ VideoSettings::DefaultSettings()
void
VideoSettings::SetVideoSize( uint32_t mode )
{
fVideoSize = mode;
fVideoSize = mode;
}
// static variable initialization
......@@ -299,35 +299,35 @@ VideoSettings::fDefaultSettings;
*****************************************************************************/
VideoWindow::VideoWindow(int v_width, int v_height, BRect frame,
vout_thread_t *p_videoout)
: BWindow(frame, NULL, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_MINIMIZABLE),
i_width(frame.IntegerWidth()),
i_height(frame.IntegerHeight()),
winSize(frame),
i_buffer(0),
teardownwindow(false),
fTrueWidth(v_width),
fTrueHeight(v_height),
fCachedFeel(B_NORMAL_WINDOW_FEEL),
fInterfaceShowing(false),
fInitStatus(B_ERROR),
fSettings(new VideoSettings(*VideoSettings::DefaultSettings()))
: BWindow(frame, NULL, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_MINIMIZABLE),
i_width(frame.IntegerWidth()),
i_height(frame.IntegerHeight()),
winSize(frame),
i_buffer(0),
teardownwindow(false),
fTrueWidth(v_width),
fTrueHeight(v_height),
fCachedFeel(B_NORMAL_WINDOW_FEEL),
fInterfaceShowing(false),
fInitStatus(B_ERROR),
fSettings(new VideoSettings(*VideoSettings::DefaultSettings()))
{
p_vout = p_videoout;
// create the view to do the display
view = new VLCView( Bounds(), p_vout );
// create background view
// create background view
BView *mainView = new BackgroundView( Bounds(), view );
AddChild(mainView);
mainView->AddChild(view);
// allocate bitmap buffers
for (int32_t i = 0; i < 3; i++)
bitmap[i] = NULL;
fInitStatus = _AllocateBuffers(v_width, v_height, &mode);
// allocate bitmap buffers
for (int32_t i = 0; i < 3; i++)
bitmap[i] = NULL;
fInitStatus = _AllocateBuffers(v_width, v_height, &mode);
// make sure we layout the view correctly
// make sure we layout the view correctly
FrameResized(i_width, i_height);
if (fInitStatus >= B_OK && mode == OVERLAY)
......@@ -339,9 +339,9 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame,
(i_height * r.min_height_scale), i_height * r.max_height_scale);
}
// vlc settings override settings from disk
if (config_GetInt(p_vout, "fullscreen"))
fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);
// vlc settings override settings from disk
if (config_GetInt(p_vout, "fullscreen"))
fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);
// add a few useful shortcuts
// XXX works only with US keymap
......@@ -359,7 +359,7 @@ VideoWindow::~VideoWindow()
teardownwindow = true;
wait_for_thread(fDrawThreadID, &result);
_FreeBuffers();
delete fSettings;
delete fSettings;
}
/*****************************************************************************
......@@ -368,90 +368,90 @@ VideoWindow::~VideoWindow()
void
VideoWindow::MessageReceived( BMessage *p_message )
{
switch( p_message->what )
{
case SHOW_INTERFACE:
SetInterfaceShowing( true );
break;
case TOGGLE_FULL_SCREEN:
BWindow::Zoom();
break;
case RESIZE_50:
case RESIZE_100:
case RESIZE_200:
if (IsFullScreen())
BWindow::Zoom();
_SetVideoSize(p_message->what);
break;
case VERT_SYNC:
SetSyncToRetrace(!IsSyncedToRetrace());
break;
case WINDOW_FEEL:
{
window_feel winFeel;
if (p_message->FindInt32("WinFeel", (int32*)&winFeel) == B_OK)
{
SetFeel(winFeel);
fCachedFeel = winFeel;
if (winFeel == B_FLOATING_ALL_WINDOW_FEEL)
fSettings->AddFlags(VideoSettings::FLAG_ON_TOP_ALL);
else
fSettings->ClearFlags(VideoSettings::FLAG_ON_TOP_ALL);
}
}
break;
case ASPECT_CORRECT:
SetCorrectAspectRatio(!CorrectAspectRatio());
break;
case SCREEN_SHOT:
// save a screen shot
if ( BBitmap* current = bitmap[i_buffer] )
{
switch( p_message->what )
{
case SHOW_INTERFACE:
SetInterfaceShowing( true );
break;
case TOGGLE_FULL_SCREEN:
BWindow::Zoom();
break;
case RESIZE_50:
case RESIZE_100:
case RESIZE_200:
if (IsFullScreen())
BWindow::Zoom();
_SetVideoSize(p_message->what);
break;
case VERT_SYNC:
SetSyncToRetrace(!IsSyncedToRetrace());
break;
case WINDOW_FEEL:
{
window_feel winFeel;
if (p_message->FindInt32("WinFeel", (int32*)&winFeel) == B_OK)
{
SetFeel(winFeel);
fCachedFeel = winFeel;
if (winFeel == B_FLOATING_ALL_WINDOW_FEEL)
fSettings->AddFlags(VideoSettings::FLAG_ON_TOP_ALL);
else
fSettings->ClearFlags(VideoSettings::FLAG_ON_TOP_ALL);
}
}
break;
case ASPECT_CORRECT:
SetCorrectAspectRatio(!CorrectAspectRatio());
break;
case SCREEN_SHOT:
// save a screen shot
if ( BBitmap* current = bitmap[i_buffer] )
{
// the following line might be tempting, but does not work for some overlay bitmaps!!!
// BBitmap* temp = new BBitmap( current );
// BBitmap* temp = new BBitmap( current );
// so we clone the bitmap ourselves
// however, we need to take care of potentially different padding!
// memcpy() is slow when reading from grafix memory, but what the heck...
BBitmap* temp = new BBitmap( current->Bounds(), current->ColorSpace() );
if ( temp && temp->IsValid() )
{
int32_t height = (int32_t)current->Bounds().Height();
uint8_t* dst = (uint8_t*)temp->Bits();
uint8_t* src = (uint8_t*)current->Bits();
int32_t dstBpr = temp->BytesPerRow();
int32_t srcBpr = current->BytesPerRow();
int32_t validBytes = dstBpr > srcBpr ? srcBpr : dstBpr;
for ( int32_t y = 0; y < height; y++ )
{
memcpy( dst, src, validBytes );
dst += dstBpr;
src += srcBpr;
}
char * path = config_GetPsz( p_vout, "beos-screenshotpath" );
if ( !path )
path = strdup( DEFAULT_SCREEN_SHOT_PATH );
/* FIXME - we should check which translators are
actually available */
char * psz_format = config_GetPsz( p_vout, "beos-screenshotformat" );
int32_t format = DEFAULT_SCREEN_SHOT_FORMAT;
if( !strcmp( psz_format, "TGA" ) )
format = 'TGA ';
else if( !strcmp( psz_format, "PPM" ) )
format = 'PPM ';
else if( !strcmp( psz_format, "JPEG" ) )
format = 'JPEG';
else if( !strcmp( psz_format, "BMP" ) )
format = 'BMP ';
_SaveScreenShot( temp, path, format );
}
else
{
delete temp;
}
}
break;
BBitmap* temp = new BBitmap( current->Bounds(), current->ColorSpace() );
if ( temp && temp->IsValid() )
{
int32_t height = (int32_t)current->Bounds().Height();
uint8_t* dst = (uint8_t*)temp->Bits();
uint8_t* src = (uint8_t*)current->Bits();
int32_t dstBpr = temp->BytesPerRow();
int32_t srcBpr = current->BytesPerRow();
int32_t validBytes = dstBpr > srcBpr ? srcBpr : dstBpr;
for ( int32_t y = 0; y < height; y++ )
{
memcpy( dst, src, validBytes );
dst += dstBpr;
src += srcBpr;
}
char * path = config_GetPsz( p_vout, "beos-screenshotpath" );
if ( !path )
path = strdup( DEFAULT_SCREEN_SHOT_PATH );
/* FIXME - we should check which translators are
actually available */
char * psz_format = config_GetPsz( p_vout, "beos-screenshotformat" );
int32_t format = DEFAULT_SCREEN_SHOT_FORMAT;
if( !strcmp( psz_format, "TGA" ) )
format = 'TGA ';
else if( !strcmp( psz_format, "PPM" ) )
format = 'PPM ';
else if( !strcmp( psz_format, "JPEG" ) )
format = 'JPEG';
else if( !strcmp( psz_format, "BMP" ) )
format = 'BMP ';
_SaveScreenShot( temp, path, format );
}
else
{
delete temp;
}
}
break;
case SHORTCUT:
{
vlc_value_t val;
......@@ -459,10 +459,10 @@ VideoWindow::MessageReceived( BMessage *p_message )
var_Set( p_vout->p_vlc, "key-pressed", val );
break;
}
default:
BWindow::MessageReceived( p_message );
break;
}
default:
BWindow::MessageReceived( p_message );
break;
}
}
/*****************************************************************************
......@@ -471,7 +471,7 @@ VideoWindow::MessageReceived( BMessage *p_message )
void
VideoWindow::Zoom(BPoint origin, float width, float height )
{
ToggleFullScreen();
ToggleFullScreen();
}
/*****************************************************************************
......@@ -480,9 +480,9 @@ VideoWindow::Zoom(BPoint origin, float width, float height )
void
VideoWindow::FrameMoved(BPoint origin)
{
if (IsFullScreen())
return ;
winSize = Frame();
if (IsFullScreen())
return ;
winSize = Frame();
}
/*****************************************************************************
......@@ -515,7 +515,7 @@ VideoWindow::FrameResized( float width, float height )
view->MoveTo(out_left,out_top);
view->ResizeTo(out_width, out_height);
if (!IsFullScreen())
if (!IsFullScreen())
winSize = Frame();
}
......@@ -525,12 +525,12 @@ VideoWindow::FrameResized( float width, float height )
void
VideoWindow::ScreenChanged(BRect frame, color_space format)
{
BScreen screen(this);
display_mode mode;
screen.GetMode(&mode);
float refresh = (mode.timing.pixel_clock * 1000)
/ ((mode.timing.h_total) * (mode.timing.v_total));
SetSyncToRetrace(refresh < MIN_AUTO_VSYNC_REFRESH);
BScreen screen(this);
display_mode mode;
screen.GetMode(&mode);
float refresh = (mode.timing.pixel_clock * 1000)
/ ((mode.timing.h_total) * (mode.timing.v_total));
SetSyncToRetrace(refresh < MIN_AUTO_VSYNC_REFRESH);
}
/*****************************************************************************
......@@ -565,10 +565,10 @@ VideoWindow::drawBuffer(int bufferIndex)
bitmap[i_buffer]->Bounds() ,
view->Bounds(),
&key, B_FOLLOW_ALL,
B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL|
B_OVERLAY_TRANSFER_CHANNEL);
view->SetViewColor(key);
}
B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL|
B_OVERLAY_TRANSFER_CHANNEL);
view->SetViewColor(key);
}
else
{
// switch the bitmap
......@@ -584,7 +584,7 @@ VideoWindow::drawBuffer(int bufferIndex)
void
VideoWindow::ToggleInterfaceShowing()
{
SetInterfaceShowing(!fInterfaceShowing);
SetInterfaceShowing(!fInterfaceShowing);
}
/*****************************************************************************
......@@ -593,24 +593,24 @@ VideoWindow::ToggleInterfaceShowing()
void
VideoWindow::SetInterfaceShowing(bool showIt)
{
BWindow* window = get_interface_window();
if (window)
{
if (showIt)
{
if (fCachedFeel != B_NORMAL_WINDOW_FEEL)
SetFeel(B_NORMAL_WINDOW_FEEL);
window->Activate(true);
SendBehind(window);
}
else
{
SetFeel(fCachedFeel);
Activate(true);
window->SendBehind(this);
}
fInterfaceShowing = showIt;
}
BWindow* window = get_interface_window();
if (window)
{
if (showIt)
{
if (fCachedFeel != B_NORMAL_WINDOW_FEEL)
SetFeel(B_NORMAL_WINDOW_FEEL);
window->Activate(true);
SendBehind(window);
}
else
{
SetFeel(fCachedFeel);
Activate(true);
window->SendBehind(this);
}
fInterfaceShowing = showIt;
}
}
/*****************************************************************************
......@@ -619,14 +619,14 @@ VideoWindow::SetInterfaceShowing(bool showIt)
void
VideoWindow::SetCorrectAspectRatio(bool doIt)
{
if (CorrectAspectRatio() != doIt)
{
if (doIt)