annotate libmenu/menu_dvbin.c @ 26534:432ba8dbef54

Merge test program compilation rules using patterns.
author diego
date Mon, 28 Apr 2008 12:35:20 +0000
parents 9befb9809011
children f8b6c7045cf8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
1
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
2 #include <stdlib.h>
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
3 #include <stdio.h>
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
4 #include <dirent.h>
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
5 #include <errno.h>
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
6 #include <string.h>
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
7 #include <sys/types.h>
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
8 #include <sys/stat.h>
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
9 #include <ctype.h>
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
10 #include <unistd.h>
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
11 #include <limits.h>
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
12
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
13
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 12308
diff changeset
14 #include "config.h"
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
15
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 12308
diff changeset
16 #include "m_struct.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 12308
diff changeset
17 #include "m_option.h"
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
18
19431
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 19271
diff changeset
19 #include "libmpcodecs/img_format.h"
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 19271
diff changeset
20 #include "libmpcodecs/mp_image.h"
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
21
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
22 #include "menu.h"
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
23 #include "menu_list.h"
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 12308
diff changeset
24 #include "input/input.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 12308
diff changeset
25 #include "osdep/keycodes.h"
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
26
19271
64d82a45a05d introduce new 'stream' directory for all stream layer related components and split them from libmpdemux
ben
parents: 17945
diff changeset
27 #include "stream/dvbin.h"
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
28
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
29
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
30
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
31 struct list_entry_s {
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
32 struct list_entry p;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
33 int num; //the position of the chosen channel in the list
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
34 };
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
35
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
36 struct menu_priv_s {
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
37 menu_list_priv_t p;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
38 char* title;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
39 char* file;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
40 int card;
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
41 int level;
17682
b865581db0d5 auto hide dvb menu if auto-close is specified in menu.conf; patch by Ben Zores ben a geexbox di org
nicodvb
parents: 16862
diff changeset
42 int auto_close;
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
43 dvb_config_t *config;
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
44 };
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
45
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
46
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
47 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s, m)
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
48 #define mpriv (menu->priv)
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
49
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
50 static m_option_t cfg_fields[] = {
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
51 MENU_LIST_PRIV_FIELDS,
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
52 { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL },
17682
b865581db0d5 auto hide dvb menu if auto-close is specified in menu.conf; patch by Ben Zores ben a geexbox di org
nicodvb
parents: 16862
diff changeset
53 { "auto-close", ST_OFF(auto_close), CONF_TYPE_FLAG, 0, 0, 1, NULL },
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
54 { NULL, NULL, NULL, 0,0,0,NULL },
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
55 };
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
56
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
57
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
58 static struct menu_priv_s cfg_dflt = {
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
59 MENU_LIST_PRIV_DFLT,
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
60 "Select a channel: ",
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
61 "channels.conf",
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
62 0,
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
63 0,
17682
b865581db0d5 auto hide dvb menu if auto-close is specified in menu.conf; patch by Ben Zores ben a geexbox di org
nicodvb
parents: 16862
diff changeset
64 1,
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
65 NULL,
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
66 };
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
67
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
68
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
69
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
70
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
71 static void free_entry(list_entry_t* entry)
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
72 {
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
73 free(entry->p.txt);
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
74 free(entry);
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
75 }
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
76
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
77
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
78 static int fill_channels_menu(menu_t *menu, dvb_channels_list *dvb_list_ptr)
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
79 {
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
80 int n;
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
81 dvb_channel_t *channel;
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
82 list_entry_t* elem;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
83
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
84 mpriv->level = 2;
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
85 if(dvb_list_ptr == NULL)
25356
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
86 {
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
87 mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_set_channel: LIST NULL PTR, quit\n");
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
88 n = 1;
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
89 if((elem = calloc(1, sizeof(list_entry_t))) != NULL)
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
90 {
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
91 elem->p.next = NULL;
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
92 elem->p.txt = strdup("There are no channels for this DVB card!");
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
93
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
94 menu_list_add_entry(menu, elem);
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
95 }
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
96 return 1;
25356
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
97 }
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
98 for(n = 0; n < dvb_list_ptr->NUM_CHANNELS; n++)
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
99 {
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
100 channel = &(dvb_list_ptr->channels[n]);
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
101 if((elem = calloc(1, sizeof(list_entry_t))) != NULL)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
102 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
103 elem->p.next = NULL;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
104 elem->p.txt = strdup(channel->name);
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
105 elem->num = n;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
106
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
107 menu_list_add_entry(menu, elem);
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
108 }
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
109 else
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
110 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
111 mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_menu: fill_menu: couldn't malloc %d bytes for menu item: %s, exit\n",
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
112 sizeof(list_entry_t), strerror(errno));
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
113 break;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
114 }
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
115 }
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
116
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
117 return n;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
118 }
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
119
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
120
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
121 static int fill_cards_menu(menu_t *menu, dvb_config_t *conf)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
122 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
123 int n;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
124 list_entry_t* elem;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
125
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
126 for(n = 0; n < conf->count; n++)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
127 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
128 if((elem = calloc(1, sizeof(list_entry_t))) != NULL)
25356
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
129 {
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
130 elem->p.next = NULL;
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
131 elem->p.txt = strdup(conf->cards[n].name);
25356
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
132 elem->num = n;
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
133
25356
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
134 if(n == 0)
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
135 elem->p.prev = NULL;
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
136
25356
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
137 menu_list_add_entry(menu, elem);
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
138 }
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
139 else
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
140 {
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
141 fprintf(stderr, "dvb_menu: fill_menu: couldn't malloc %d bytes for menu item: %s, exit\n",
25356
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
142 sizeof(list_entry_t), strerror(errno));
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
143 if(n)
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
144 return 1;
25356
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
145
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
146 return 0;
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
147 }
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
148 }
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
149
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
150 return n;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
151 }
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
152
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
153
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
154 static int fill_menu(menu_t* menu)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
155 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
156 list_entry_t* elem;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
157 dvb_channels_list *dvb_list_ptr;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
158
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
159 menu_list_init(menu);
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
160
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
161 if(mpriv->config == NULL)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
162 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
163 if((elem = calloc(1, sizeof(list_entry_t))) != NULL)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
164 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
165 elem->p.prev = elem->p.next = NULL;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
166 elem->p.txt = strdup("NO DVB configuration present!");
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
167
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
168 menu_list_add_entry(menu, elem);
25356
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
169 return 1;
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
170 }
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
171 return 0;
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
172 }
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
173
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
174 mpriv->p.title = mpriv->title;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
175 if(mpriv->level == 1 && mpriv->config->count > 1)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
176 return fill_cards_menu(menu, mpriv->config);
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
177 else
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
178 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
179 dvb_list_ptr = mpriv->config->cards[mpriv->card].list;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
180 return fill_channels_menu(menu, dvb_list_ptr);
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
181 }
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
182 }
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
183
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
184
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
185 static void read_cmd(menu_t* menu, int cmd)
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
186 {
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
187 list_entry_t *elem;
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
188 mp_cmd_t* c;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
189 char *cmd_name;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
190 switch(cmd)
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
191 {
17945
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 17682
diff changeset
192 case MENU_CMD_RIGHT:
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
193 case MENU_CMD_OK:
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
194 {
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
195 elem = mpriv->p.current;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
196
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
197 if(mpriv->level == 1)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
198 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
199 mpriv->card = mpriv->p.current->num;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
200 mpriv->level = 2;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
201 menu_list_uninit(menu, free_entry);
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
202 fill_menu(menu);
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
203 }
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
204 else
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
205 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
206 dvb_priv_t *dvbp = (dvb_priv_t*) mpriv->config->priv;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
207 cmd_name = malloc(25 + strlen(elem->p.txt));
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
208 if(dvbp != NULL)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
209 sprintf(cmd_name, "dvb_set_channel %d %d", elem->num, mpriv->card);
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
210 else
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
211 sprintf(cmd_name, "loadfile 'dvb://%d@%s'", mpriv->card+1, elem->p.txt);
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
212
25356
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
213 c = mp_input_parse_cmd(cmd_name);
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
214 free(cmd_name);
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
215 if(c)
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
216 {
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
217 if(mpriv->auto_close)
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
218 mp_input_queue_cmd (mp_input_parse_cmd ("menu hide"));
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
219 mp_input_queue_cmd(c);
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
220 }
a5c22f3e4673 cosmetics: partially reformatted this monstruosity
nicodvb
parents: 25346
diff changeset
221 }
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
222 }
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
223 break;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
224
17945
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 17682
diff changeset
225 case MENU_CMD_LEFT:
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
226 case MENU_CMD_CANCEL:
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
227 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
228 elem = mpriv->p.current;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
229
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
230 menu_list_uninit(menu, free_entry);
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
231 if(mpriv->config->count > 1)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
232 mpriv->level--;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
233 else
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
234 mpriv->level = 0;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
235
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
236 if(mpriv->level > 0)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
237 {
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
238 fill_menu(menu);
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
239 break;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
240 }
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
241 }
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
242
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
243 default:
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
244 menu_list_read_cmd(menu, cmd);
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
245 }
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
246 }
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
247
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
248
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
249 static void close_menu(menu_t* menu)
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
250 {
25379
9befb9809011 get rid of the file-static dvb_config and free the config at close() . Patch by Andrew Calkin and me
nicodvb
parents: 25356
diff changeset
251 dvb_free_config(mpriv->config);
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
252 menu_list_uninit(menu, free_entry);
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
253 }
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
254
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
255
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
256 static int open_dvb_sel(menu_t* menu, char* args)
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
257 {
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
258 mpriv->config = dvb_get_config();
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
259 if(mpriv->config == NULL)
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
260 return 0;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
261
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
262 menu->draw = menu_list_draw;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
263 menu->read_cmd = read_cmd;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
264 menu->close = close_menu;
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
265
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
266 mpriv->card = 0;
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
267 mpriv->level = 1;
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
268 return fill_menu(menu);
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
269 }
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
270
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
271 const menu_info_t menu_info_dvbsel =
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
272 {
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
273 "DVB channels menu", //descr
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
274 "dvbsel", //name
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
275 "Nico", //author
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
276 "dvb_sel",
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
277 { //m_struct_t priv_st=
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
278 "dvb_cfg", //name
12308
e76abd2a803c new configuration structure, multi-card support
nicodvb
parents: 11352
diff changeset
279 sizeof(struct menu_priv_s), //size
10626
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
280 &cfg_dflt, //defaults
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
281 cfg_fields //settable fields
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
282 },
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
283 open_dvb_sel //open function
fd97f3727f15 Finnaly commit Nico's dvb menu. Sorry for committing this
albeu
parents:
diff changeset
284 };