vout_beos.cpp 20.5 KB
Newer Older
1
2
3
/*****************************************************************************
 * vout_beos.cpp: beos video output display method
 *****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
4
 * Copyright (C) 2000, 2001 VideoLAN
5
 * $Id: vout_beos.cpp,v 1.46 2002/03/17 05:48:18 tcastley Exp $
6
 *
Sam Hocevar's avatar
   
Sam Hocevar committed
7
8
 * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
 *          Samuel Hocevar <sam@zoy.org>
Richard Shepherd's avatar
Richard Shepherd committed
9
 *          Tony Castley <tcastley@mail.powerup.com.au>
Sam Hocevar's avatar
   
Sam Hocevar committed
10
 *          Richard Shepherd <richard@rshepherd.demon.co.uk>
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <errno.h>                                                 /* ENOMEM */
#include <stdlib.h>                                                /* free() */
#include <stdio.h>
#include <string.h>                                            /* strerror() */
34
35
#include <InterfaceKit.h>
#include <DirectWindow.h>
36
#include <Application.h>
37
#include <Bitmap.h>
38
39
40

extern "C"
{
Sam Hocevar's avatar
   
Sam Hocevar committed
41
#include <videolan/vlc.h>
42
43
44
45

#include "video.h"
#include "video_output.h"

Sam Hocevar's avatar
   
Sam Hocevar committed
46
#include "interface.h"
47
48
}

Sam Hocevar's avatar
   
Sam Hocevar committed
49
#include "VideoWindow.h"
50

Sam Hocevar's avatar
   
Sam Hocevar committed
51
52
#define BITS_PER_PLANE  16
#define BYTES_PER_PIXEL 2
53
54

/*****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
55
 * vout_sys_t: BeOS video output method descriptor
56
57
 *****************************************************************************
 * This structure is part of the video output thread descriptor.
Sam Hocevar's avatar
   
Sam Hocevar committed
58
 * It describes the BeOS specific properties of an output thread.
59
60
61
 *****************************************************************************/
typedef struct vout_sys_s
{
Sam Hocevar's avatar
   
Sam Hocevar committed
62
    VideoWindow *  p_window;
Sam Hocevar's avatar
   
Sam Hocevar committed
63

Sam Hocevar's avatar
   
Sam Hocevar committed
64
65
    s32 i_width;
    s32 i_height;
Sam Hocevar's avatar
   
Sam Hocevar committed
66
67
68
69

    u8 *pp_buffer[2];
    int i_index;

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
} vout_sys_t;


/*****************************************************************************
 * beos_GetAppWindow : retrieve a BWindow pointer from the window name
 *****************************************************************************/
BWindow *beos_GetAppWindow(char *name)
{
    int32       index;
    BWindow     *window;
    
    for (index = 0 ; ; index++)
    {
        window = be_app->WindowAt(index);
        if (window == NULL)
            break;
86
        if (window->LockWithTimeout(20000) == B_OK)
87
88
89
90
91
92
93
94
95
96
97
98
        {
            if (strcmp(window->Name(), name) == 0)
            {
                window->Unlock();
                break;
            }
            window->Unlock();
        }
    }
    return window; 
}

99
/**************************************************************************** 
100
 * Modify Refresh : code to detect refresh changes 
Sam Hocevar's avatar
   
Sam Hocevar committed
101
 ****************************************************************************/ 
102
103
void waitForRefreshIfRequired(BScreen *screen)
{
104
105
106
    //rudolf: sync init: 
    display_mode disp_mode; 
    static uint32 refresh, oldrefresh = 0; 
107
    
108
109
110
111
112
113
114
115
    screen-> GetMode(&disp_mode); 
    refresh = 
         (disp_mode.timing.pixel_clock * 1000)/((disp_mode.timing.h_total)* 
         (disp_mode.timing.v_total)); 
    if (!(refresh == oldrefresh)) 
    { 
        oldrefresh = refresh; 
    } 
116
117
118
119
120
121
    //rudolf: sync: 
    if (refresh  < 61) 
    { 
        screen-> WaitForRetrace(22000);//set timeout for  < 45 Hz... 
    } 
}
122

