Mercurial > mplayer.hg
annotate parser-mecmd.c @ 16805:50fb26acbcba
processing audio is sometimes essential for a/v sync, so 1000l to
whoever made rawvideo muxer disable audio!!
with this patch, audio is processed but simply thrown away by the
muxer. various 'error' conditions in rawvideo muxer are removed to
make it work. feel free to re-add them if they can be done without
breaking anything, but do not use printf !!!!
btw old behavior can be obtained by manually specifying -nosound.
author | rfelker |
---|---|
date | Wed, 19 Oct 2005 05:44:27 +0000 |
parents | feb16d0117c8 |
children | d631b3c09c53 |
rev | line source |
---|---|
8164 | 1 #include "config.h" |
2 | |
3 #include <stdio.h> | |
4 #include <stdlib.h> | |
5 #include <string.h> | |
6 #include <errno.h> | |
7 | |
8 #ifdef MP_DEBUG | |
9 #include <assert.h> | |
10 #endif | |
11 | |
12 #include "mp_msg.h" | |
13 #include "m_option.h" | |
14 #include "m_config.h" | |
15 #include "parser-mecmd.h" | |
16 | |
17 void | |
18 m_entry_list_free(m_entry_t* lst) { | |
19 int i,j; | |
20 | |
21 for(i = 0 ; lst[i].name != NULL ; i++){ | |
22 free(lst[i].name); | |
23 for(j = 0 ; lst[i].opts[2*j] != NULL ; j++) { | |
24 free(lst[i].opts[2*j]); | |
25 free(lst[i].opts[2*j+1]); | |
26 } | |
27 free(lst[i].opts); | |
28 } | |
29 free(lst); | |
30 } | |
31 | |
32 int | |
33 m_entry_set_options(m_config_t *config, m_entry_t* entry) { | |
34 int i,r; | |
35 | |
36 for(i = 0 ; entry->opts[2*i] != NULL ; i++){ | |
37 r = m_config_set_option(config,entry->opts[2*i],entry->opts[2*i+1]); | |
38 if(r < 0) | |
39 return 0; | |
40 } | |
41 return 1; | |
42 } | |
43 | |
44 | |
45 | |
46 | |
47 m_entry_t* | |
48 m_config_parse_me_command_line(m_config_t *config, int argc, char **argv) | |
49 { | |
50 int i,nf = 0,no = 0; | |
51 int tmp; | |
52 char *opt; | |
53 int no_more_opts = 0; | |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
54 int opt_exit = 0; |
8164 | 55 m_entry_t *lst = NULL, *entry = NULL; |
56 | |
57 #ifdef MP_DEBUG | |
58 assert(config != NULL); | |
59 assert(argv != NULL); | |
60 assert(argc >= 1); | |
61 #endif | |
62 | |
63 config->mode = M_COMMAND_LINE; | |
64 | |
65 lst = calloc(1,sizeof(m_entry_t)); | |
66 | |
67 for (i = 1; i < argc; i++) { | |
68 //next: | |
69 opt = argv[i]; | |
70 /* check for -- (no more options id.) except --help! */ | |
15245
4fdfe0860cc5
Make "mplayer -- --a" play the file --a instead of bailing out with a useless
reimar
parents:
14541
diff
changeset
|
71 if ((*opt == '-') && (*(opt+1) == '-') && (*(opt+2) == 0)) |
8164 | 72 { |
73 no_more_opts = 1; | |
74 if (i+1 >= argc) | |
75 { | |
14541 | 76 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "'--' indicates no more options, but no filename was given on the command line.\n"); |
8164 | 77 goto err_out; |
78 } | |
79 continue; | |
80 } | |
81 | |
82 if ((no_more_opts == 0) && (*opt == '-') && (*(opt+1) != 0)) /* option */ | |
83 { | |
84 m_option_t* mp_opt = NULL; | |
85 /* remove trailing '-' */ | |
86 opt++; | |
87 mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "this_opt = option: %s\n", opt); | |
88 mp_opt = m_config_get_option(config,opt); | |
89 if(!mp_opt) { | |
10595
522afd56703c
100l to albeu for his english grammar, and 10l to me becouse I noticed that lately (my backward compatibilty macro uses M_OPT_UNKNOWN)
alex
parents:
10594
diff
changeset
|
90 tmp = M_OPT_UNKNOWN; |
15742
55cbf0c204bc
when somebody specifies e.g. --loop, the message says that a -loop option
reimar
parents:
15245
diff
changeset
|
91 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "-%s is not an MEncoder option\n",opt); |
8164 | 92 goto err_out; |
93 } | |
8893 | 94 if(!entry || (mp_opt->flags & M_OPT_GLOBAL)){ |
8164 | 95 tmp = m_config_set_option(config, opt, argv[i + 1]); |
8893 | 96 if(tmp < 0){ |
97 // mp_msg(MSGT_CFGPARSER, MSGL_ERR, "m_config_set_option() failed (%d)\n",tmp); | |
98 goto err_out; | |
99 } | |
100 } else { | |
8164 | 101 tmp = m_config_check_option(config, opt, argv[i + 1]); |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
102 if (tmp <= M_OPT_EXIT) { |
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
103 opt_exit = 1; |
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
104 tmp = M_OPT_EXIT - tmp; |
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
105 } |
8164 | 106 if(tmp >= 0) { |
107 entry->opts = realloc(entry->opts,(no+2)*2*sizeof(char*)); | |
108 entry->opts[2*no] = strdup(opt); | |
109 entry->opts[2*no+1] = argv[i + 1] ? strdup(argv[i + 1]) : NULL; | |
110 entry->opts[2*no+2] = entry->opts[2*no+3] = NULL; | |
111 no++; | |
8893 | 112 } else { |
113 // mp_msg(MSGT_CFGPARSER, MSGL_ERR, "m_config_set_option() failed (%d)\n",tmp); | |
114 goto err_out; | |
8164 | 115 } |
116 } | |
117 i += tmp; | |
9747
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
118 } else {/* filename */ |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
119 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Adding file %s\n",argv[i]); |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
120 lst = realloc(lst,(nf+2)*sizeof(m_entry_t)); |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
121 lst[nf].name = strdup(argv[i]); |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
122 lst[nf].opts = calloc(2,sizeof(char*)); |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
123 entry = &lst[nf]; |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
124 no = 0; |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
125 memset(&lst[nf+1],0,sizeof(m_entry_t)); |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
126 nf++; |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
127 } |
8164 | 128 } |
129 | |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
130 if (opt_exit) |
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
131 exit(0); |
8164 | 132 if(nf == 0) { |
133 m_entry_list_free(lst); | |
134 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "No file given\n"); | |
135 return NULL; | |
136 } | |
137 return lst; | |
138 | |
139 err_out: | |
140 m_entry_list_free(lst); | |
141 return NULL; | |
142 } |