~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to libvo/vo_caca.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <string.h>
32
32
#include <time.h>
33
33
#include <errno.h>
 
34
#include <caca.h>
34
35
 
35
36
#include "config.h"
36
37
#include "video_out.h"
38
39
#include "sub/sub.h"
39
40
 
40
41
#include "osdep/keycodes.h"
 
42
#include "input/input.h"
 
43
#include "input/mouse.h"
41
44
#include "mp_msg.h"
42
45
#include "mp_fifo.h"
43
46
 
44
 
#include <caca.h>
45
 
#ifdef CACA_API_VERSION_1
46
 
  /* Include the pre-1.x compatibility header.
47
 
   * Once libcaca 1.x is widespread, vo_caca should be fully
48
 
   * converted to the new API. A patch exists:
49
 
   * http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-July/044669.html
50
 
   */
51
 
  #include <caca0.h>
52
 
#endif
53
 
 
54
47
static const vo_info_t info = {
55
 
  "libcaca",
56
 
  "caca",
57
 
  "Pigeon <pigeon@pigeond.net>",
58
 
  ""
 
48
    "libcaca",
 
49
    "caca",
 
50
    "Pigeon <pigeon@pigeond.net>",
 
51
    ""
59
52
};
60
53
 
61
 
const LIBVO_EXTERN (caca)
 
54
const LIBVO_EXTERN(caca)
62
55
 
63
56
/* caca stuff */
64
 
static struct caca_bitmap *cbitmap = NULL;
 
57
static caca_canvas_t  *canvas;
 
58
static caca_display_t *display;
 
59
static caca_dither_t  *dither           = NULL;
 
60
static const char     *dither_antialias = "default";
 
61
static const char     *dither_charset   = "default";
 
62
static const char     *dither_color     = "default";
 
63
static const char     *dither_algo      = "none";
65
64
 
66
65
/* image infos */
67
66
static int image_format;
71
70
static int screen_w, screen_h;
72
71
 
73
72
/* We want 24bpp always for now */
74
 
static unsigned int bpp = 24;
 
73
static unsigned int bpp   = 24;
75
74
static unsigned int depth = 3;
76
75
static unsigned int rmask = 0xff0000;
77
76
static unsigned int gmask = 0x00ff00;
78
77
static unsigned int bmask = 0x0000ff;
79
78
static unsigned int amask = 0;
80
79
 
81
 
#define MESSAGE_SIZE 512
82
 
#define MESSAGE_DURATION 5
 
80
#define MESSAGE_SIZE     512
 
81
#define MESSAGE_DURATION   5
83
82
 
84
 
static time_t stoposd = 0;
 
83
static time_t stoposd     = 0;
85
84
static int showosdmessage = 0;
86
85
static char osdmessagetext[MESSAGE_SIZE];
87
86
static char posbar[MESSAGE_SIZE];
91
90
 
92
91
static void osdmessage(int duration, const char *fmt, ...)
93
92
{
94
 
    /*
95
 
     * for outputting a centered string at the bottom
96
 
     * of our window for a while
97
 
     */
 
93
    /* for outputting a centered string at the window bottom for a while */
98
94
    va_list ar;
99
95
    char m[MESSAGE_SIZE];
100
96
 
104
100
    strcpy(osdmessagetext, m);
105
101
 
106
102
    showosdmessage = 1;
107
 
    stoposd = time(NULL) + duration;
108
 
    osdx = (screen_w - strlen (osdmessagetext)) / 2;
109
 
    posbar[0] = '\0';
 
103
    stoposd        = time(NULL) + duration;
 
104
    osdx           = (screen_w - strlen(osdmessagetext)) / 2;
 
105
    posbar[0]      = '\0';
110
106
}
111
107
 
112
 
static void osdpercent(int duration, int min, int max, int val, const char *desc, const char *unit)
 
108
static void osdpercent(int duration, int min, int max, int val,
 
109
                       const char *desc, const char *unit)