123
124
125
126
127
128
129
/**************************************************************************** 
 * DrawingThread : thread that really does the drawing 
 ****************************************************************************/ 
int32 Draw(void *data) 
{ 
    static float out_top, out_left, out_height, out_width;
    BScreen *screen; 
130
    VideoWindow* p_win; 
131
132

    screen = new BScreen(); 
133
    p_win = (VideoWindow *) data; 
134

135
    if ( p_win-> voutWindow-> LockLooper() ) 
136
137
    {
        waitForRefreshIfRequired(screen); 
138
139
        if (p_win->resized)
        {
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
            p_win->resized = false;
            p_win-> view-> FillRect(p_win-> voutWindow-> Bounds());
            /* if the width is proportionally smaller */
            if (p_win->width_scale <= p_win->height_scale)
            {
                out_width = p_win->i_width * p_win->width_scale;
                out_height = p_win->i_height * p_win->width_scale;
                out_left = 0; 
                if (p_win-> is_zoomed)
                {
                   out_top = (screen-> Frame().Height() - out_height) / 2;
                }
                else
                {
                   out_top = (p_win->winSize.Height() - out_height) / 2;
                }
            }
            else   /* if the height is proportionally smaller */
            {
                out_width = p_win->i_width * p_win->height_scale;
                out_height = p_win->i_height * p_win->height_scale;
                out_top = 0;
                if (p_win-> is_zoomed)
                {
                   out_left = (screen-> Frame().Width() - out_width) / 2;
                } 
                else
                {
                   out_left = (p_win->winSize.Width() - out_width) /2;
                }
            }
        }  
        p_win-> view-> DrawBitmap( p_win-> bitmap[p_win-> i_buffer],  
                                 BRect(out_left, out_top,
                                       out_left + out_width, out_top + out_height) );  
        p_win-> voutWindow-> UnlockLooper(); 
176
177
    } 
    return B_OK; 
Sam Hocevar's avatar
   
Sam Hocevar committed
178
179
}

180
/*****************************************************************************
181
 * bitmapWindow : This is the bitmap window output
182
 *****************************************************************************/
183
184
bitmapWindow::bitmapWindow(BRect frame, VideoWindow *theOwner)
        : BWindow( frame, NULL, B_TITLED_WINDOW, 
185
                    B_NOT_CLOSABLE | B_NOT_MINIMIZABLE )
186
{
187
    owner = theOwner;
188
189
190
191
    owner->winSize = frame;
    owner->width_scale = frame.Width() / owner->i_width;
    owner->height_scale = frame.Height() / owner->i_height;
    owner->resized = true;
192
193
    SetTitle(VOUT_TITLE " (BBitmap output)");
}
194

195
196
197
bitmapWindow::~bitmapWindow()
{
}
Richard Shepherd's avatar
Richard Shepherd committed
198

199
200
void bitmapWindow::FrameResized( float width, float height )
{
201
202
203
    owner->winSize = Frame();
    owner->width_scale = width / owner->i_width;
    owner->height_scale = height / owner->i_height;
204
    owner->resized = true;
205
}
206

207
208
void bitmapWindow::Zoom(BPoint origin, float width, float height )
{
209
    if(owner-> is_zoomed)
Sam Hocevar's avatar
   
Sam Hocevar committed
210
    {
211
212
213
214
        MoveTo(owner->winSize.left, owner->winSize.top);
        ResizeTo(owner->winSize.IntegerWidth(), owner->winSize.IntegerHeight());
        owner->width_scale = owner->winSize.IntegerWidth() / owner->i_width;
        owner->height_scale = owner->winSize.IntegerHeight() / owner->i_height;
Sam Hocevar's avatar
   
Sam Hocevar committed
215
216
217
218
219
220
221
222
223
224
        be_app->ShowCursor();
    }
    else
    {
        BScreen *screen;
        screen = new BScreen(this);
        BRect rect = screen->Frame();
        delete screen;
        MoveTo(0,0);
        ResizeTo(rect.IntegerWidth(), rect.IntegerHeight());
225
226
        owner->width_scale = rect.IntegerWidth() / owner->i_width;
        owner->height_scale = rect.IntegerHeight() / owner->i_height;
Sam Hocevar's avatar
   
Sam Hocevar committed
227
228
        be_app->HideCursor();
    }
229
    owner-> is_zoomed = !owner-> is_zoomed;
230
    owner->resized = true;
231
232
}

