4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
26 #include "channel.inc"
27 #include "condition.inc"
32 #include "vdevicebase.h"
33 #include "vdevicebuz.inc"
37 #define INPUT_BUFFER_SIZE 0x40000
39 // Let's get real. The Buz driver doesn't work. If the buffers overflow
40 // for enough time it locks up and can't be recovered except by a
41 // SIGINT and restart. We need to cascade the buffer reading in another
42 // ring buffer thread, have it read continuously, and cancel it if it
43 // dies. How about if we do this in SCHED_RR and wait for it to die before
44 // implementing cancellation?
47 class VDeviceBUZInput : public Thread
50 VDeviceBUZInput(VDeviceBUZ *device);
54 void get_buffer(char **ptr, int *size);
56 void increment_counter(int *counter);
57 void decrement_counter(int *counter);
64 int current_outbuffer;
65 Condition *output_lock;
71 class VDeviceBUZ : public VDeviceBase
74 VDeviceBUZ(VideoDevice *device);
77 friend class VDeviceBUZInput;
82 int read_buffer(VFrame *frame);
83 int write_buffer(VFrame *frames, EDL *edl);
84 void reset_parameters();
85 ArrayList<int>* get_render_strategies();
86 int set_channel(Channel *channel);
87 int get_norm(int norm);
88 static void get_inputs(ArrayList<Channel*> *input_sources);
89 int set_picture(PictureConfig *picture);
90 int get_best_colormodel(int colormodel);
91 int create_channeldb(ArrayList<Channel*> *channeldb);
92 void new_output_buffer(VFrame *output, int colormodel);
96 int open_input_core(Channel *channel);
97 void close_input_core();
98 int open_output_core(Channel *channel);
99 int close_output_core();
102 char *input_buffer, *frame_buffer, *output_buffer;
103 long frame_size, frame_allocated;
106 ArrayList<int> render_strategies;
107 // Temporary frame for compressing output data
109 // Frame given to user to acquire data
113 VDeviceBUZInput *input_thread;
115 struct buz_params bparm;
116 struct buz_requestbuffers breq;
117 // Can't CSYNC the first loop
119 // Number of output frame to load