annotate m_property.c @ 31434:d3db0dcba99f

Move dvd_device extern declaration from stream_dvd_common.h to stream.h. All the other variables from open.c are declared in stream.h.
author diego
date Mon, 21 Jun 2010 08:58:09 +0000
parents c1a3f1bbba26
children 6d08af681d54
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30429
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
1 /*
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
3 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
8 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
13 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
17 */
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17927
diff changeset
18
96568be4bfdc Doxygen attack!
albeu
parents: 17927
diff changeset
19 /// \file
96568be4bfdc Doxygen attack!
albeu
parents: 17927
diff changeset
20 /// \ingroup Properties
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
21
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
22 #include "config.h"
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
23
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
24 #include <stdlib.h>
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
25 #include <stdio.h>
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
26 #include <string.h>
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
27 #include <inttypes.h>
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
28 #include <unistd.h>
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
29
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
30 #include "m_option.h"
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
31 #include "m_property.h"
17914
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
32 #include "mp_msg.h"
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
33 #include "help_mp.h"
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
34
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
35 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
36
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
37 static int do_action(const m_option_t* prop_list, const char* name,
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
38 int action, void* arg, void *ctx) {
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
39 const char* sep;
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
40 const m_option_t* prop;
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
41 m_property_action_t ka;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
42 int r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
43 if((sep = strchr(name,'/')) && sep[1]) {
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
44 int len = sep-name;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
45 char base[len+1];
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
46 memcpy(base,name,len);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
47 base[len] = 0;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
48 prop = m_option_list_find(prop_list, base);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
49 ka.key = sep+1;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
50 ka.action = action;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
51 ka.arg = arg;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
52 action = M_PROPERTY_KEY_ACTION;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
53 arg = &ka;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
54 } else
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
55 prop = m_option_list_find(prop_list, name);
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
56 if(!prop) return M_PROPERTY_UNKNOWN;
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
57 r = ((m_property_ctrl_f)prop->p)(prop,action,arg,ctx);
23395
0ff039835f0f Fix fallback on the default GET_TYPE for unvailable/disabled
albeu
parents: 23394
diff changeset
58 if(action == M_PROPERTY_GET_TYPE && r < 0) {
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
59 if(!arg) return M_PROPERTY_ERROR;
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
60 *(const m_option_t**)arg = prop;
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
61 return M_PROPERTY_OK;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
62 }
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
63 return r;
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
64 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
65
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
66 int m_property_do(const m_option_t* prop_list, const char* name,
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
67 int action, void* arg, void *ctx) {
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
68 const m_option_t* opt;
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
69 void* val;
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
70 char* str;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
71 int r;
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
72
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
73 switch(action) {
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
74 case M_PROPERTY_PRINT:
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
75 if((r = do_action(prop_list,name,M_PROPERTY_PRINT,arg,ctx)) >= 0)
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
76 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
77 // fallback on the default print for this type
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
78 case M_PROPERTY_TO_STRING:
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
79 if((r = do_action(prop_list,name,M_PROPERTY_TO_STRING,arg,ctx)) !=
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
80 M_PROPERTY_NOT_IMPLEMENTED)
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
81 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
82 // fallback on the options API. Get the type, value and print.
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
83 if((r = do_action(prop_list,name,M_PROPERTY_GET_TYPE,&opt,ctx)) <= 0)
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
84 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
85 val = calloc(1,opt->type->size);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
86 if((r = do_action(prop_list,name,M_PROPERTY_GET,val,ctx)) <= 0) {
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
87 free(val);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
88 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
89 }
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
90 if(!arg) return M_PROPERTY_ERROR;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
91 str = m_option_print(opt,val);
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
92 free(val);
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
93 *(char**)arg = str == (char*)-1 ? NULL : str;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
94 return str != (char*)-1;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
95 case M_PROPERTY_PARSE:
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
96 // try the property own parsing func
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
97 if((r = do_action(prop_list,name,M_PROPERTY_PARSE,arg,ctx)) !=
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
98 M_PROPERTY_NOT_IMPLEMENTED)
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
99 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
100 // fallback on the options API, get the type and parse.
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
101 if((r = do_action(prop_list,name,M_PROPERTY_GET_TYPE,&opt,ctx)) <= 0)
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
102 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
103 if(!arg) return M_PROPERTY_ERROR;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
104 val = calloc(1,opt->type->size);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
105 if((r = m_option_parse(opt,opt->name,arg,val,M_CONFIG_FILE)) <= 0) {
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
106 free(val);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
107 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
108 }
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
109 r = do_action(prop_list,name,M_PROPERTY_SET,val,ctx);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
110 m_option_free(opt,val);
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
111 free(val);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
112 return r;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
113 }
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
114 return do_action(prop_list,name,action,arg,ctx);
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
115 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
116
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
117 char* m_properties_expand_string(const m_option_t* prop_list,char* str, void *ctx) {
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
118 int l,fr=0,pos=0,size=strlen(str)+512;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
119 char *p = NULL,*e,*ret = malloc(size), num_val;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
120 int skip = 0, lvl = 0, skip_lvl = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
121
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
122 while(str[0]) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
123 if(str[0] == '\\') {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
124 int sl = 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
125 switch(str[1]) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
126 case 'e':
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
127 p = "\x1b", l = 1; break;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
128 case 'n':
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
129 p = "\n", l = 1; break;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
130 case 'r':
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
131 p = "\r", l = 1; break;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
132 case 't':
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
133 p = "\t", l = 1; break;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
134 case 'x':
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
135 if(str[2]) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
136 char num[3] = { str[2], str[3], 0 };
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
137 char* end = num;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
138 num_val = strtol(num,&end,16);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
139 sl = end-num;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
140 l = 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
141 p = &num_val;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
142 } else
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
143 l = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
144 break;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
145 default:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
146 p = str+1, l = 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
147 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
148 str+=1+sl;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
149 } else if(lvl > 0 && str[0] == ')') {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
150 if(skip && lvl <= skip_lvl) skip = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
151 lvl--, str++, l = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
152 } else if(str[0] == '$' && str[1] == '{' && (e = strchr(str+2,'}'))) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
153 int pl = e-str-2;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
154 char pname[pl+1];
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
155 memcpy(pname,str+2,pl);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
156 pname[pl] = 0;
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
157 if(m_property_do(prop_list, pname,
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
158 M_PROPERTY_PRINT, &p, ctx) >= 0 && p)
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
159 l = strlen(p), fr = 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
160 else
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
161 l = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
162 str = e+1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
163 } else if(str[0] == '?' && str[1] == '(' && (e = strchr(str+2,':'))) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
164 lvl++;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
165 if(!skip) {
25501
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
166 int is_not = str[2] == '!';
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
167 int pl = e - str - (is_not ? 3 : 2);
25460
3086b6d39052 Move two variable to the scope where they are indeed used.
ulion
parents: 23416
diff changeset
168 char pname[pl+1];
25501
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
169 memcpy(pname, str + (is_not ? 3 : 2), pl);
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
170 pname[pl] = 0;
25501
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
171 if(m_property_do(prop_list,pname,M_PROPERTY_GET,NULL,ctx) < 0) {
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
172 if (!is_not)
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
173 skip = 1, skip_lvl = lvl;
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
174 }
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
175 else if (is_not)
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
176 skip = 1, skip_lvl = lvl;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
177 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
178 str = e+1, l = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
179 } else
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
180 p = str, l = 1, str++;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
181
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
182 if(skip || l <= 0) continue;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
183
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
184 if(pos+l+1 > size) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
185 size = pos+l+512;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
186 ret = realloc(ret,size);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
187 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
188 memcpy(ret+pos,p,l);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
189 pos += l;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
190 if(fr) free(p), fr = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
191 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
192
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
193 ret[pos] = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
194 return ret;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
195 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
196
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
197 void m_properties_print_help_list(const m_option_t* list) {
17914
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
198 char min[50],max[50];
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
199 int i,count = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
200
17914
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
201 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_PropertyListHeader);
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
202 for(i = 0 ; list[i].name ; i++) {
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
203 const m_option_t* opt = &list[i];
17914
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
204 if(opt->flags & M_OPT_MIN)
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
205 sprintf(min,"%-8.0f",opt->min);
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
206 else
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
207 strcpy(min,"No");
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
208 if(opt->flags & M_OPT_MAX)
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
209 sprintf(max,"%-8.0f",opt->max);
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
210 else
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
211 strcpy(max,"No");
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
212 mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %-20.20s %-15.15s %-10.10s %-10.10s\n",
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
213 opt->name,
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
214 opt->type->name,
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
215 min,
17927
3787f29f0b20 100L too many arguments to mp_msg().
albeu
parents: 17914
diff changeset
216 max);
17914
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
217 count++;
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
218 }
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
219 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_TotalProperties, count);
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
220 }
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
221
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
222 // Some generic property implementations
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
223
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
224 int m_property_int_ro(const m_option_t* prop,int action,
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
225 void* arg,int var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
226 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
227 case M_PROPERTY_GET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
228 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
229 *(int*)arg = var;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
230 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
231 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
232 return M_PROPERTY_NOT_IMPLEMENTED;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
233 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
234
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
235 int m_property_int_range(const m_option_t* prop,int action,
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
236 void* arg,int* var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
237 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
238 case M_PROPERTY_SET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
239 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
240 M_PROPERTY_CLAMP(prop,*(int*)arg);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
241 *var = *(int*)arg;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
242 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
243 case M_PROPERTY_STEP_UP:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
244 case M_PROPERTY_STEP_DOWN:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
245 *var += (arg ? *(int*)arg : 1) *
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
246 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
247 M_PROPERTY_CLAMP(prop,*var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
248 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
249 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
250 return m_property_int_ro(prop,action,arg,*var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
251 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
252
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
253 int m_property_choice(const m_option_t* prop,int action,
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
254 void* arg,int* var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
255 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
256 case M_PROPERTY_STEP_UP:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
257 case M_PROPERTY_STEP_DOWN:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
258 *var += action == M_PROPERTY_STEP_UP ? 1 : prop->max;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
259 *var %= (int)prop->max+1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
260 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
261 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
262 return m_property_int_range(prop,action,arg,var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
263 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
264
27647
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
265 int m_property_flag_ro(const m_option_t* prop,int action,
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
266 void* arg,int var) {
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
267 switch(action) {
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
268 case M_PROPERTY_PRINT:
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
269 if(!arg) return 0;
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
270 *(char**)arg = strdup((var > prop->min) ? MSGTR_Enabled : MSGTR_Disabled);
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
271 return 1;
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
272 }
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
273 return m_property_int_ro(prop,action,arg,var);
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
274 }
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
275
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
276 int m_property_flag(const m_option_t* prop,int action,
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
277 void* arg,int* var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
278 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
279 case M_PROPERTY_STEP_UP:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
280 case M_PROPERTY_STEP_DOWN:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
281 *var = *var == prop->min ? prop->max : prop->min;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
282 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
283 case M_PROPERTY_PRINT:
27647
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
284 return m_property_flag_ro(prop, action, arg, *var);
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
285 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
286 return m_property_int_range(prop,action,arg,var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
287 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
288
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
289 int m_property_float_ro(const m_option_t* prop,int action,
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
290 void* arg,float var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
291 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
292 case M_PROPERTY_GET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
293 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
294 *(float*)arg = var;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
295 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
296 case M_PROPERTY_PRINT:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
297 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
298 *(char**)arg = malloc(20);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
299 sprintf(*(char**)arg,"%.2f",var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
300 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
301 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
302 return M_PROPERTY_NOT_IMPLEMENTED;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
303 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
304
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
305 int m_property_float_range(const m_option_t* prop,int action,
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
306 void* arg,float* var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
307 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
308 case M_PROPERTY_SET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
309 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
310 M_PROPERTY_CLAMP(prop,*(float*)arg);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
311 *var = *(float*)arg;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
312 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
313 case M_PROPERTY_STEP_UP:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
314 case M_PROPERTY_STEP_DOWN:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
315 *var += (arg ? *(float*)arg : 0.1) *
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
316 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
317 M_PROPERTY_CLAMP(prop,*var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
318 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
319 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
320 return m_property_float_ro(prop,action,arg,*var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
321 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
322
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
323 int m_property_delay(const m_option_t* prop,int action,
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
324 void* arg,float* var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
325 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
326 case M_PROPERTY_PRINT:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
327 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
328 *(char**)arg = malloc(20);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
329 sprintf(*(char**)arg,"%d ms",ROUND((*var)*1000));
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
330 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
331 default:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
332 return m_property_float_range(prop,action,arg,var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
333 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
334 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
335
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
336 int m_property_double_ro(const m_option_t* prop,int action,
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
337 void* arg,double var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
338 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
339 case M_PROPERTY_GET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
340 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
341 *(double*)arg = var;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
342 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
343 case M_PROPERTY_PRINT:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
344 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
345 *(char**)arg = malloc(20);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
346 sprintf(*(char**)arg,"%.2f",var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
347 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
348 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
349 return M_PROPERTY_NOT_IMPLEMENTED;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
350 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
351
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
352 int m_property_time_ro(const m_option_t* prop,int action,
23416
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
353 void* arg,double var) {
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
354 switch(action) {
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
355 case M_PROPERTY_PRINT:
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
356 if (!arg)
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
357 return M_PROPERTY_ERROR;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
358 else {
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
359 int h, m, s = var;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
360 h = s / 3600;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
361 s -= h * 3600;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
362 m = s / 60;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
363 s -= m * 60;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
364 *(char **) arg = malloc(20);
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
365 if (h > 0)
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
366 sprintf(*(char **) arg, "%d:%02d:%02d", h, m, s);
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
367 else if (m > 0)
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
368 sprintf(*(char **) arg, "%d:%02d", m, s);
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
369 else
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
370 sprintf(*(char **) arg, "%d", s);
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
371 return M_PROPERTY_OK;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
372 }
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
373 }
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
374 return m_property_double_ro(prop,action,arg,var);
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
375 }
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
376
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
377 int m_property_string_ro(const m_option_t* prop,int action,void* arg,char* str) {
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
378 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
379 case M_PROPERTY_GET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
380 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
381 *(char**)arg = str;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
382 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
383 case M_PROPERTY_PRINT:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
384 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
385 *(char**)arg = str ? strdup(str) : NULL;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
386 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
387 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
388 return M_PROPERTY_NOT_IMPLEMENTED;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
389 }
23394
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
390
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
391 int m_property_bitrate(const m_option_t* prop,int action,void* arg,int rate) {
23394
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
392 switch(action) {
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
393 case M_PROPERTY_PRINT:
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
394 if (!arg)
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
395 return M_PROPERTY_ERROR;
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
396 *(char**)arg = malloc (16);
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
397 sprintf(*(char**)arg, "%d kbps", rate*8/1000);
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
398 return M_PROPERTY_OK;
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
399 }
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
400 return m_property_int_ro(prop, action, arg, rate);
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
401 }