233
234
235
236
237
/*****************************************************************************
 * directWindow : This is the bitmap window output
 *****************************************************************************/
directWindow::directWindow(BRect frame, VideoWindow *theOwner)
        : BDirectWindow( frame, NULL, B_TITLED_WINDOW, 
238
                    B_NOT_CLOSABLE | B_NOT_MINIMIZABLE )
239
{
240
    owner = theOwner;
241
242
243
244
    owner->winSize = frame;
    owner->width_scale = frame.Width() / owner->i_width;
    owner->height_scale = frame.Height() / owner->i_height;
    owner->resized = true;
245
246
    SetTitle(VOUT_TITLE " (DirectWindow output)");
}
Sam Hocevar's avatar
   
Sam Hocevar committed
247

248
249
250
directWindow::~directWindow()
{
}
Sam Hocevar's avatar
   
Sam Hocevar committed
251

252
253
254
void directWindow::DirectConnected(direct_buffer_info *info)
{
}
255

256
void directWindow::FrameResized( float width, float height )
Sam Hocevar's avatar
   
Sam Hocevar committed
257
{
258
259
260
    owner->winSize = Frame();
    owner->width_scale = width / owner->i_width;
    owner->height_scale = height / owner->i_height;
261
    owner->resized = true;
Sam Hocevar's avatar
   
Sam Hocevar committed
262
263
}

264
void directWindow::Zoom(BPoint origin, float width, float height )
Sam Hocevar's avatar
   
Sam Hocevar committed
265
{
266
    if(owner-> is_zoomed)
Sam Hocevar's avatar
   
Sam Hocevar committed
267
268
    {
        SetFullScreen(false);
269
270
271
272
        MoveTo(owner->winSize.left, owner->winSize.top);
        ResizeTo(owner->winSize.Width(), owner->winSize.Height());
        owner->width_scale = owner->winSize.Width() / owner->i_width;
        owner->height_scale = owner->winSize.Height() / owner->i_height;
Sam Hocevar's avatar
   
Sam Hocevar committed
273
274
275
276
        be_app->ShowCursor();
    }
    else
    {
277
        owner->winSize = Frame();
Sam Hocevar's avatar
   
Sam Hocevar committed
278
279
280
281
282
283
        SetFullScreen(true);
        BScreen *screen;
        screen = new BScreen(this);
        BRect rect = screen->Frame();
        delete screen;
        MoveTo(0,0);
284
285
286
        ResizeTo(rect.Width(), rect.Height());
        owner->width_scale = rect.Width() / owner->i_width;
        owner->height_scale = rect.Height() / owner->i_height;
Sam Hocevar's avatar
   
Sam Hocevar committed
287
288
        be_app->HideCursor();
    }
289
    owner-> is_zoomed = !owner-> is_zoomed;
290
    owner->resized = true;
Sam Hocevar's avatar
   
Sam Hocevar committed
291
292
}

293
/*****************************************************************************
294
 * VideoWindow constructor and destructor
295
 *****************************************************************************/
296
297
VideoWindow::VideoWindow( int width, int height, 
                          vout_thread_t *p_video_output )
298
{
299
300
301
    if ( BDirectWindow::SupportsWindowMode() )
    { 
        voutWindow = new directWindow( BRect( 80, 50, 
Sam Hocevar's avatar
   
Sam Hocevar committed
302
                                          80 + width, 50 + height ), this );
303
304
305
    }
    else
    {
Sam Hocevar's avatar
   
Sam Hocevar committed
306
307
308
        voutWindow = new bitmapWindow( BRect( 80, 50, 
                                          80 + width, 50 + height ), this );
    }
309

Sam Hocevar's avatar
   
Sam Hocevar committed
310
    /* set the VideoWindow variables */
311
    teardownwindow = false;
312
313
    is_zoomed = false;
    resized = true;
Sam Hocevar's avatar
   
Sam Hocevar committed
314
315
    
    /* create the view to do the display */
316
317
    view = new VLCView( voutWindow->Bounds() );
    voutWindow->AddChild(view);
318
    
Sam Hocevar's avatar
   
Sam Hocevar committed
319
320
    /* Bitmap mode overlay not available, set the system to 32bits
     * and let BeOS do all the work */
Sam Hocevar's avatar
   
Sam Hocevar committed
321
322
323
324
325
326
327
    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());

    i_width = bitmap[0]->Bounds().IntegerWidth();
    i_height = bitmap[0]->Bounds().IntegerHeight();
