annotate libvo/vo_caca.c @ 33519:4d0f63ed8271

Remove a pointless "return".
author reimar
date Mon, 13 Jun 2011 19:33:17 +0000
parents ddb45e9443ec
children edee96cf6d71
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
1 /*
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
2 * video output driver for libcaca
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
3 *
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
4 * by Pigeon <pigeon@pigeond.net>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
5 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
6 * Some functions/codes/ideas are from x11 and aalib vo
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
7 *
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
8 * TODO: support draw_alpha?
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
9 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
10 * This file is part of MPlayer.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
11 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
12 * MPlayer is free software; you can redistribute it and/or modify
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
13 * it under the terms of the GNU General Public License as published by
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
15 * (at your option) any later version.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
16 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
17 * MPlayer is distributed in the hope that it will be useful,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
20 * GNU General Public License for more details.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
21 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
22 * You should have received a copy of the GNU General Public License along
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
23 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
25 */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
26
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
27 #include <stdio.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
28 #include <stdlib.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
29 #include <sys/stat.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
30 #include <unistd.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
31 #include <string.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
32 #include <time.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
33 #include <errno.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
34
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
35 #include "config.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
36 #include "video_out.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
37 #include "video_out_internal.h"
32467
fbe5c829c69b Move libvo/sub.[ch] from libvo to sub.
cigaes
parents: 32176
diff changeset
38 #include "sub/sub.h"
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
39
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
40 #include "osdep/keycodes.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
41 #include "mp_msg.h"
22823
98eaf29b5dee Code cleanup: don't include a .c file in mplayer.c and fix a few
rathann
parents: 21161
diff changeset
42 #include "mp_fifo.h"
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
43
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
44 #include <caca.h>
19979
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
45 #ifdef CACA_API_VERSION_1
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
46 /* Include the pre-1.x compatibility header.
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
47 * Once libcaca 1.x is widespread, vo_caca should be fully
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
48 * converted to the new API. A patch exists:
32176
597a376752a7 Update URL to patch for new API support.
diego
parents: 29263
diff changeset
49 * http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-July/044669.html
19979
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
50 */
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
51 #include <caca0.h>
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
52 #endif
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
53
25216
3aee342be929 Make vo info structs const
reimar
parents: 24046
diff changeset
54 static const vo_info_t info = {
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
55 "libcaca",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
56 "caca",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
57 "Pigeon <pigeon@pigeond.net>",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
58 ""
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
59 };
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
60
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
61 const LIBVO_EXTERN (caca)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
62
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
63 /* caca stuff */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
64 static struct caca_bitmap *cbitmap = NULL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
65
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
66 /* image infos */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
67 static int image_format;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
68 static int image_width;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
69 static int image_height;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
70
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
71 static int screen_w, screen_h;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
72
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
73 /* We want 24bpp always for now */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
74 static unsigned int bpp = 24;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
75 static unsigned int depth = 3;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
76 static unsigned int rmask = 0xff0000;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
77 static unsigned int gmask = 0x00ff00;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
78 static unsigned int bmask = 0x0000ff;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
79 static unsigned int amask = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
80
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
81 #define MESSAGE_SIZE 512
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
82 #define MESSAGE_DURATION 5
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
83
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
84 static time_t stoposd = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
85 static int showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
86 static char osdmessagetext[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
87 static char posbar[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
88
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
89 static int osdx = 0, osdy = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
90 static int posbary = 2;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
91
19053
75327b24e06f marks several string parameters as const, as they are not modified inside the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents: 16171
diff changeset
92 static void osdmessage(int duration, const char *fmt, ...)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
93 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
94 /*
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
95 * for outputting a centered string at the bottom
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
96 * of our window for a while
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
97 */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
98 va_list ar;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
99 char m[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
100
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
101 va_start(ar, fmt);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
102 vsprintf(m, fmt, ar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
103 va_end(ar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
104 strcpy(osdmessagetext, m);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
105
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
106 showosdmessage = 1;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
107 stoposd = time(NULL) + duration;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
108 osdx = (screen_w - strlen (osdmessagetext)) / 2;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
109 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
110 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
111
19053
75327b24e06f marks several string parameters as const, as they are not modified inside the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents: 16171
diff changeset
112 static void osdpercent(int duration, int min, int max, int val, const char *desc, const char *unit)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
113 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
114 /*
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
115 * prints a bar for setting values
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
116 */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
117 float step;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
118 int where, i;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
119
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
120 step = (float)screen_w / (float)(max - min);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
121 where = (val - min) * step;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
122 osdmessage (duration, "%s: %i%s", desc, val, unit);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
123 posbar[0] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
124 posbar[screen_w - 1] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
125
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
126 for (i = 0; i < screen_w; i++)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
127 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
128 if (i == where)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
129 posbar[i] = '#';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
130 else
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
131 posbar[i] = '-';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
132 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29212
diff changeset
133
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
134 if (where != 0)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
135 posbar[0] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
136
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
137 if (where != (screen_w - 1))
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
138 posbar[screen_w - 1] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
139
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
140 posbar[screen_w] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
141 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
142
29212
eda346733b8c Add missing 'void' to parameterless function declarations.
diego
parents: 28446
diff changeset
143 static int resize(void)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
144 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
145 screen_w = caca_get_width();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
146 screen_h = caca_get_height();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
147
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
148 if (cbitmap)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
149 caca_free_bitmap(cbitmap);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
150
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
151 cbitmap = caca_create_bitmap(bpp, image_width, image_height,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
152 depth * image_width, rmask, gmask, bmask,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
153 amask);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
154
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
155 if (!cbitmap)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
156 mp_msg(MSGT_VO, MSGL_FATAL, "vo_caca: caca_create_bitmap failed!\n");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
157
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
158 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
159 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
160
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
161 static int config(uint32_t width, uint32_t height, uint32_t d_width,
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 12129
diff changeset
162 uint32_t d_height, uint32_t flags, char *title, uint32_t format)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
163 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
164 image_height = height;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
165 image_width = width;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
166 image_format = format;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29212
diff changeset
167
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
168 showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
169 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
170
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
171 return resize ();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
172 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
173
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
174 static int draw_frame(uint8_t *src[])
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
175 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
176 caca_draw_bitmap(0, 0, screen_w, screen_h, cbitmap, src[0]);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
177 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
178 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
179
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
180 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
181 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
182 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
183 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
184
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
185 static void flip_page(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
186 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
187
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
188 if (showosdmessage)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
189 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
190 if (time(NULL) >= stoposd)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
191 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
192 showosdmessage = 0;
24032
144162149176 Fix likely mistake when using char*.
cehoyos
parents: 22823
diff changeset
193 if (*posbar)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
194 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
195 } else {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
196 caca_putstr(osdx, osdy, osdmessagetext);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29212
diff changeset
197
24032
144162149176 Fix likely mistake when using char*.
cehoyos
parents: 22823
diff changeset
198 if (*posbar)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
199 caca_putstr(0, posbary, posbar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
200 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
201 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
202
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
203 caca_refresh();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
204 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
205
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
206 static void check_events (void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
207 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
208 unsigned int cev;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
209
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
210 if ((cev = caca_get_event(CACA_EVENT_ANY)))
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
211 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
212 if (cev & CACA_EVENT_RESIZE)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
213 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
214 caca_refresh();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
215 resize();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
216 } else if (cev & CACA_EVENT_KEY_RELEASE)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
217 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
218 int key = (cev & 0x00ffffff);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
219 enum caca_feature cf;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
220
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
221 switch (key) {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
222 case 'd':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
223 case 'D':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
224 /* Toggle dithering method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
225 cf = 1 + caca_get_feature(CACA_DITHERING);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
226 if (cf > CACA_DITHERING_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
227 cf = CACA_DITHERING_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
228 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
229 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
230 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
231
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
232 case 'a':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
233 case 'A':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
234 /* Toggle antialiasing method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
235 cf = 1 + caca_get_feature(CACA_ANTIALIASING);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
236 if (cf > CACA_ANTIALIASING_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
237 cf = CACA_ANTIALIASING_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
238 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
239 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
240 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
241
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
242 case 'b':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
243 case 'B':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
244 /* Toggle background method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
245 cf = 1 + caca_get_feature(CACA_BACKGROUND);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
246 if (cf > CACA_BACKGROUND_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
247 cf = CACA_BACKGROUND_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
248 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
249 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
250 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
251
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
252 case CACA_KEY_UP:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
253 mplayer_put_key(KEY_UP);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
254 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
255 case CACA_KEY_DOWN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
256 mplayer_put_key(KEY_DOWN);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
257 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
258 case CACA_KEY_LEFT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
259 mplayer_put_key(KEY_LEFT);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
260 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
261 case CACA_KEY_RIGHT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
262 mplayer_put_key(KEY_RIGHT);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
263 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
264 case CACA_KEY_ESCAPE:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
265 mplayer_put_key(KEY_ESC);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
266 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
267 case CACA_KEY_PAGEUP:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
268 mplayer_put_key(KEY_PAGE_UP);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
269 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
270 case CACA_KEY_PAGEDOWN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
271 mplayer_put_key(KEY_PAGE_DOWN);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
272 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
273 case CACA_KEY_RETURN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
274 mplayer_put_key(KEY_ENTER);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
275 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
276 case CACA_KEY_HOME:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
277 mplayer_put_key(KEY_HOME);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
278 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
279 case CACA_KEY_END:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
280 mplayer_put_key(KEY_END);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
281 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
282 default:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
283 if (key <= 255)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
284 mplayer_put_key (key);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
285 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
286 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
287 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
288 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
289 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
290
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
291 static void uninit(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
292 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
293 caca_free_bitmap(cbitmap);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
294 cbitmap = NULL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
295 caca_end();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
296 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
297
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
298
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
299 static void draw_osd(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
300 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
301 if (vo_osd_progbar_type != -1)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
302 osdpercent(MESSAGE_DURATION, 0, 255,
24046
7e2808fb1807 Identifiers should not start with two underscores.
diego
parents: 24032
diff changeset
303 vo_osd_progbar_value, sub_osd_names[vo_osd_progbar_type],
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
304 "");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
305 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
306
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
307 static int preinit(const char *arg)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
308 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
309 if (arg)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
310 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
311 mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: Unknown subdevice: %s\n", arg);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
312 return ENOSYS;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
313 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
314
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
315 if (caca_init())
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
316 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
317 mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: failed to initialize\n");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
318 return ENOSYS;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
319 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
320
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
321 caca_set_window_title("MPlayer");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
322
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
323 /* Default libcaca features */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
324 caca_set_feature(CACA_ANTIALIASING_PREFILTER);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
325 caca_set_feature(CACA_DITHERING_RANDOM);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
326
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
327 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
328 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
329
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
330 static int query_format(uint32_t format)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
331 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
332 if (format == IMGFMT_BGR24)
21161
ad7747bce52d Make compilation depending on USE_OSD unconditional.
uau
parents: 19979
diff changeset
333 return VFCAP_OSD | VFCAP_CSP_SUPPORTED;
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
334
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
335 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
336 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
337
33305
ddb45e9443ec Remove the variable arguments from the libvo control() functions.
iive
parents: 32467
diff changeset
338 static int control(uint32_t request, void *data)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
339 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
340 switch(request)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
341 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
342 case VOCTRL_QUERY_FORMAT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
343 return query_format(*((uint32_t *)data));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
344 default:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
345 return VO_NOTIMPL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
346 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
347 }