113
110
{
114
 
    /*
115
 
     * prints a bar for setting values
116
 
     */
 
111
    /* prints a bar for setting values */
117
112
    float step;
118
113
    int where, i;
119
114
 
120
 
    step = (float)screen_w / (float)(max - min);
 
115
    step  = (float)screen_w / (float)(max - min);
121
116
    where = (val - min) * step;
122
 
    osdmessage (duration, "%s: %i%s", desc, val, unit);
123
 
    posbar[0] = '|';
 
117
    osdmessage(duration, "%s: %i%s", desc, val, unit);
 
118
    posbar[0]            = '|';
124
119
    posbar[screen_w - 1] = '|';
125
120
 
126
 
    for (i = 0; i < screen_w; i++)
127
 
    {
128
 
        if (i == where)
129
 
            posbar[i] = '#';
130
 
        else
131
 
            posbar[i] = '-';
 
121
    for (i = 0; i < screen_w; i++) {
 
122
        if (i == where)
 
123
            posbar[i] = '#';
 
124
        else
 
125
            posbar[i] = '-';
132
126
    }
133
127
 
134
128
    if (where != 0)
135
 
        posbar[0] = '|';
 
129
        posbar[0] = '|';
136
130
 
137
131
    if (where != (screen_w - 1))
138
 
        posbar[screen_w - 1] = '|';
 
132
        posbar[screen_w - 1] = '|';
139
133
 
140
134
    posbar[screen_w] = '\0';
141
135
}
142
136
 
143
137
static int resize(void)
144
138
{
145
 
    screen_w = caca_get_width();
146
 
    screen_h = caca_get_height();
147
 
 
148
 
    if (cbitmap)
149
 
        caca_free_bitmap(cbitmap);
150
 
 
151
 
    cbitmap = caca_create_bitmap(bpp, image_width, image_height,
152
 
                                depth * image_width, rmask, gmask, bmask,
153
 
                                amask);
154
 
 
155
 
    if (!cbitmap)
156
 
        mp_msg(MSGT_VO, MSGL_FATAL, "vo_caca: caca_create_bitmap failed!\n");
 
139
    screen_w = caca_get_canvas_width(canvas);
 
140
    screen_h = caca_get_canvas_height(canvas);
 
141
 
 
142
    caca_free_dither(dither);
 
143
 
 
144
    dither = caca_create_dither(bpp, image_width, image_height,
 
145
                                depth * image_width,
 
146
                                rmask, gmask, bmask, amask);
 
147
    if (dither == NULL) {
 
148
        mp_msg(MSGT_VO, MSGL_FATAL, "vo_caca: caca_create_dither failed!\n");
 
149
        return ENOSYS;
 
150
    }
 
151
 
 
152
    /* Default libcaca features */
 
153
    caca_set_dither_antialias(dither, dither_antialias);
 
154
    caca_set_dither_charset(dither, dither_charset);
 
155
    caca_set_dither_color(dither, dither_color);
 
156
    caca_set_dither_algorithm(dither, dither_algo);
157
157
 
158
158
    return 0;
159
159
}
160
160
 
161
161
static int config(uint32_t width, uint32_t height, uint32_t d_width,
162
 
        uint32_t d_height, uint32_t flags, char *title, uint32_t format)
 
162
                  uint32_t d_height, uint32_t flags, char *title,
 
163
                  uint32_t format)
163
164
{
164
165
    image_height = height;
165
 
    image_width = width;
 
166
    image_width  = width;
166
167
    image_format = format;
167
168
 
168
169
    showosdmessage = 0;
169
 
    posbar[0] = '\0';
 
170
    posbar[0]      = '\0';
170
171
 
171
 
    return resize ();
 
172
    return resize();
172
173
}
173
174
 
174
175
static int draw_frame(uint8_t *src[])
175
176
{
176
 
    caca_draw_bitmap(0, 0, screen_w, screen_h, cbitmap, src[0]);
 
177
    caca_dither_bitmap(canvas, 0, 0, screen_w, screen_h, dither, src[0]);
177
178
    return 0;
178
179
}
179
180
 
184
185
 
185
186
static void flip_page(void)
186
187
{
187
 
 
188
 
    if (showosdmessage)
189
 
    {
190
 
        if (time(NULL) >= stoposd)
191
 
        {
192
 
            showosdmessage = 0;
193
 
            if (*posbar)
194
 
                posbar[0] = '\0';
195
 
        } else {
196
 
            caca_putstr(osdx, osdy, osdmessagetext);
197
 
 
198
 
            if (*posbar)
199
 
                caca_putstr(0, posbary, posbar);
200
 
        }
201
 
    }
202
 
 
203
 
    caca_refresh();
204
 
}
205
 
 
206
 