328
    
329
330
331
    winSize = voutWindow->Frame();
    width_scale = winSize.Width() / i_width;
    height_scale = winSize.Height() / i_height;
332
333
334
335
336
337
338
339

    voutWindow->Show();
}

VideoWindow::~VideoWindow()
{
    int32 result;

340
341
    teardownwindow = true;
    wait_for_thread(fDrawThreadID, &result);
342
343
344
345
    voutWindow->Hide();
    voutWindow->Sync();
    voutWindow->Lock();
    voutWindow->Quit();
Sam Hocevar's avatar
   
Sam Hocevar committed
346
347
    delete bitmap[0];
    delete bitmap[1];
348
349
350
}

void VideoWindow::drawBuffer(int bufferIndex)
351
{
Sam Hocevar's avatar
   
Sam Hocevar committed
352
353
354
355
    status_t status;
    
    i_buffer = bufferIndex; 
    
356
357
358
    fDrawThreadID = spawn_thread(Draw, "drawing_thread",
                    B_DISPLAY_PRIORITY, (void*) this);
    wait_for_thread(fDrawThreadID, &status);
359
360
}

Sam Hocevar's avatar
   
Sam Hocevar committed
361
362
363
364
365
/*****************************************************************************
 * VLCView::VLCView
 *****************************************************************************/
VLCView::VLCView(BRect bounds) : BView(bounds, "", B_FOLLOW_ALL, B_WILL_DRAW)
{
Sam Hocevar's avatar
   
Sam Hocevar committed
366
    SetViewColor(B_TRANSPARENT_32_BIT);
Sam Hocevar's avatar
   
Sam Hocevar committed
367
368
369
370
371
372
373
374
375
376
}

/*****************************************************************************
 * VLCView::~VLCView
 *****************************************************************************/
VLCView::~VLCView()
{
}

/*****************************************************************************
377
 * VLCVIew::MouseDown
Sam Hocevar's avatar
   
Sam Hocevar committed
378
379
380
 *****************************************************************************/
void VLCView::MouseDown(BPoint point)
{
Sam Hocevar's avatar
   
Sam Hocevar committed
381
382
    BWindow *win = Window();
    win->Zoom();
Sam Hocevar's avatar
   
Sam Hocevar committed
383
384
}

385
386
387
388
389
390
391
392
393
/*****************************************************************************
 * VLCVIew::Draw
 *****************************************************************************/
void VLCView::Draw(BRect updateRect) 
{
    FillRect(updateRect);
}


394
395
396
397
398
399
extern "C"
{

/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
Sam Hocevar's avatar
   
Sam Hocevar committed
400
401
402
403
404
405
406
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 * );
Sam Hocevar's avatar
   
Sam Hocevar committed
407
408
409
410
411
412
413
414

static int  BeosOpenDisplay ( vout_thread_t *p_vout );
static void BeosCloseDisplay( vout_thread_t *p_vout );

/*****************************************************************************
 * Functions exported as capabilities. They are declared as static so that
 * we don't pollute the namespace too much.
 *****************************************************************************/
Sam Hocevar's avatar
   
Sam Hocevar committed
415
void _M( vout_getfunctions )( function_list_t * p_function_list )
Sam Hocevar's avatar
   
