annotate m_property.c @ 29904:f529a2bb299d

Add support for Windows OpenGL rendering onto a device instead of into a window. Has little use except for experimenting - on Windows 9x it could be used to render on monitors that were not managed by Windows, but that feature was removed in newer Windows versions.
author reimar
date Sat, 21 Nov 2009 22:27:40 +0000
parents 0f1b5b68af32
children c1a3f1bbba26
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17927
diff changeset
1
96568be4bfdc Doxygen attack!
albeu
parents: 17927
diff changeset
2 /// \file
96568be4bfdc Doxygen attack!
albeu
parents: 17927
diff changeset
3 /// \ingroup Properties
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
4
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
5 #include "config.h"
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
6
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
7 #include <stdlib.h>
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
8 #include <stdio.h>
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
9 #include <string.h>
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
10 #include <inttypes.h>
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
11 #include <unistd.h>
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
12
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
13 #include "m_option.h"
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
14 #include "m_property.h"
17914
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
15 #include "mp_msg.h"
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
16 #include "help_mp.h"
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
17
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
18 #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
19
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
20 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
21 int action, void* arg, void *ctx) {
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
22 const char* sep;
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
23 const m_option_t* prop;
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
24 m_property_action_t ka;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
25 int r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
26 if((sep = strchr(name,'/')) && sep[1]) {
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
27 int len = sep-name;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
28 char base[len+1];
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
29 memcpy(base,name,len);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
30 base[len] = 0;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
31 prop = m_option_list_find(prop_list, base);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
32 ka.key = sep+1;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
33 ka.action = action;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
34 ka.arg = arg;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
35 action = M_PROPERTY_KEY_ACTION;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
36 arg = &ka;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
37 } else
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
38 prop = m_option_list_find(prop_list, name);
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
39 if(!prop) return M_PROPERTY_UNKNOWN;
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
40 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
41 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
42 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
43 *(const m_option_t**)arg = prop;
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
44 return M_PROPERTY_OK;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
45 }
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
46 return r;
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
47 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
48
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
49 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
50 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
51 const m_option_t* opt;
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
52 void* val;
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
53 char* str;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
54 int r;
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
55
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
56 switch(action) {
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
57 case M_PROPERTY_PRINT:
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
58 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
59 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
60 // fallback on the default print for this type
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
61 case M_PROPERTY_TO_STRING:
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
62 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
63 M_PROPERTY_NOT_IMPLEMENTED)
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
64 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
65 // 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
66 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
67 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
68 val = calloc(1,opt->type->size);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
69 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
70 free(val);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
71 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
72 }
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
73 if(!arg) return M_PROPERTY_ERROR;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
74 str = m_option_print(opt,val);
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
75 free(val);
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
76 *(char**)arg = str == (char*)-1 ? NULL : str;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
77 return str != (char*)-1;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
78 case M_PROPERTY_PARSE:
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
79 // try the property own parsing func
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
80 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
81 M_PROPERTY_NOT_IMPLEMENTED)
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
82 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
83 // 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
84 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
85 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
86 if(!arg) return M_PROPERTY_ERROR;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
87 val = calloc(1,opt->type->size);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
88 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
89 free(val);
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
90 return r;
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
91 }
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
92 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
93 m_option_free(opt,val);
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
94 free(val);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
95 return r;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
96 }
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
97 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
98 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
99
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
100 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
101 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
102 char *p = NULL,*e,*ret = malloc(size), num_val;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
103 int skip = 0, lvl = 0, skip_lvl = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
104
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
105 while(str[0]) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
106 if(str[0] == '\\') {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
107 int sl = 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
108 switch(str[1]) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
109 case 'e':
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
110 p = "\x1b", l = 1; break;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
111 case 'n':
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
112 p = "\n", l = 1; break;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
113 case 'r':
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
114 p = "\r", l = 1; break;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
115 case 't':
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
116 p = "\t", l = 1; break;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
117 case 'x':
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
118 if(str[2]) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
119 char num[3] = { str[2], str[3], 0 };
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
120 char* end = num;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
121 num_val = strtol(num,&end,16);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
122 sl = end-num;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
123 l = 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
124 p = &num_val;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
125 } else
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
126 l = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
127 break;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
128 default:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
129 p = str+1, l = 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
130 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
131 str+=1+sl;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
132 } else if(lvl > 0 && str[0] == ')') {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
133 if(skip && lvl <= skip_lvl) skip = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
134 lvl--, str++, l = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
135 } 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
136 int pl = e-str-2;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
137 char pname[pl+1];
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
138 memcpy(pname,str+2,pl);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
139 pname[pl] = 0;
23393
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
140 if(m_property_do(prop_list, pname,
a5e55cb59bbc Rework the property API to allow sub properties such as
albeu
parents: 22280
diff changeset
141 M_PROPERTY_PRINT, &p, ctx) >= 0 && p)
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
142 l = strlen(p), fr = 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
143 else
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
144 l = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
145 str = e+1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
146 } 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
147 lvl++;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
148 if(!skip) {
25501
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
149 int is_not = str[2] == '!';
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
150 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
151 char pname[pl+1];
25501
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
152 memcpy(pname, str + (is_not ? 3 : 2), pl);
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
153 pname[pl] = 0;
25501
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
154 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
155 if (!is_not)
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
156 skip = 1, skip_lvl = lvl;
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
157 }
26a839637972 Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents: 25460
diff changeset
158 else if (is_not)
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
159 skip = 1, skip_lvl = lvl;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
160 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
161 str = e+1, l = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
162 } else
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
163 p = str, l = 1, str++;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
164
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
165 if(skip || l <= 0) continue;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
166
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
167 if(pos+l+1 > size) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
168 size = pos+l+512;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
169 ret = realloc(ret,size);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
170 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
171 memcpy(ret+pos,p,l);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
172 pos += l;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
173 if(fr) free(p), fr = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
174 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
175
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
176 ret[pos] = 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
177 return ret;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
178 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
179
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
180 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
181 char min[50],max[50];
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
182 int i,count = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27647
diff changeset
183
17914
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
184 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_PropertyListHeader);
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
185 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
186 const m_option_t* opt = &list[i];
17914
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
187 if(opt->flags & M_OPT_MIN)
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
188 sprintf(min,"%-8.0f",opt->min);
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
189 else
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
190 strcpy(min,"No");
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
191 if(opt->flags & M_OPT_MAX)
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
192 sprintf(max,"%-8.0f",opt->max);
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
193 else
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
194 strcpy(max,"No");
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
195 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
196 opt->name,
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
197 opt->type->name,
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
198 min,
17927
3787f29f0b20 100L too many arguments to mp_msg().
albeu
parents: 17914
diff changeset
199 max);
17914
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
200 count++;
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
201 }
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
202 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_TotalProperties, count);
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
203 }
f9cb6fc1608a Add an option to list the properties: -list-properties
albeu
parents: 17911
diff changeset
204
17911
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
205 // Some generic property implementations
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
206
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
207 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
208 void* arg,int var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
209 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
210 case M_PROPERTY_GET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
211 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
212 *(int*)arg = var;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
213 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
214 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
215 return M_PROPERTY_NOT_IMPLEMENTED;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
216 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
217
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
218 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
219 void* arg,int* var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
220 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
221 case M_PROPERTY_SET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
222 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
223 M_PROPERTY_CLAMP(prop,*(int*)arg);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
224 *var = *(int*)arg;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
225 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
226 case M_PROPERTY_STEP_UP:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
227 case M_PROPERTY_STEP_DOWN:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
228 *var += (arg ? *(int*)arg : 1) *
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
229 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
230 M_PROPERTY_CLAMP(prop,*var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
231 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
232 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
233 return m_property_int_ro(prop,action,arg,*var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
234 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
235
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
236 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
237 void* arg,int* var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
238 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
239 case M_PROPERTY_STEP_UP:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
240 case M_PROPERTY_STEP_DOWN:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
241 *var += action == M_PROPERTY_STEP_UP ? 1 : prop->max;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
242 *var %= (int)prop->max+1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
243 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
244 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
245 return m_property_int_range(prop,action,arg,var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
246 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
247
27647
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
248 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
249 void* arg,int var) {
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
250 switch(action) {
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
251 case M_PROPERTY_PRINT:
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
252 if(!arg) return 0;
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
253 *(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
254 return 1;
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
255 }
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
256 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
257 }
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
258
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
259 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
260 void* arg,int* var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
261 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
262 case M_PROPERTY_STEP_UP:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
263 case M_PROPERTY_STEP_DOWN:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
264 *var = *var == prop->min ? prop->max : prop->min;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
265 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
266 case M_PROPERTY_PRINT:
27647
98478619a22c Add a m_property_flag_ro function for the default behaviour of a
reimar
parents: 25716
diff changeset
267 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
268 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
269 return m_property_int_range(prop,action,arg,var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
270 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
271
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
272 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
273 void* arg,float var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
274 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
275 case M_PROPERTY_GET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
276 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
277 *(float*)arg = var;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
278 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
279 case M_PROPERTY_PRINT:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
280 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
281 *(char**)arg = malloc(20);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
282 sprintf(*(char**)arg,"%.2f",var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
283 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
284 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
285 return M_PROPERTY_NOT_IMPLEMENTED;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
286 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
287
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
288 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
289 void* arg,float* var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
290 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
291 case M_PROPERTY_SET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
292 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
293 M_PROPERTY_CLAMP(prop,*(float*)arg);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
294 *var = *(float*)arg;
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_STEP_UP:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
297 case M_PROPERTY_STEP_DOWN:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
298 *var += (arg ? *(float*)arg : 0.1) *
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
299 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
300 M_PROPERTY_CLAMP(prop,*var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
301 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
302 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
303 return m_property_float_ro(prop,action,arg,*var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
304 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
305
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
306 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
307 void* arg,float* var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
308 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
309 case M_PROPERTY_PRINT:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
310 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
311 *(char**)arg = malloc(20);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
312 sprintf(*(char**)arg,"%d ms",ROUND((*var)*1000));
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
313 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
314 default:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
315 return m_property_float_range(prop,action,arg,var);
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
316 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
317 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
318
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
319 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
320 void* arg,double var) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
321 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
322 case M_PROPERTY_GET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
323 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
324 *(double*)arg = var;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
325 return 1;
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,"%.2f",var);
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 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
332 return M_PROPERTY_NOT_IMPLEMENTED;
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
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
335 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
336 void* arg,double var) {
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
337 switch(action) {
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
338 case M_PROPERTY_PRINT:
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
339 if (!arg)
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
340 return M_PROPERTY_ERROR;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
341 else {
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
342 int h, m, s = var;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
343 h = s / 3600;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
344 s -= h * 3600;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
345 m = s / 60;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
346 s -= m * 60;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
347 *(char **) arg = malloc(20);
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
348 if (h > 0)
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
349 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
350 else if (m > 0)
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
351 sprintf(*(char **) arg, "%d:%02d", m, s);
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
352 else
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
353 sprintf(*(char **) arg, "%d", s);
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
354 return M_PROPERTY_OK;
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
355 }
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
356 }
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
357 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
358 }
ae4237717601 Move the time printing code out of the length property.
albeu
parents: 23395
diff changeset
359
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
360 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
361 switch(action) {
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
362 case M_PROPERTY_GET:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
363 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
364 *(char**)arg = str;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
365 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
366 case M_PROPERTY_PRINT:
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
367 if(!arg) return 0;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
368 *(char**)arg = str ? strdup(str) : NULL;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
369 return 1;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
370 }
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
371 return M_PROPERTY_NOT_IMPLEMENTED;
52f95509cd05 Add the new property API and implement a couple properties.
albeu
parents:
diff changeset
372 }
23394
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
373
25716
fc8d4bd1689a All the m_property stuff works fine with constant m_option_t
reimar
parents: 25501
diff changeset
374 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
375 switch(action) {
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
376 case M_PROPERTY_PRINT:
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
377 if (!arg)
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
378 return M_PROPERTY_ERROR;
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
379 *(char**)arg = malloc (16);
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
380 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
381 return M_PROPERTY_OK;
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
382 }
d4e8613ddc95 Make all the info available via the metadata API available via properties.
albeu
parents: 23393
diff changeset
383 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
384 }