static void check_events (void)
207
 
{
208
 
    unsigned int cev;
209
 
 
210
 
    if ((cev = caca_get_event(CACA_EVENT_ANY)))
211
 
    {
212
 
        if (cev & CACA_EVENT_RESIZE)
213
 
        {
214
 
            caca_refresh();
215
 
            resize();
216
 
        } else if (cev & CACA_EVENT_KEY_RELEASE)
217
 
        {
218
 
            int key = (cev & 0x00ffffff);
219
 
            enum caca_feature cf;
220
 
 
221
 
            switch (key) {
222
 
            case 'd':
223
 
            case 'D':
224
 
              /* Toggle dithering method */
225
 
              cf = 1 + caca_get_feature(CACA_DITHERING);
226
 
              if (cf > CACA_DITHERING_MAX)
227
 
                  cf = CACA_DITHERING_MIN;
228
 
              caca_set_feature(cf);
229
 
              osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
230
 
              break;
231
 
 
232
 
            case 'a':
233
 
            case 'A':
234
 
              /* Toggle antialiasing method */
235
 
              cf = 1 + caca_get_feature(CACA_ANTIALIASING);
236
 
              if (cf > CACA_ANTIALIASING_MAX)
237
 
                  cf = CACA_ANTIALIASING_MIN;
238
 
              caca_set_feature(cf);
239
 
              osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
240
 
              break;
241
 
 
242
 
            case 'b':
243
 
            case 'B':
244
 
              /* Toggle background method */
245
 
              cf = 1 + caca_get_feature(CACA_BACKGROUND);
246
 
              if (cf > CACA_BACKGROUND_MAX)
247
 
                  cf = CACA_BACKGROUND_MIN;
248
 
              caca_set_feature(cf);
249
 
              osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
250
 
              break;
251
 
 
252
 
            case CACA_KEY_UP:
253
 
              mplayer_put_key(KEY_UP);
254
 
              break;
255
 
            case CACA_KEY_DOWN:
256
 
              mplayer_put_key(KEY_DOWN);
257
 
              break;
258
 
            case CACA_KEY_LEFT:
259
 
              mplayer_put_key(KEY_LEFT);
260
 
              break;
261
 
            case CACA_KEY_RIGHT:
262
 
              mplayer_put_key(KEY_RIGHT);
263
 
              break;
264
 
            case CACA_KEY_ESCAPE:
265
 
              mplayer_put_key(KEY_ESC);
266
 
              break;
267
 
            case CACA_KEY_PAGEUP:
268
 
              mplayer_put_key(KEY_PAGE_UP);
269
 
              break;
270
 
            case CACA_KEY_PAGEDOWN:
271
 
              mplayer_put_key(KEY_PAGE_DOWN);
272
 
              break;
273
 
            case CACA_KEY_RETURN:
274
 
              mplayer_put_key(KEY_ENTER);
275
 
              break;
276
 
            case CACA_KEY_HOME:
277
 
              mplayer_put_key(KEY_HOME);
278
 
              break;
279
 
            case CACA_KEY_END:
280
 
              mplayer_put_key(KEY_END);
281
 
              break;
282
 
            default:
283
 
              if (key <= 255)
284
 
                  mplayer_put_key (key);
285
 
              break;
286
 
            }
287
 
        }
 
188
    if (showosdmessage) {
 
189
        if (time(NULL) >= stoposd) {
 
190
            showosdmessage = 0;
 
191
            if (*posbar)
 
192
                posbar[0] = '\0';
 
193
        } else {
 
194
            caca_put_str(canvas, osdx, osdy, osdmessagetext);
 
195
            if (*posbar)
 
196
                caca_put_str(canvas, 0, posbary, posbar);
 
197
        }
 
198
    }
 
199
 
 
200
    caca_refresh_display(display);
 
201
}
 
202
 
 
203
static void set_next_str(const char * const *list, const char **str,
 
204
                         const char **msg)
 
205
{
 
206
    int ind;
 
207
    for (ind = 0; list[ind]; ind += 2) {
 
208
        if (strcmp(list[ind], *str) == 0) {
 
209
            if (list[ind + 2] == NULL)
 
210
                ind = -2;
 
211
            *str = list[ind + 2];
 
212
            *msg = list[ind + 3];
 
213
            return;
 
214
        }
 
215
    }
 
216
 
 
217
    *str = list[0];
 
218
    *msg = list[1];
 
219
}
 
220
 
 
221
static const struct mp_keymap keysym_map[] = {
 
222
    {CACA_KEY_RETURN, KEY_ENTER}, {CACA_KEY_ESCAPE, KEY_ESC},
 
223
    {CACA_KEY_UP, KEY_DOWN}, {CACA_KEY_DOWN, KEY_DOWN},
 
224
    {CACA_KEY_LEFT, KEY_LEFT}, {CACA_KEY_RIGHT, KEY_RIGHT},
 
225
    {CACA_KEY_PAGEUP, KEY_PAGE_UP}, {CACA_KEY_PAGEDOWN, KEY_PAGE_DOWN},
 
226
    {CACA_KEY_HOME, KEY_HOME}, {CACA_KEY_END, KEY_END},
 
227
    {CACA_KEY_INSERT, KEY_INSERT}, {CACA_KEY_DELETE, KEY_DELETE},
 
228
    {CACA_KEY_BACKSPACE, KEY_BACKSPACE}, {CACA_KEY_TAB, KEY_TAB},
 
229
    {CACA_KEY_PAUSE, KEY_PAUSE},
 
230
    {CACA_KEY_F1, KEY_F+1}, {CACA_KEY_F2, KEY_F+2},
 
231
    {CACA_KEY_F3, KEY_F+3}, {CACA_KEY_F4, KEY_F+4},
 
232
    {CACA_KEY_F5, KEY_F+5}, {CACA_KEY_F6, KEY_F+6},
 
233
    {CACA_KEY_F7, KEY_F+7}, {CACA_KEY_F8, KEY_F+8},
 
234
    {CACA_KEY_F9, KEY_F+9}, {CACA_KEY_F10, KEY_F+10},
 
235
    {CACA_KEY_F11, KEY_F+11}, {CACA_KEY_F12, KEY_F+12},
 
236
    {CACA_KEY_F13, KEY_F+13}, {CACA_KEY_F14, KEY_F+14},
 
237
    {CACA_KEY_F15, KEY_F+15},
 
238
    {0, 0}
 
239
};
 
240
 
 
241
static void check_events(void)
 
242
{
 
243
    caca_event_t cev;
 
244
    while (caca_get_event(display, CACA_EVENT_ANY, &cev, 0)) {
 
245
 
 
246
        switch (cev.type) {
 
247
        case CACA_EVENT_RESIZE:
 
248
            caca_refresh_display(display);
 
249
            resize();
 
250
            break;
 
251
        case CACA_EVENT_QUIT:
 
252
            mplayer_put_key(KEY_CLOSE_WIN);
 
253
            break;
 
254
        case CACA_EVENT_MOUSE_MOTION:
 
255
            vo_mouse_movement(cev.data.mouse.x, cev.data.mouse.y);
 
256
            break;
 
257
        case CACA_EVENT_MOUSE_PRESS:
 
258
            if (!vo_nomouse_input)
 
259
                mplayer_put_key((MOUSE_BTN0 + cev.data.mouse.button - 1) | MP_KEY_DOWN);
 
260
            break;
 
261
        case CACA_EVENT_MOUSE_RELEASE:
 
262
            if (!vo_nomouse_input)
 
263
                mplayer_put_key(MOUSE_BTN0 + cev.data.mouse.button - 1);
 
264
            break;
 
265
        case CACA_EVENT_KEY_PRESS:
 
266
        {
 
267
            int key = cev.data.key.ch;
 
268
            int mpkey = lookup_keymap_table(keysym_map, key);
 
269
            const char *msg_name;
 
270
 
 
271
            if (mpkey)
 
272
                mplayer_put_key(mpkey);
 
273
            else
 
274
            switch (key) {
 
275
            case 'd':
 
276
            case 'D':
 
277
                /* Toggle dithering algorithm */
 
278
                set_next_str(caca_get_dither_algorithm_list(dither), &dither_algo, &msg_name);
 
279
                caca_set_dither_algorithm(dither, dither_algo);
 
280
                osdmessage(MESSAGE_DURATION, "Using %s", msg_name);
 
281
                break;
 
282
 
 
283
            case 'a':
 
284
            case 'A':
 
285
                /* Toggle antialiasing method */
 
286
                set_next_str(caca_get_dither_antialias_list(dither), &dither_antialias, &msg_name);
 
287
                caca_set_dither_antialias(dither, dither_antialias);
 
288
                osdmessage(MESSAGE_DURATION, "Using %s", msg_name);
 
289
                break;
 
290
 
 
291
            case 'h':
 
292
            case 'H':
 
293
                /* Toggle charset method */
 
294
                set_next_str(caca_get_dither_charset_list(dither), &dither_charset, &msg_name);
 
295
                caca_set_dither_charset(dither, dither_charset);
 
296
                osdmessage(MESSAGE_DURATION, "Using %s", msg_name);
 
297
                break;
 
298
 
 
299
            case 'c':
 
300
            case 'C':
 
301
                /* Toggle color method */
 
302
                set_next_str(caca_get_dither_color_list(dither), &dither_color, &msg_name);
 
303
                caca_set_dither_color(dither, dither_color);
 
304
                osdmessage(MESSAGE_DURATION, "Using %s", msg_name);
 
305
                break;
 
306
 
 
307
            default:
 
308
                if (key <= 255)
 
309
                    mplayer_put_key(key);
 
310
                break;
 
311
            }
 
312
        }
 
313
        }
288
314
    }
289
315
}
290
316
 
291
317
static void uninit(void)
292
318
{
293
 
    caca_free_bitmap(cbitmap);
294
 
    cbitmap = NULL;
295
 
    caca_end();
 
319
    caca_free_dither(dither);
 
320
    dither = NULL;
 
321
    caca_free_display(display);
 
322
    caca_free_canvas(canvas);
296
323
}
297
324
 
298
325
 
299
326
static void draw_osd(void)
300
327
{
301
328
    if (vo_osd_progbar_type != -1)
302
 
        osdpercent(MESSAGE_DURATION, 0, 255,
303
 
                  vo_osd_progbar_value, sub_osd_names[vo_osd_progbar_type],
304
 
                  "");
 
329
        osdpercent(MESSAGE_DURATION, 0, 255, vo_osd_progbar_value,
 
330
                   sub_osd_names[vo_osd_progbar_type], "");
305
331
}
306
332
 
307
333
static int preinit(const char *arg)
308
334
{
309
 
    if (arg)
310
 
    {
311
 
        mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: Unknown subdevice: %s\n", arg);
312
 
        return ENOSYS;
313
 
    }
314
 
 
315
 
    if (caca_init())
316
 
    {
317
 
        mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: failed to initialize\n");
318
 
        return ENOSYS;
319
 
    }
320
 
 
321
 
    caca_set_window_title("MPlayer");
322
 
 
323
 
    /* Default libcaca features */
324
 
    caca_set_feature(CACA_ANTIALIASING_PREFILTER);
325
 
    caca_set_feature(CACA_DITHERING_RANDOM);
 
335
    if (arg) {
 
336
        mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: Unknown subdevice: %s\n", arg);
 
337
        return ENOSYS;
 
338
    }
 
339
 
 
340
    canvas = caca_create_canvas(0, 0);
 
341
    if (canvas == NULL) {
 
342
        mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: failed to create canvas\n");
 
343
        return ENOSYS;
 
344
    }
 
345
 
 
346
    display = caca_create_display(canvas);
 
347
 
 
348
    if (display == NULL) {
 
349
        mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: failed to create display\n");
 
350
        caca_free_canvas(canvas);
 
351
        return ENOSYS;
 
352
    }
 
353
 
 
354
    caca_set_display_title(display, "MPlayer");
326
355
 
327
356
    return 0;
328
357
}
330
359
static int query_format(uint32_t format)
331
360
{
332
361
    if (format == IMGFMT_BGR24)
333
 
      return VFCAP_OSD | VFCAP_CSP_SUPPORTED;
 
362
        return VFCAP_OSD | VFCAP_CSP_SUPPORTED;
334
363
 
335
364
    return 0;
336
365
}
337
366
 
338
367
static int control(uint32_t request, void *data)
339
368
{
340
 
    switch(request)
341
 
    {
 
369
    switch (request) {
342
370
    case VOCTRL_QUERY_FORMAT:
343
 
      return query_format(*((uint32_t *)data));
 
371
        return query_format(*((uint32_t *)data));
344
372
    default:
345
 
      return VO_NOTIMPL;
 
373
        return VO_NOTIMPL;
346
374
    }
347
375
}