Sam Hocevar committed
416
417
418
419
420
421
422
{
    p_function_list->functions.vout.pf_create     = vout_Create;
    p_function_list->functions.vout.pf_init       = vout_Init;
    p_function_list->functions.vout.pf_end        = vout_End;
    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;
Sam Hocevar's avatar
   
Sam Hocevar committed
423
    p_function_list->functions.vout.pf_render     = vout_Render;
Sam Hocevar's avatar
   
Sam Hocevar committed
424
425
}

426
/*****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
427
 * vout_Create: allocates BeOS video thread output method
428
 *****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
429
 * This function allocates and initializes a BeOS vout method.
430
 *****************************************************************************/
Sam Hocevar's avatar
   
Sam Hocevar committed
431
int vout_Create( vout_thread_t *p_vout )
432
433
434
435
436
{
    /* Allocate structure */
    p_vout->p_sys = (vout_sys_t*) malloc( sizeof( vout_sys_t ) );
    if( p_vout->p_sys == NULL )
    {
Sam Hocevar's avatar
   
Sam Hocevar committed
437
        intf_ErrMsg( "error: %s", strerror(ENOMEM) );
438
439
        return( 1 );
    }
Sam Hocevar's avatar
   
Sam Hocevar committed
440
441
442
443
444
445
446
447
448
449
450
451
452
453

    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;
    }
454
455
456
457
458

    return( 0 );
}

/*****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
459
 * vout_Init: initialize BeOS video thread output method
460
 *****************************************************************************/
Sam Hocevar's avatar
   
Sam Hocevar committed
461
int vout_Init( vout_thread_t *p_vout )
462
{
Sam Hocevar's avatar
   
Sam Hocevar committed
463
464
465
466
467
    int i_index;
    picture_t *p_pic;

    I_OUTPUTPICTURES = 0;

Sam Hocevar's avatar
   
Sam Hocevar committed
468
469
470
471
472
473
474
    /* Open and initialize device */
    if( BeosOpenDisplay( p_vout ) )
    {
        intf_ErrMsg("vout error: can't open display");
        return 0;
    }

475
476
477
    p_vout->p_sys->pp_buffer[0] = (u8*)p_vout->p_sys->p_window->bitmap[0]->Bits();
    p_vout->p_sys->pp_buffer[1] = (u8*)p_vout->p_sys->p_window->bitmap[1]->Bits();

Sam Hocevar's avatar
   
Sam Hocevar committed
478
479
480
    p_vout->output.i_width  = p_vout->p_sys->i_width;
    p_vout->output.i_height = p_vout->p_sys->i_height;
    p_vout->output.i_aspect = p_vout->p_sys->i_width
Sam Hocevar's avatar
   
Sam Hocevar committed
481
                               * VOUT_ASPECT_FACTOR / p_vout->p_sys->i_height;
Sam Hocevar's avatar
   
Sam Hocevar committed
482
483
    p_vout->output.i_chroma = FOURCC_RV32;

Sam Hocevar's avatar
   
Sam Hocevar committed
484
485
486
487
    p_vout->output.i_rmask  = 0x00ff0000;
    p_vout->output.i_gmask  = 0x0000ff00;
    p_vout->output.i_bmask  = 0x000000ff;

Sam Hocevar's avatar
   
Sam Hocevar committed
488
489
490
491
492
493
494
495
496
497
498
    p_pic = NULL;

    /* Find an empty picture slot */
    for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
    {
        if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
        {
            p_pic = p_vout->p_picture + i_index;
            break;
        }
    }
499

Sam Hocevar's avatar
   
Sam Hocevar committed
500
    if( p_pic == NULL )
Sam Hocevar's avatar
   
Sam Hocevar committed
501
    {
Sam Hocevar's avatar
   
Sam Hocevar committed
502
        return 0;
503
    }
Sam Hocevar's avatar
   
Sam Hocevar committed
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520

    p_vout->p_sys->i_index = 0;
    p_pic->p->p_pixels = p_vout->p_sys->pp_buffer[0];
    p_pic->p->i_pixel_bytes = 4;
    p_pic->p->i_lines = p_vout->p_sys->i_height;
    p_pic->p->b_margin = 0;
    p_pic->p->i_pitch = 4 * p_vout->p_sys->i_width;

    p_pic->i_planes = 1;

    p_pic->i_status = DESTROYED_PICTURE;
    p_pic->i_type   = DIRECT_PICTURE;

    PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;

    I_OUTPUTPICTURES++;

521
522
523
524
    return( 0 );
}

