annotate libass/ass_library.c @ 21404:896a8210ed9f

Make sure we do not hang if no streams are available
author reimar
date Fri, 01 Dec 2006 18:51:44 +0000
parents 2edba6772316
children 7af6c25a0cfc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20477
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*-
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
2 // vim:ts=8:sw=8:noet:ai:
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
3 /*
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
4 Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
5
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
6 This program is free software; you can redistribute it and/or modify
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
8 the Free Software Foundation; either version 2 of the License, or
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
9 (at your option) any later version.
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
10
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
11 This program is distributed in the hope that it will be useful,
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
14 GNU General Public License for more details.
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
15
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
17 along with this program; if not, write to the Free Software
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
19 */
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
20
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
21 #include <inttypes.h>
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
22 #include <stdio.h>
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
23 #include <stdlib.h>
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
24 #include <string.h>
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
25
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
26 #include "ass.h"
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
27 #include "ass_library.h"
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
28
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
29
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
30 ass_library_t* ass_library_init(void)
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
31 {
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
32 return calloc(1, sizeof(ass_library_t));
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
33 }
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
34
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
35 void ass_library_done(ass_library_t* priv)
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
36 {
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
37 if (priv) free(priv);
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
38 }
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
39
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
40 void ass_set_fonts_dir(ass_library_t* priv, const char* fonts_dir)
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
41 {
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
42 if (priv->fonts_dir)
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
43 free(priv->fonts_dir);
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
44
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
45 priv->fonts_dir = fonts_dir ? strdup(fonts_dir) : 0;
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
46 }
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
47
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
48 void ass_set_extract_fonts(ass_library_t* priv, int extract)
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
49 {
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
50 priv->extract_fonts = !!extract;
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
51 }
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
52
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
53 void ass_set_style_overrides(ass_library_t* priv, char** list)
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
54 {
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
55 char** p;
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
56 char** q;
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
57 int cnt;
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
58
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
59 if (priv->style_overrides) {
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
60 for (p = priv->style_overrides; *p; ++p)
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
61 free(*p);
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
62 free(priv->style_overrides);
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
63 }
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
64
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
65 if (!list) return;
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
66
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
67 for (p = list, cnt = 0; *p; ++p, ++cnt) {}
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
68
20722
2edba6772316 Bugfix: when copying ass_force_style_list, ending 0 was left out.
eugeni
parents: 20477
diff changeset
69 priv->style_overrides = malloc((cnt + 1) * sizeof(char*));
20477
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
70 for (p = list, q = priv->style_overrides; *p; ++p, ++q)
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
71 *q = strdup(*p);
20722
2edba6772316 Bugfix: when copying ass_force_style_list, ending 0 was left out.
eugeni
parents: 20477
diff changeset
72 priv->style_overrides[cnt] = NULL;
20477
de4a66d99f41 Libass interface reworked:
eugeni
parents:
diff changeset
73 }