add lv2ui support
[goodguy/history.git] / cinelerra-5.1 / cinelerra / forkbase.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2009 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #ifndef __FORKBASE_H__
23 #define __FORKBASE_H__
24
25 #include "forkbase.inc"
26 #include "mutex.h"
27 #include "thread.h"
28
29 // Utility functions for all the forking classes
30
31 #include <stdint.h>
32
33 class ForkBase
34 {
35 public:
36         enum { EXIT_CODE=0x7fff };
37         typedef struct { int64_t token; int bytes; } token_bfr_t;
38
39         ForkBase();
40         virtual ~ForkBase();
41
42         int is_running();
43         int read_timeout(int ms, int fd, void *data, int bytes);
44         int read_parent(int ms);
45         int send_parent(int64_t value, const void *data, int bytes);
46         int read_child(int ms);
47         int send_child(int64_t value, const void *data, int bytes);
48
49         int done, pid;
50         ForkChild *child;
51
52         int child_fd;
53         int64_t child_token;
54         int child_bytes;
55         int child_allocated;
56         uint8_t *child_data;
57
58         int parent_fd;
59         int64_t parent_token;
60         int parent_bytes;
61         int parent_allocated;
62         uint8_t *parent_data;
63 };
64
65 class ForkChild : public ForkBase
66 {
67 public:
68         ForkChild();
69         virtual ~ForkChild();
70         virtual void run() = 0;
71         virtual int handle_child();
72         int child_iteration();
73 };
74
75 class ForkParent : public Thread, public ForkBase
76 {
77 public:
78         ForkParent();
79         virtual ~ForkParent();
80         virtual int handle_parent();
81         virtual ForkChild *new_fork() = 0;
82
83         void start_child();
84         void start();
85         void stop();
86         void run();
87         int parent_iteration();
88
89         Mutex *lock;
90 };
91
92 #endif