/*****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
525
 * vout_End: terminate BeOS video thread output method
526
 *****************************************************************************/
Sam Hocevar's avatar
   
Sam Hocevar committed
527
void vout_End( vout_thread_t *p_vout )
528
{
Sam Hocevar's avatar
   
Sam Hocevar committed
529
    BeosCloseDisplay( p_vout );
530
531
532
}

/*****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
533
 * vout_Destroy: destroy BeOS video thread output method
534
535
536
 *****************************************************************************
 * Terminate an output method created by DummyCreateOutputMethod
 *****************************************************************************/
Sam Hocevar's avatar
   
Sam Hocevar committed
537
void vout_Destroy( vout_thread_t *p_vout )
538
539
540
541
542
{
    free( p_vout->p_sys );
}

/*****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
543
 * vout_Manage: handle BeOS events
544
545
546
547
 *****************************************************************************
 * This function should be called regularly by video output thread. It manages
 * console events. It returns a non null value on error.
 *****************************************************************************/
Sam Hocevar's avatar
   
Sam Hocevar committed
548
int vout_Manage( vout_thread_t *p_vout )
549
{
550
                          
Sam Hocevar's avatar
   
Sam Hocevar committed
551
552
553
554
555
556
557
558
559
    return( 0 );
}

/*****************************************************************************
 * vout_Render: render previously calculated output
 *****************************************************************************/
void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
{
    ;
560
561
562
}

/*****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
563
 * vout_Display: displays previously rendered output
564
 *****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
565
 * This function send the currently rendered image to BeOS image, waits until
566
567
 * it is displayed and switch the two rendering buffers, preparing next frame.
 *****************************************************************************/
Sam Hocevar's avatar
   
Sam Hocevar committed
568
void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
569
570
{
    VideoWindow * p_win = p_vout->p_sys->p_window;
Sam Hocevar's avatar
   
Sam Hocevar committed
571

572
    /* draw buffer if required */    
Sam Hocevar's avatar
   
Sam Hocevar committed
573
574
    if (!p_win->teardownwindow)
    {
Sam Hocevar's avatar
   
Sam Hocevar committed
575
       p_win->drawBuffer(p_vout->p_sys->i_index);
576
    }
577
    /* change buffer */
Sam Hocevar's avatar
   
Sam Hocevar committed
578
579
    p_vout->p_sys->i_index = ++p_vout->p_sys->i_index & 1;
    p_pic->p->p_pixels = p_vout->p_sys->pp_buffer[p_vout->p_sys->i_index];
580
581
582
583
584
}

/* following functions are local */

/*****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
585
 * BeosOpenDisplay: open and initialize BeOS device
586
587
588
 *****************************************************************************/
static int BeosOpenDisplay( vout_thread_t *p_vout )
{ 
Sam Hocevar's avatar
   
Sam Hocevar committed
589
590
591
    p_vout->p_sys->p_window = new VideoWindow( p_vout->p_sys->i_width - 1,
                                               p_vout->p_sys->i_height - 1,
                                               p_vout );
592

Sam Hocevar's avatar
   
Sam Hocevar committed
593
    if( p_vout->p_sys->p_window == NULL )
594
    {
Sam Hocevar's avatar
   
Sam Hocevar committed
595
        intf_ErrMsg( "error: cannot allocate memory for VideoWindow" );
596
597
598
599
600
601
602
        return( 1 );
    }   
    
    return( 0 );
}

/*****************************************************************************
Sam Hocevar's avatar
   
Sam Hocevar committed
603
 * BeosDisplay: close and reset BeOS device
604
605
606
607
608
609
610
 *****************************************************************************
 * Returns all resources allocated by BeosOpenDisplay and restore the original
 * state of the device.
 *****************************************************************************/
static void BeosCloseDisplay( vout_thread_t *p_vout )
{    
    /* Destroy the video window */
611
    delete p_vout->p_sys->p_window;
612
613
614
}

} /* extern "C" */