annotate libvo/vo_bl.c @ 36920:40ad45360c8a

Replace old item 'potmeter' by new item 'pimage'. Recent versions of the X11/GTK GUI didn't allow to control a potmeter, because that didn't seem to make any sense. In order to get rid of the confusing potmeter that doesn't distinguish from a hpotmeter and in order to allow the more useful behaviour recent versions of the X11/GTK GUI have been utilized (and because we're still supporting item 'potmeter' for reasons of compatibility with old skins), introduce new item 'pimage' that reuses most of the current potmeter code. Additionally, remove remaining code and documentation of 'potmeter'.
author ib
date Mon, 17 Mar 2014 12:29:46 +0000
parents 3b2228019b6a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27509
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
1 /*
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
2 * playback using the Blinkenlights UDP protocol (and to files)
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
3 *
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
4 * UDP socket handling copied from bsender.c part of blib-0.6:
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
5 * http://sven.gimp.org/blinkenlights/
27509
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
6 * copyright (c) 2001-2001 The Blinkenlights Crew:
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
7 * Sven Neumann <sven@gimp.org>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
8 * Michael Natterer <mitch@gimp.org>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
9 * Daniel Mack <daniel@yoobay.net>
36537
3b2228019b6a vo_bl: update copyright header.
reimar
parents: 36536
diff changeset
10 * some patches: copyright (C) 2004,2014 Stefan Schuermans
3b2228019b6a vo_bl: update copyright header.
reimar
parents: 36536
diff changeset
11 * <stefan@blinkenarea.org>
27509
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
12 * other stuff: copyright (C) 2002 Rik Snel
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
13 *
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
14 * This file is part of MPlayer.
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
15 *
27509
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
16 * MPlayer is free software; you can redistribute it and/or modify
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
17 * it under the terms of the GNU General Public License as published by
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
18 * the Free Software Foundation; either version 2 of the License, or
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
19 * (at your option) any later version.
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
20 *
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
21 * MPlayer is distributed in the hope that it will be useful,
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
24 * GNU General Public License for more details.
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
25 *
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
26 * You should have received a copy of the GNU General Public License along
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
27 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
d97a607821f1 Replace casual GPL notices by proper license headers.
diego
parents: 27481
diff changeset
28 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
29 */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
30
33842
a4efd6c16f8a vo_bl: Move config.h #include to the top of the #include list.
diego
parents: 33412
diff changeset
31 #include "config.h"
a4efd6c16f8a vo_bl: Move config.h #include to the top of the #include list.
diego
parents: 33412
diff changeset
32
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
33 #include <stdio.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
34 #include <stdlib.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
35 #include <string.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
36 #include <unistd.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
37 #include <fcntl.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
38 #include <errno.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
39 #include <sys/stat.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
40 #include <sys/types.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
41 #include <sys/time.h>
33412
2a2e9b6551d8 configure: Convert HAVE_SYS_MMAN_H into a 0/1 definition.
diego
parents: 33305
diff changeset
42 #if HAVE_SYS_MMAN_H
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
43 #include <sys/mman.h>
26105
c99d53b76ee5 Wrap '#include <sys/mman.h>' in HAVE_SYS_MMAN_H.
diego
parents: 25675
diff changeset
44 #endif
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
45 #include <sys/ioctl.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
46
10281
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
47 #include <netdb.h>
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
48 #include <sys/socket.h>
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
49 #include <netinet/in.h>
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
50
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
51 #include "video_out.h"
36495
211cb1950419 vo_bl: Switch to modern VOCTRL_DRAW_IMAGE API.
reimar
parents: 36494
diff changeset
52 #define NO_DRAW_FRAME
211cb1950419 vo_bl: Switch to modern VOCTRL_DRAW_IMAGE API.
reimar
parents: 36494
diff changeset
53 #define NO_DRAW_SLICE
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
54 #include "video_out_internal.h"
13787
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 13000
diff changeset
55 #include "mp_msg.h"
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 13000
diff changeset
56 #include "m_option.h"
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
57 #include "fastmemcpy.h"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
58
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
59 static const vo_info_t info =
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
60 {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
61 "Blinkenlights driver: http://www.blinkenlights.de",
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
62 "bl",
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
63 "Rik Snel <snel@phys.uu.nl>",
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
64 ""
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
65 };
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
66
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
67 const LIBVO_EXTERN (bl)
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7326
diff changeset
68
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
69 /* General variables */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
70
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
71 static unsigned char *image = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
72 static unsigned char *tmp = NULL;
25521
5b70080c41d2 Remove unused static variables, fixes the warnings:
diego
parents: 25520
diff changeset
73 static int framenum;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
74 static char *bl_subdevice = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
75 static int prevpts = -1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
76
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
77 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
78 char *name; /* filename */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
79 FILE *fp;
15158
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
80 int header_written; /* if header was written already */
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
81 } bl_file_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
82
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
83 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
84 char *name; /* hostname */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
85 int port;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
86 int fd; /* file descriptor */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
87 } bl_host_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
88
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
89 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
90 char *name;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
91 int img_format;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
92
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
93 int channels;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
94 int width;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
95 int height;
36535
9bd54104cdee vo_bl: Fix bpc variable documentation.
reimar
parents: 36514
diff changeset
96 int bpc; /* bits per component: bpc = 8, channels = 3 => bpp = 24*/
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
97
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
98 /* file output functions */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
99 int (*init_file)(bl_file_t *file);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
100 void (*write_frame)(bl_file_t *file, unsigned char *i, int duration);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
101 void (*close_file)(bl_file_t *file);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
102
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
103 /* network output functions */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
104 int (*init_connection)(bl_host_t *host);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
105 void (*send_frame)(bl_host_t *host);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
106 void (*close_connection)(bl_host_t *host);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
107 } bl_properties_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
108
36498
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
109 static bl_properties_t *bl;
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
110 static bl_properties_t cur_bl;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
111
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
112 /* arbitrary limit because I am too lazy to do proper memory management */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
113 #define BL_MAX_FILES 16
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
114 #define BL_MAX_HOSTS 16
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
115 static bl_file_t bl_files[BL_MAX_FILES];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
116 static bl_host_t bl_hosts[BL_MAX_HOSTS];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
117 static int no_bl_files = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
118 static int no_bl_hosts = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
119
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
120 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
121 uint32_t magic;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
122 uint16_t height;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
123 uint16_t width;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
124 uint16_t channels;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
125 uint16_t maxval;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
126 unsigned char data[0];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
127 } bl_packet_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
128
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
129 static bl_packet_t *bl_packet = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
130 static int bl_size;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
131
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
132 /* bml output functions */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
133 static int bml_init(bl_file_t *f) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
134 f->fp = fopen(f->name, "w");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
135 if (!f->fp) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
136 mp_msg(MSGT_VO, MSGL_ERR, "bl: error opening %s\n", f->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
137 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
138 }
15158
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
139 f->header_written = 0;
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
140 return 0;
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
141 }
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
142
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
143 static void bml_write_frame(bl_file_t *f, unsigned char *i, int duration) {
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
144 int j, k;
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
145 if( ! f->header_written )
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
146 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
147 fprintf(f->fp,
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
148 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
149 "<blm width=\"%d\" height=\"%d\" bits=\"%d\" channels=\"%d\">\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
150 " <header>\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
151 " <title>Movie autogenerated by MPlayer</title>\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
152 " <url>http://www.mplayerhq.hu</url>\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
153 " </header>\n", bl->width, bl->height, bl->bpc, bl->channels);
15158
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
154 f->header_written = 1;
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
155 }
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
156 fprintf(f->fp, " <frame duration=\"%d\">\n", duration);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
157 for (j = 0; j < bl->height; j++) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
158 fprintf(f->fp, " <row>");
36513
fe7d63062afb vo_bl: consistently multiply by "channels".
reimar
parents: 36512
diff changeset
159 for (k = 0; k < bl->width * bl->channels; k++)
36514
855d2d796453 vo_bl: cosmetics, use more readable array indexing syntax.
reimar
parents: 36513
diff changeset
160 fprintf(f->fp, "%02x", i[j * bl->width * bl->channels + k]);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
161 fprintf(f->fp, "</row>\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
162 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
163 fprintf(f->fp, " </frame>\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
164 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
165
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
166 static void bml_close(bl_file_t *f) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
167 fprintf(f->fp, "</blm>\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
168 fclose(f->fp);
36502
13e0edb7a23d vo_bl: after close reset to NULL/-1.
reimar
parents: 36501
diff changeset
169 f->fp = NULL;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
170 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
171
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
172 /* Blinkenlights UDP protocol */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
173 static int udp_init(bl_host_t *h) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
174 struct sockaddr_in addr;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
175 struct hostent *dest;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
176
36501
d0234dff2dc4 vo_bl: move assignment to a place where it actuall has an effect.
reimar
parents: 36500
diff changeset
177 h->fd = -1;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
178 dest = gethostbyname(h->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
179 if (!dest) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
180 mp_msg(MSGT_VO, MSGL_ERR,
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
181 "unable to resolve host %s\n", h->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
182 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
183 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
184
28697
5b749a93fc89 Use memset to make sure all parts of struct sockaddr_in are always initialized.
reimar
parents: 27509
diff changeset
185 memset(&addr, 0, sizeof(addr));
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
186 addr.sin_family = AF_INET;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
187 addr.sin_port = htons(h->port);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
188
23458
973e53dc7df5 Do not use fast_memcpy for small size copy, esp. when the size is constant
reimar
parents: 23457
diff changeset
189 memcpy(&addr.sin_addr.s_addr, dest->h_addr_list[0], dest->h_length);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
190
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
191 h->fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
192 if (h->fd < 0) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
193 mp_msg(MSGT_VO, MSGL_ERR,
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
194 "couldn't create socket for %s\n", h->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
195 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
196 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
197 if (connect(h->fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
198 mp_msg(MSGT_VO, MSGL_ERR, "couldn't connect socket for %s\n",
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
199 h->name);
27481
03c589c49c6d Remove Windows-specific #ifdefs, the file does not compile on MinGW anyway.
diego
parents: 27474
diff changeset
200 close(h->fd);
36502
13e0edb7a23d vo_bl: after close reset to NULL/-1.
reimar
parents: 36501
diff changeset
201 h->fd = -1;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
202 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
203 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
204 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
205 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
206
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
207 static void udp_send(bl_host_t *h) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
208 if (send(h->fd, bl_packet, bl_size, 0) != bl_size)
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
209 mp_msg(MSGT_VO, MSGL_ERR, "unable to send to %s\n", h->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
210 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
211
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
212 static void udp_close(bl_host_t *h) {
27481
03c589c49c6d Remove Windows-specific #ifdefs, the file does not compile on MinGW anyway.
diego
parents: 27474
diff changeset
213 close(h->fd);
36502
13e0edb7a23d vo_bl: after close reset to NULL/-1.
reimar
parents: 36501
diff changeset
214 h->fd = -1;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
215 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
216
36536
a2bf6994df8c vo_bl: RGB output support.
reimar
parents: 36535
diff changeset
217 #define NO_BLS 4
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
218
36498
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
219 static const bl_properties_t bls[NO_BLS] = {
36496
cf65ac6b4842 Do not needlessly request chroma.
reimar
parents: 36495
diff changeset
220 { "hdl", IMGFMT_Y8, 1, 18, 8, 8,
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
221 &bml_init, &bml_write_frame, &bml_close,
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
222 &udp_init, &udp_send, &udp_close },
36496
cf65ac6b4842 Do not needlessly request chroma.
reimar
parents: 36495
diff changeset
223 { "arcade", IMGFMT_Y8, 1, 26, 20, 8,
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
224 &bml_init, &bml_write_frame, &bml_close,
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
225 &udp_init, &udp_send, &udp_close },
36496
cf65ac6b4842 Do not needlessly request chroma.
reimar
parents: 36495
diff changeset
226 { "grayscale", IMGFMT_Y8, 1, -1, -1, 8, /* use width and height of movie */
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
227 &bml_init, &bml_write_frame, &bml_close,
36536
a2bf6994df8c vo_bl: RGB output support.
reimar
parents: 36535
diff changeset
228 &udp_init, &udp_send, &udp_close },
a2bf6994df8c vo_bl: RGB output support.
reimar
parents: 36535
diff changeset
229 { "rgb", IMGFMT_RGB24, 3, -1, -1, 8, /* use width and height of movie */
a2bf6994df8c vo_bl: RGB output support.
reimar
parents: 36535
diff changeset
230 &bml_init, &bml_write_frame, &bml_close,
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
231 &udp_init, &udp_send, &udp_close } };
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
232
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
233 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: 15158
diff changeset
234 uint32_t d_height, uint32_t flags, char *title, uint32_t format)
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
235 {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
236 void * ptr;
36498
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
237 int reset_width = bl->width < 0;
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
238 int reset_height = bl->height < 0;
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
239
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
240 /* adapt size of Blinkenlights UDP stream to size of movie */
36509
eeb86b142fa7 vo_bl: minor simplification of size reinit case.
reimar
parents: 36508
diff changeset
241 if (reset_width) bl->width = width; /* use width of movie */
eeb86b142fa7 vo_bl: minor simplification of size reinit case.
reimar
parents: 36508
diff changeset
242 if (reset_height) bl->height = height; /* use height of movie */
eeb86b142fa7 vo_bl: minor simplification of size reinit case.
reimar
parents: 36508
diff changeset
243
36511
6e88ef2077a4 vo_bl: Simplify/avoid duplicating size calculations.
reimar
parents: 36510
diff changeset
244 bl_size = 12 + bl->width*bl->height*bl->channels;
6e88ef2077a4 vo_bl: Simplify/avoid duplicating size calculations.
reimar
parents: 36510
diff changeset
245
36510
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
246 /* check for maximum size of UDP packet */
36511
6e88ef2077a4 vo_bl: Simplify/avoid duplicating size calculations.
reimar
parents: 36510
diff changeset
247 if (bl_size > 65507) {
36510
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
248 mp_msg(MSGT_VO, MSGL_ERR, "bl: %dx%d-%d does not fit into an UDP packet\n",
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
249 bl->width, bl->height, bl->channels);
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
250 goto err_out;
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
251 }
36508
449868d26489 vo_bl: Do memory allocation only in one place.
reimar
parents: 36507
diff changeset
252
36510
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
253 /* resize or allocate frame and tmp buffers */
36512
8057935cd9e0 vo_bl: Simplify realloc + memset to calloc.
reimar
parents: 36511
diff changeset
254 free(bl_packet);
8057935cd9e0 vo_bl: Simplify realloc + memset to calloc.
reimar
parents: 36511
diff changeset
255 bl_packet = calloc(bl_size, 1); /* space for header and image data */
8057935cd9e0 vo_bl: Simplify realloc + memset to calloc.
reimar
parents: 36511
diff changeset
256 if (!bl_packet) {
36510
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
257 mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n");
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
258 goto err_out;
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
259 }
36512
8057935cd9e0 vo_bl: Simplify realloc + memset to calloc.
reimar
parents: 36511
diff changeset
260 image = ((unsigned char*)bl_packet + 12); /* pointer to image data */
36510
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
261
36511
6e88ef2077a4 vo_bl: Simplify/avoid duplicating size calculations.
reimar
parents: 36510
diff changeset
262 ptr = realloc(tmp, bl_size); /* space for image data only, could be slightly smaller */
36510
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
263 if (!ptr) {
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
264 mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n");
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
265 goto err_out;
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
266 }
18ee133ba2f5 vo_bl: cosmetics, reindent.
reimar
parents: 36509
diff changeset
267 tmp = ptr;
36508
449868d26489 vo_bl: Do memory allocation only in one place.
reimar
parents: 36507
diff changeset
268
449868d26489 vo_bl: Do memory allocation only in one place.
reimar
parents: 36507
diff changeset
269 bl_packet->magic = htonl(0x23542666);
449868d26489 vo_bl: Do memory allocation only in one place.
reimar
parents: 36507
diff changeset
270 bl_packet->width = htons(bl->width);
449868d26489 vo_bl: Do memory allocation only in one place.
reimar
parents: 36507
diff changeset
271 bl_packet->height = htons(bl->height);
449868d26489 vo_bl: Do memory allocation only in one place.
reimar
parents: 36507
diff changeset
272 bl_packet->channels = htons(bl->channels);
449868d26489 vo_bl: Do memory allocation only in one place.
reimar
parents: 36507
diff changeset
273 bl_packet->maxval = htons((1 << bl->bpc) - 1);
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
274
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
275 framenum = 0;
36536
a2bf6994df8c vo_bl: RGB output support.
reimar
parents: 36535
diff changeset
276 if (format != bl->img_format) {
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
277 mp_msg(MSGT_VO, MSGL_ERR, "vo_bl called with wrong format");
36498
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
278 goto err_out;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
279 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
280 if (width > bl->width) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
281 mp_msg(MSGT_VO, MSGL_ERR, "bl: width of movie too large %d > %d\n", width, bl->width);
36498
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
282 goto err_out;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
283 }
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
284 if (height > bl->height) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
285 mp_msg(MSGT_VO, MSGL_ERR, "bl: height of movie too large %d > %d\n", height, bl->height);
36498
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
286 goto err_out;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
287 }
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
288 mp_msg(MSGT_VO, MSGL_V, "vo_config bl called\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
289 return 0;
36498
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
290 err_out:
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
291 // undo changes that might make variables mismatch
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
292 // our actual allocations
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
293 if (reset_width) bl->width = -1;
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
294 if (reset_height) bl->height = -1;
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
295 return 1;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
296 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
297
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
298 static void draw_osd(void) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
299 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
300
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
301 static void flip_page (void) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
302 int i;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
303
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
304 if (prevpts >= 0) for (i = 0; i < no_bl_files; i++)
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
305 bl->write_frame(&bl_files[i], tmp, (vo_pts - prevpts)/90);
23457
a124f3abc1ec Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents: 22283
diff changeset
306 fast_memcpy(tmp, image, bl->width*bl->height*bl->channels);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
307 prevpts = vo_pts;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
308
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
309 for (i = 0; i < no_bl_hosts; i++) bl->send_frame(&bl_hosts[i]);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
310
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
311
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
312 framenum++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
313 return;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
314 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
315
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15952
diff changeset
316 static int query_format(uint32_t format) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
317 if (format == bl->img_format)
36495
211cb1950419 vo_bl: Switch to modern VOCTRL_DRAW_IMAGE API.
reimar
parents: 36494
diff changeset
318 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE|VOCAP_NOSLICES;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
319 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
320 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
321
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
322 static void uninit(void) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
323 int i;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
324 mp_msg(MSGT_VO, MSGL_V, "bl: uninit called\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
325 free(bl_packet);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
326 bl_packet = NULL;
36499
b83593ffdcfb vo_bl: Fix a memleak
reimar
parents: 36498
diff changeset
327 free(tmp);
b83593ffdcfb vo_bl: Fix a memleak
reimar
parents: 36498
diff changeset
328 tmp = NULL;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
329 free(bl_subdevice);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
330 bl_subdevice = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
331 for (i = 0; i < no_bl_files; i++) bl->close_file(&bl_files[i]);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
332 for (i = 0; i < no_bl_hosts; i++) bl->close_connection(&bl_hosts[i]);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
333 no_bl_files = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
334 no_bl_hosts = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
335 bl = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
336 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
337
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
338 static void check_events(void) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
339 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
340
36495
211cb1950419 vo_bl: Switch to modern VOCTRL_DRAW_IMAGE API.
reimar
parents: 36494
diff changeset
341 static uint32_t draw_image(mp_image_t *mpi) {
36513
fe7d63062afb vo_bl: consistently multiply by "channels".
reimar
parents: 36512
diff changeset
342 memcpy_pic(image, mpi->planes[0], mpi->w * bl->channels, mpi->h,
fe7d63062afb vo_bl: consistently multiply by "channels".
reimar
parents: 36512
diff changeset
343 bl->width * bl->channels, mpi->stride[0]);
36495
211cb1950419 vo_bl: Switch to modern VOCTRL_DRAW_IMAGE API.
reimar
parents: 36494
diff changeset
344 return VO_TRUE;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
345 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
346
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15952
diff changeset
347 static int preinit(const char *arg) {
36505
294261f7e1b5 vo_bl: Move variables into blocks that use them.
reimar
parents: 36504
diff changeset
348 char *p;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
349 int end = 0, i;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
350 if (!arg || strlen(arg) == 0) {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
351 mp_msg(MSGT_VO, MSGL_ERR, "bl: subdevice must be given, example: -vo bl:arcade:host=localhost:2323\n");
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
352 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
353 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
354
36500
21d4dd6f5996 vo_bl: Deobfuscate, use strdup.
reimar
parents: 36499
diff changeset
355 bl_subdevice = strdup(arg);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
356 if (!bl_subdevice) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
357 mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
358 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
359 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
360 p = bl_subdevice;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
361 mp_msg(MSGT_VO, MSGL_V, "bl: preinit called with %s\n", arg);
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
362 for (i = 0; i < NO_BLS; i++) {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
363 if (!strncmp(p, bls[i].name, strlen(bls[i].name)))
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
364 break;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
365 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
366 if (i >= NO_BLS) {
36505
294261f7e1b5 vo_bl: Move variables into blocks that use them.
reimar
parents: 36504
diff changeset
367 char txt[256];
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
368 txt[0] = 0;
36504
edc2020f7bf4 vo_bl: Use snprintf.
reimar
parents: 36503
diff changeset
369 for (i = 0; i < NO_BLS; i++) {
edc2020f7bf4 vo_bl: Use snprintf.
reimar
parents: 36503
diff changeset
370 int pos = strlen(txt);
edc2020f7bf4 vo_bl: Use snprintf.
reimar
parents: 36503
diff changeset
371 snprintf(txt + pos, sizeof(txt) - pos, "%s%s",
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
372 txt[0] == 0 ? "" : i == NO_BLS - 1 ? " or " : ", ", bls[i].name );
36504
edc2020f7bf4 vo_bl: Use snprintf.
reimar
parents: 36503
diff changeset
373 }
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
374 mp_msg(MSGT_VO, MSGL_ERR, "bl: subdevice must start with %s\nbl: i.e. -vo bl:arcade:host=localhost:2323\n", txt);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
375 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
376 }
36498
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
377 // Global data arrays should not be modified, otherwise behaviour
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
378 // becomes too confusing.
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
379 cur_bl = bls[i];
08051e43dfee vo_bl: Fix crashes on error.
reimar
parents: 36497
diff changeset
380 bl = &cur_bl;
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
381 p += strlen(bls[i].name);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
382 if (*p == '\0') {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
383 no_bl_hosts = 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
384 bl_hosts[0].name = "localhost";
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
385 bl_hosts[0].port = 2323;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
386 mp_msg(MSGT_VO, MSGL_V, "bl: no hosts/files specified, using localhost:2323\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
387 end = 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
388 } else if (*p != ':') {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
389 mp_msg(MSGT_VO, MSGL_ERR, "bl: syntax error in subdevice\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
390 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
391 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
392 p++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
393
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
394 while (!end) {
36505
294261f7e1b5 vo_bl: Move variables into blocks that use them.
reimar
parents: 36504
diff changeset
395 char *q = p + 5;
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
396 if (!strncmp(p, "file=", 5)) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
397 if (no_bl_files == BL_MAX_FILES) {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
398 mp_msg(MSGT_VO, MSGL_ERR, "bl: maximum number of files reached (%d)\n", BL_MAX_FILES);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
399 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
400 }
36507
faf406e38545 vo_bl: Simplify parser, reduce code duplication.
reimar
parents: 36506
diff changeset
401 p = q;
36506
0f2c90b69a12 vo_bl: Use strcspn
reimar
parents: 36505
diff changeset
402 q += strcspn(q, ",");
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
403 if (*q == '\0') end = 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
404 *q = '\0';
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
405 bl_files[no_bl_files].name = p;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
406 mp_msg(MSGT_VO, MSGL_V, "blfile[%d]: %s\n",
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
407 no_bl_files, p);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
408 no_bl_files++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
409 } else if (!strncmp(p, "host=", 5)) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
410 if (no_bl_hosts == BL_MAX_HOSTS) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
411 mp_msg(MSGT_VO, MSGL_ERR, "bl: maximum number of hosts reached (%d)\n", BL_MAX_HOSTS);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
412 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
413 }
36507
faf406e38545 vo_bl: Simplify parser, reduce code duplication.
reimar
parents: 36506
diff changeset
414 p = q;
36506
0f2c90b69a12 vo_bl: Use strcspn
reimar
parents: 36505
diff changeset
415 q += strcspn(q, ",:");
36507
faf406e38545 vo_bl: Simplify parser, reduce code duplication.
reimar
parents: 36506
diff changeset
416
faf406e38545 vo_bl: Simplify parser, reduce code duplication.
reimar
parents: 36506
diff changeset
417 bl_hosts[no_bl_hosts].port = 2323; // default port
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
418 if (*q == ':') {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
419 *q++ = '\0';
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
420 bl_hosts[no_bl_hosts].port = atoi(q);
36506
0f2c90b69a12 vo_bl: Use strcspn
reimar
parents: 36505
diff changeset
421 q += strcspn(q, ",");
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
422 }
36507
faf406e38545 vo_bl: Simplify parser, reduce code duplication.
reimar
parents: 36506
diff changeset
423
faf406e38545 vo_bl: Simplify parser, reduce code duplication.
reimar
parents: 36506
diff changeset
424 if (*q == '\0') end = 1;
faf406e38545 vo_bl: Simplify parser, reduce code duplication.
reimar
parents: 36506
diff changeset
425 *q = '\0';
faf406e38545 vo_bl: Simplify parser, reduce code duplication.
reimar
parents: 36506
diff changeset
426 bl_hosts[no_bl_hosts].name = p;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
427 mp_msg(MSGT_VO, MSGL_V,
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
428 "blhost[%d]: %s:%d\n",
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
429 no_bl_hosts, p,
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
430 bl_hosts[no_bl_hosts].port);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
431 no_bl_hosts++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
432 } else {
25675
fcac7e2a38fc fix bug in error message (found by Diego through a compiler warning)
rik
parents: 25521
diff changeset
433 mp_msg(MSGT_VO, MSGL_ERR, "bl: syntax error in entry %d in subdevice %s, should be a comma separated\nlist of host=name:port and file=foo.bml\n", no_bl_hosts + no_bl_files, arg);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
434 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
435 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
436 p = ++q;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
437 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
438
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
439 /* open all files */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
440 for (i = 0; i < no_bl_files; i++)
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
441 if (bl->init_file(&bl_files[i])) return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
442
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
443 /* open all sockets */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28697
diff changeset
444 for (i = 0; i < no_bl_hosts; i++)
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
445 if (bl->init_connection(&bl_hosts[i])) return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
446
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
447
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
448 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
449 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
450
33305
ddb45e9443ec Remove the variable arguments from the libvo control() functions.
iive
parents: 29263
diff changeset
451 static int control(uint32_t request, void *data) {
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
452 switch (request) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
453 case VOCTRL_QUERY_FORMAT:
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
454 return query_format(*((uint32_t*)data));
36495
211cb1950419 vo_bl: Switch to modern VOCTRL_DRAW_IMAGE API.
reimar
parents: 36494
diff changeset
455 case VOCTRL_DRAW_IMAGE:
211cb1950419 vo_bl: Switch to modern VOCTRL_DRAW_IMAGE API.
reimar
parents: 36494
diff changeset
456 return draw_image(data);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
457 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
458 return VO_NOTIMPL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
459 }