Mercurial > mplayer.hg
annotate playtree.c @ 28300:c7dcb679ae70
add mimic in avi fourcc LM20 to ffmimic
MidiVid3 binary decoder for MV30
Telegeny binary decoder for VDTZ
author | compn |
---|---|
date | Fri, 16 Jan 2009 19:09:57 +0000 |
parents | 26c73d63f619 |
children | aac3629b180d |
rev | line source |
---|---|
18265 | 1 |
2 /// \file | |
3 /// \ingroup Playtree | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
4 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
5 #include "config.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
6 #include <stdlib.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
7 #include <string.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
8 #include <stdio.h> |
4050 | 9 #include <unistd.h> |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
10 #include <errno.h> |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
11 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
12 #include <assert.h> |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
13 #endif |
9748 | 14 #include "m_config.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
15 #include "playtree.h" |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
16 #include "mp_msg.h" |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
17 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
18 static int |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
19 play_tree_is_valid(play_tree_t* pt); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
20 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
21 play_tree_t* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
22 play_tree_new(void) { |
18879 | 23 play_tree_t* r = calloc(1,sizeof(play_tree_t)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
24 if(r == NULL) |
23614
bab9e6c606cc
Cast sizeof() to int in mp_msg arguments so it fits the format string on 64bit
reimar
parents:
18886
diff
changeset
|
25 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",(int)sizeof(play_tree_t)); |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
26 r->entry_type = PLAY_TREE_ENTRY_NODE; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
27 return r; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
28 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
29 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
30 void |
23872 | 31 play_tree_free(play_tree_t* pt, int children) { |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
32 play_tree_t* iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
33 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
34 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
35 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
36 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
37 |
23872 | 38 if(children) { |
8062
ed2d3e7e7e36
10L found by jeroen dobbelaere <jeroen dot dobbelaere at acunia dot com>
albeu
parents:
5802
diff
changeset
|
39 for(iter = pt->child; iter != NULL; ) { |
ed2d3e7e7e36
10L found by jeroen dobbelaere <jeroen dot dobbelaere at acunia dot com>
albeu
parents:
5802
diff
changeset
|
40 play_tree_t* nxt=iter->next; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
41 play_tree_free(iter,1); |
8062
ed2d3e7e7e36
10L found by jeroen dobbelaere <jeroen dot dobbelaere at acunia dot com>
albeu
parents:
5802
diff
changeset
|
42 iter = nxt; |
ed2d3e7e7e36
10L found by jeroen dobbelaere <jeroen dot dobbelaere at acunia dot com>
albeu
parents:
5802
diff
changeset
|
43 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
44 pt->child = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
45 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
46 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
47 play_tree_remove(pt,0,0); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
48 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
49 for(iter = pt->child ; iter != NULL ; iter = iter->next) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
50 iter->parent = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
51 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
52 //if(pt->params) free(pt->params); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
53 if(pt->files) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
54 int i; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
55 for(i = 0 ; pt->files[i] != NULL ; i++) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
56 free(pt->files[i]); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
57 free(pt->files); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
58 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
59 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
60 free(pt); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
61 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
62 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
63 void |
23872 | 64 play_tree_free_list(play_tree_t* pt, int children) { |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
65 play_tree_t* iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
66 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
67 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
68 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
69 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
70 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
71 for(iter = pt ; iter->prev != NULL ; iter = iter->prev) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
72 /* NOTHING */; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
73 |
8062
ed2d3e7e7e36
10L found by jeroen dobbelaere <jeroen dot dobbelaere at acunia dot com>
albeu
parents:
5802
diff
changeset
|
74 while(iter) { |
ed2d3e7e7e36
10L found by jeroen dobbelaere <jeroen dot dobbelaere at acunia dot com>
albeu
parents:
5802
diff
changeset
|
75 play_tree_t* nxt = iter->next; |
23872 | 76 play_tree_free(iter, children); |
8062
ed2d3e7e7e36
10L found by jeroen dobbelaere <jeroen dot dobbelaere at acunia dot com>
albeu
parents:
5802
diff
changeset
|
77 iter = nxt; |
ed2d3e7e7e36
10L found by jeroen dobbelaere <jeroen dot dobbelaere at acunia dot com>
albeu
parents:
5802
diff
changeset
|
78 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
79 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
80 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
81 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
82 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
83 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
84 play_tree_append_entry(play_tree_t* pt, play_tree_t* entry) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
85 play_tree_t* iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
86 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
87 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
88 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
89 assert(entry != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
90 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
91 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
92 if(pt == entry) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
93 return; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
94 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
95 for(iter = pt ; iter->next != NULL ; iter = iter->next) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
96 /* NOTHING */; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
97 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
98 entry->parent = iter->parent; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
99 entry->prev = iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
100 entry->next = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
101 iter->next = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
102 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
103 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
104 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
105 play_tree_prepend_entry(play_tree_t* pt, play_tree_t* entry) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
106 play_tree_t* iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
107 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
108 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
109 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
110 assert(entry != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
111 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
112 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
113 for(iter = pt ; iter->prev != NULL; iter = iter->prev) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
114 /* NOTHING */; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
115 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
116 entry->prev = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
117 entry->next = iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
118 entry->parent = iter->parent; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
119 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
120 iter->prev = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
121 if(entry->parent) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
122 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
123 assert(entry->parent->child == iter); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
124 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
125 entry->parent->child = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
126 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
127 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
128 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
129 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
130 play_tree_insert_entry(play_tree_t* pt, play_tree_t* entry) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
131 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
132 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
133 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
134 assert(entry != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
135 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
136 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
137 entry->parent = pt->parent; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
138 entry->prev = pt; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
139 if(pt->next) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
140 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
141 assert(pt->next->prev == pt); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
142 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
143 entry->next = pt->next; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
144 entry->next->prev = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
145 } else |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
146 entry->next = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
147 pt->next = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
148 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
149 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
150 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
151 void |
23872 | 152 play_tree_remove(play_tree_t* pt, int free_it, int with_children) { |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
153 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
154 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
155 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
156 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
157 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
158 // Middle of list |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
159 if(pt->prev && pt->next) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
160 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
161 assert(pt->prev->next == pt); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
162 assert(pt->next->prev == pt); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
163 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
164 pt->prev->next = pt->next; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
165 pt->next->prev = pt->prev; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
166 } // End of list |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
167 else if(pt->prev) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
168 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
169 assert(pt->prev->next == pt); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
170 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
171 pt->prev->next = NULL; |
25489 | 172 } // Beginning of list |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
173 else if(pt->next) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
174 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
175 assert(pt->next->prev == pt); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
176 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
177 pt->next->prev = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
178 if(pt->parent) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
179 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
180 assert(pt->parent->child == pt); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
181 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
182 pt->parent->child = pt->next; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
183 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
184 } // The only one |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
185 else if(pt->parent) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
186 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
187 assert(pt->parent->child == pt); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
188 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
189 pt->parent->child = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
190 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
191 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
192 pt->prev = pt->next = pt->parent = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
193 if(free_it) |
23872 | 194 play_tree_free(pt,with_children); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
195 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
196 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
197 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
198 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
199 play_tree_set_child(play_tree_t* pt, play_tree_t* child) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
200 play_tree_t* iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
201 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
202 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
203 assert(pt != NULL); |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
204 assert(pt->entry_type == PLAY_TREE_ENTRY_NODE); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
205 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
206 |
23872 | 207 //DEBUG_FF: Where are the children freed? |
9290
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
208 // Attention in using this function! |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
209 for(iter = pt->child ; iter != NULL ; iter = iter->next) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
210 iter->parent = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
211 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
212 // Go back to first one |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
213 for(iter = child ; iter->prev != NULL ; iter = iter->prev) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
214 /* NOTHING */; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
215 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
216 pt->child = iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
217 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
218 for( ; iter != NULL ; iter= iter->next) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
219 iter->parent = pt; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
220 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
221 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
222 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
223 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
224 play_tree_set_parent(play_tree_t* pt, play_tree_t* parent) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
225 play_tree_t* iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
226 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
227 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
228 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
229 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
230 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
231 if(pt->parent) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
232 pt->parent->child = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
233 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
234 for(iter = pt ; iter != NULL ; iter = iter->next) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
235 iter->parent = parent; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
236 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
237 if(pt->prev) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
238 for(iter = pt->prev ; iter->prev != NULL ; iter = iter->prev) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
239 iter->parent = parent; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
240 iter->parent = parent; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
241 parent->child = iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
242 } else |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
243 parent->child = pt; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
244 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
245 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
246 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
247 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
248 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
249 play_tree_add_file(play_tree_t* pt,char* file) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
250 int n = 0; |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
251 char* e; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
252 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
253 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
254 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
255 assert(pt->child == NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
256 assert(file != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
257 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
258 |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
259 if(pt->entry_type != PLAY_TREE_ENTRY_NODE && |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
260 pt->entry_type != PLAY_TREE_ENTRY_FILE) |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
261 return; |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
262 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
263 if(pt->files) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
264 for(n = 0 ; pt->files[n] != NULL ; n++) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
265 /* NOTHING */; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
266 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
267 pt->files = (char**)realloc(pt->files,(n+2)*sizeof(char*)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
268 if(pt->files ==NULL) { |
23614
bab9e6c606cc
Cast sizeof() to int in mp_msg arguments so it fits the format string on 64bit
reimar
parents:
18886
diff
changeset
|
269 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",(n+2)*(int)sizeof(char*)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
270 return; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
271 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
272 |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
273 e = pt->files[n] = strdup(file); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
274 pt->files[n+1] = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
275 |
9748 | 276 pt->entry_type = PLAY_TREE_ENTRY_FILE; |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
277 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
278 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
279 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
280 int |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
281 play_tree_remove_file(play_tree_t* pt,char* file) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
282 int n,f = -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
283 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
284 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
285 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
286 assert(file != NULL); |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
287 assert(pt->entry_type != PLAY_TREE_ENTRY_NODE); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
288 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
289 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
290 for(n=0 ; pt->files[n] != NULL ; n++) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
291 if(strcmp(file,pt->files[n]) == 0) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
292 f = n; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
293 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
294 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
295 if(f < 0) // Not found |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
296 return 0; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
297 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
298 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
299 assert(n > f); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
300 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
301 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
302 free(pt->files[f]); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
303 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
304 if(n > 1) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
305 memmove(&pt->files[f],&pt->files[f+1],(n-f)*sizeof(char*)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
306 pt->files = (char**)realloc(pt->files,n*sizeof(char*)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
307 if(pt->files == NULL) { |
23614
bab9e6c606cc
Cast sizeof() to int in mp_msg arguments so it fits the format string on 64bit
reimar
parents:
18886
diff
changeset
|
308 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",(n+2)*(int)sizeof(char*)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
309 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
310 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
311 } else { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
312 free(pt->files); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
313 pt->files = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
314 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
315 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
316 return 1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
317 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
318 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
319 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
320 play_tree_set_param(play_tree_t* pt, char* name, char* val) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
321 int n = 0,ni = -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
322 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
323 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
324 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
325 assert(name != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
326 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
327 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
328 if(pt->params) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
329 for( ; pt->params[n].name != NULL ; n++) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
330 if(strcasecmp(pt->params[n].name,name) == 0) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
331 ni = n; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
332 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
333 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
334 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
335 if(ni > 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
336 if(pt->params[n].value != NULL) free(pt->params[n].value); |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
337 pt->params[n].value = val != NULL ? strdup(val) : NULL; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
338 return; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
339 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
340 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
341 pt->params = (play_tree_param_t*)realloc(pt->params,(n+2)*sizeof(play_tree_param_t)); |
9290
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
342 if(pt->params == NULL) { |
23614
bab9e6c606cc
Cast sizeof() to int in mp_msg arguments so it fits the format string on 64bit
reimar
parents:
18886
diff
changeset
|
343 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't realloc params (%d bytes of memory)\n",(n+2)*(int)sizeof(play_tree_param_t)); |
9290
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
344 return; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
345 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
346 pt->params[n].name = strdup(name); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
347 pt->params[n].value = val != NULL ? strdup(val) : NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
348 memset(&pt->params[n+1],0,sizeof(play_tree_param_t)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
349 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
350 return; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
351 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
352 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
353 int |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
354 play_tree_unset_param(play_tree_t* pt, char* name) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
355 int n,ni = -1; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
356 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
357 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
358 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
359 assert(name != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
360 assert(pt->params != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
361 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
362 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
363 for(n = 0 ; pt->params[n].name != NULL ; n++) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
364 if(strcasecmp(pt->params[n].name,name) == 0) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
365 ni = n; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
366 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
367 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
368 if(ni < 0) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
369 return 0; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
370 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
371 if(pt->params[ni].name) free(pt->params[ni].name); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
372 if(pt->params[ni].value) free(pt->params[ni].value); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
373 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
374 if(n > 1) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
375 memmove(&pt->params[ni],&pt->params[ni+1],(n-ni)*sizeof(play_tree_param_t)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
376 pt->params = (play_tree_param_t*)realloc(pt->params,n*sizeof(play_tree_param_t)); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
377 if(pt->params == NULL) { |
23614
bab9e6c606cc
Cast sizeof() to int in mp_msg arguments so it fits the format string on 64bit
reimar
parents:
18886
diff
changeset
|
378 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",n*(int)sizeof(play_tree_param_t)); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
379 return -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
380 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
381 } else { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
382 free(pt->params); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
383 pt->params = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
384 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
385 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
386 return 1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
387 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
388 |
5217
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
389 void |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
390 play_tree_set_params_from(play_tree_t* dest,play_tree_t* src) { |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
391 int i; |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
392 |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
393 #ifdef MP_DEBUG |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
394 assert(dest != NULL); |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
395 assert(src != NULL); |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
396 #endif |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
397 |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
398 if(!src->params) |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
399 return; |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
400 |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
401 for(i = 0; src->params[i].name != NULL ; i++) |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
402 play_tree_set_param(dest,src->params[i].name,src->params[i].value); |
10394 | 403 if(src->flags & PLAY_TREE_RND) // pass the random flag too |
404 dest->flags |= PLAY_TREE_RND; | |
5217
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
405 |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
406 } |
3e7152b383ca
Set the params given to a playlist url to the playlist
albeu
parents:
4974
diff
changeset
|
407 |
23872 | 408 // all children if deep < 0 |
8174 | 409 void |
410 play_tree_set_flag(play_tree_t* pt, int flags , int deep) { | |
411 play_tree_t* i; | |
412 | |
413 pt->flags |= flags; | |
414 | |
415 if(deep && pt->child) { | |
416 if(deep > 0) deep--; | |
417 for(i = pt->child ; i ; i = i->next) | |
418 play_tree_set_flag(i,flags,deep); | |
419 } | |
420 } | |
421 | |
422 void | |
423 play_tree_unset_flag(play_tree_t* pt, int flags , int deep) { | |
424 play_tree_t* i; | |
425 | |
426 pt->flags &= ~flags; | |
427 | |
428 if(deep && pt->child) { | |
429 if(deep > 0) deep--; | |
430 for(i = pt->child ; i ; i = i->next) | |
431 play_tree_unset_flag(i,flags,deep); | |
432 } | |
433 } | |
434 | |
435 | |
436 //////////////////////////////////// ITERATOR ////////////////////////////////////// | |
437 | |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
438 static void |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
439 play_tree_iter_push_params(play_tree_iter_t* iter) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
440 int n; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
441 play_tree_t* pt; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
442 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
443 assert(iter != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
444 assert(iter->config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
445 assert(iter->tree != NULL); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
446 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
447 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
448 pt = iter->tree; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
449 |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
450 // We always push a config because we can set some option |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
451 // while playing |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
452 m_config_push(iter->config); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
453 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
454 if(pt->params == NULL) |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
455 return; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
456 |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
457 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
458 for(n = 0; pt->params[n].name != NULL ; n++) { |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
459 int e; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
460 if((e = m_config_set_option(iter->config,pt->params[n].name,pt->params[n].value)) < 0) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
461 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Error %d while setting option '%s' with value '%s'\n",e, |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
462 pt->params[n].name,pt->params[n].value); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
463 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
464 } |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
465 |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
466 if(!pt->child) |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
467 iter->entry_pushed = 1; |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
468 return; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
469 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
470 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
471 play_tree_iter_t* |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
472 play_tree_iter_new(play_tree_t* pt,m_config_t* config) { |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
473 play_tree_iter_t* iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
474 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
475 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
476 assert(pt != NULL); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
477 assert(config != NULL); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
478 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
479 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
480 if( ! play_tree_is_valid(pt)) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
481 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
482 |
18879 | 483 iter = calloc(1,sizeof(play_tree_iter_t)); |
9290
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
484 if(! iter) { |
23614
bab9e6c606cc
Cast sizeof() to int in mp_msg arguments so it fits the format string on 64bit
reimar
parents:
18886
diff
changeset
|
485 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate new iterator (%d bytes of memory)\n",(int)sizeof(play_tree_iter_t)); |
9290
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
486 return NULL; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
487 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
488 iter->root = pt; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
489 iter->tree = NULL; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
490 iter->config = config; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
491 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
492 if(pt->parent) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
493 iter->loop = pt->parent->loop; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
494 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
495 return iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
496 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
497 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
498 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
499 play_tree_iter_free(play_tree_iter_t* iter) { |
4960 | 500 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
501 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
502 assert(iter != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
503 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
504 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
505 if(iter->status_stack) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
506 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
507 assert(iter->stack_size > 0); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
508 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
509 free(iter->status_stack); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
510 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
511 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
512 free(iter); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
513 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
514 |
8174 | 515 static play_tree_t* |
516 play_tree_rnd_step(play_tree_t* pt) { | |
517 int count = 0; | |
518 int r; | |
519 play_tree_t *i,*head; | |
520 | |
521 // Count how many free choice we have | |
522 for(i = pt ; i->prev ; i = i->prev) | |
523 if(!(i->flags & PLAY_TREE_RND_PLAYED)) count++; | |
524 head = i; | |
525 if(!(i->flags & PLAY_TREE_RND_PLAYED)) count++; | |
526 for(i = pt->next ; i ; i = i->next) | |
527 if(!(i->flags & PLAY_TREE_RND_PLAYED)) count++; | |
528 | |
529 if(!count) return NULL; | |
530 | |
13884 | 531 r = (int)((float)(count) * rand() / (RAND_MAX + 1.0)); |
8174 | 532 |
533 for(i = head ; i ; i=i->next) { | |
534 if(!(i->flags & PLAY_TREE_RND_PLAYED)) r--; | |
535 if(r < 0) return i; | |
536 } | |
537 | |
538 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Random stepping error\n"); | |
539 return NULL; | |
540 } | |
541 | |
542 | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
543 int |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
544 play_tree_iter_step(play_tree_iter_t* iter, int d,int with_nodes) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
545 play_tree_t* pt; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
546 |
5651
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5217
diff
changeset
|
547 if ( !iter ) return PLAY_TREE_ITER_ENTRY; |
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5217
diff
changeset
|
548 if ( !iter->root ) return PLAY_TREE_ITER_ENTRY; |
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5217
diff
changeset
|
549 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
550 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
551 assert(iter != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
552 assert(iter->root != NULL); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
553 //printf("PT : Stepping = %d\n",d); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
554 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
555 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
556 if(iter->tree == NULL) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
557 iter->tree = iter->root; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
558 return play_tree_iter_step(iter,0,with_nodes); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
559 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
560 |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
561 if(iter->config && iter->entry_pushed > 0) { |
4781
e370779ac77f
In the good way this time, (1 and 0 was swaped 10*10^10l for me ;))
albeu
parents:
4768
diff
changeset
|
562 iter->entry_pushed = 0; |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
563 m_config_pop(iter->config); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
564 } |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
565 |
8174 | 566 if(iter->tree->parent && (iter->tree->parent->flags & PLAY_TREE_RND)) |
567 iter->mode = PLAY_TREE_ITER_RND; | |
568 else | |
569 iter->mode = PLAY_TREE_ITER_NORMAL; | |
570 | |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
571 iter->file = -1; |
8174 | 572 if(iter->mode == PLAY_TREE_ITER_RND) |
573 pt = play_tree_rnd_step(iter->tree); | |
574 else if( d > 0 ) { | |
575 int i; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
576 pt = iter->tree; |
8174 | 577 for(i = d ; i > 0 && pt ; i--) |
578 pt = pt->next; | |
579 d = i ? i : 1; | |
580 } else if(d < 0) { | |
581 int i; | |
582 pt = iter->tree; | |
583 for(i = d ; i < 0 && pt ; i++) | |
584 pt = pt->prev; | |
585 d = i ? i : -1; | |
586 } else | |
587 pt = iter->tree; | |
588 | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
589 if(pt == NULL) { // No next |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
590 // Must we loop? |
13708 | 591 if (iter->mode == PLAY_TREE_ITER_RND) { |
592 if (iter->root->loop == 0) | |
593 return PLAY_TREE_ITER_END; | |
594 play_tree_unset_flag(iter->root, PLAY_TREE_RND_PLAYED, -1); | |
595 if (iter->root->loop > 0) iter->root->loop--; | |
596 // try again | |
597 return play_tree_iter_step(iter, 0, with_nodes); | |
598 } else | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
599 if(iter->tree->parent && iter->tree->parent->loop != 0 && ((d > 0 && iter->loop != 0) || ( d < 0 && (iter->loop < 0 || iter->loop < iter->tree->parent->loop) ) ) ) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
600 if(d > 0) { // Go back to the first one |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
601 for(pt = iter->tree ; pt->prev != NULL; pt = pt->prev) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
602 /* NOTHNG */; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
603 if(iter->loop > 0) iter->loop--; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
604 } else if( d < 0 ) { // Or the last one |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
605 for(pt = iter->tree ; pt->next != NULL; pt = pt->next) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
606 /* NOTHNG */; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
607 if(iter->loop >= 0 && iter->loop < iter->tree->parent->loop) iter->loop++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
608 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
609 iter->tree = pt; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
610 return play_tree_iter_step(iter,0,with_nodes); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
611 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
612 // Go up one level |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
613 return play_tree_iter_up_step(iter,d,with_nodes); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
614 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
615 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
616 |
23872 | 617 // Is there any valid child? |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
618 if(pt->child && play_tree_is_valid(pt->child)) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
619 iter->tree = pt; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
620 if(with_nodes) { // Stop on the node |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
621 return PLAY_TREE_ITER_NODE; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
622 } else // Or follow it |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
623 return play_tree_iter_down_step(iter,d,with_nodes); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
624 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
625 |
23872 | 626 // Is it a valid entry? |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
627 if(! play_tree_is_valid(pt)) { |
9290
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
628 if(d == 0) { // Can this happen ? FF: Yes! |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
629 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"What to do now ???? Infinite loop if we continue\n"); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
630 return PLAY_TREE_ITER_ERROR; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
631 } // Not a valid entry : go to next one |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
632 return play_tree_iter_step(iter,d,with_nodes); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
633 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
634 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
635 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
636 assert(pt->files != NULL); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
637 #endif |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
638 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
639 iter->tree = pt; |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
640 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
641 for(d = 0 ; iter->tree->files[d] != NULL ; d++) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
642 /* NOTHING */; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
643 iter->num_files = d; |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
644 |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
645 if(iter->config) { |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
646 play_tree_iter_push_params(iter); |
4781
e370779ac77f
In the good way this time, (1 and 0 was swaped 10*10^10l for me ;))
albeu
parents:
4768
diff
changeset
|
647 iter->entry_pushed = 1; |
8174 | 648 if(iter->mode == PLAY_TREE_ITER_RND) |
649 pt->flags |= PLAY_TREE_RND_PLAYED; | |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
650 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
651 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
652 return PLAY_TREE_ITER_ENTRY; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
653 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
654 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
655 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
656 static int |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
657 play_tree_is_valid(play_tree_t* pt) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
658 play_tree_t* iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
659 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
660 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
661 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
662 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
663 |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
664 if(pt->entry_type != PLAY_TREE_ENTRY_NODE) { |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
665 #ifdef MP_DEBUG |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
666 assert(pt->child == NULL); |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
667 #endif |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
668 return 1; |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
669 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
670 else if (pt->child != NULL) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
671 for(iter = pt->child ; iter != NULL ; iter = iter->next) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
672 if(play_tree_is_valid(iter)) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
673 return 1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
674 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
675 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
676 return 0; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
677 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
678 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
679 int |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
680 play_tree_iter_up_step(play_tree_iter_t* iter, int d,int with_nodes) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
681 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
682 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
683 assert(iter != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
684 assert(iter->tree != NULL); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
685 //printf("PT : Go UP\n"); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
686 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
687 |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
688 iter->file = -1; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
689 if(iter->tree->parent == iter->root->parent) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
690 return PLAY_TREE_ITER_END; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
691 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
692 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
693 assert(iter->tree->parent != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
694 assert(iter->stack_size > 0); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
695 assert(iter->status_stack != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
696 #endif |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
697 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
698 iter->stack_size--; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
699 iter->loop = iter->status_stack[iter->stack_size]; |
5802 | 700 if(iter->stack_size > 0) |
701 iter->status_stack = (int*)realloc(iter->status_stack,iter->stack_size*sizeof(int)); | |
702 else { | |
703 free(iter->status_stack); | |
704 iter->status_stack = NULL; | |
705 } | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
706 if(iter->stack_size > 0 && iter->status_stack == NULL) { |
23614
bab9e6c606cc
Cast sizeof() to int in mp_msg arguments so it fits the format string on 64bit
reimar
parents:
18886
diff
changeset
|
707 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",iter->stack_size*(int)sizeof(char*)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
708 return PLAY_TREE_ITER_ERROR; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
709 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
710 iter->tree = iter->tree->parent; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
711 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
712 // Pop subtree params |
27088 | 713 if(iter->config) { |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
714 m_config_pop(iter->config); |
8174 | 715 if(iter->mode == PLAY_TREE_ITER_RND) |
716 iter->tree->flags |= PLAY_TREE_RND_PLAYED; | |
717 } | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
718 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
719 return play_tree_iter_step(iter,d,with_nodes); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
720 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
721 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
722 int |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
723 play_tree_iter_down_step(play_tree_iter_t* iter, int d,int with_nodes) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
724 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
725 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
726 assert(iter->tree->files == NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
727 assert(iter->tree->child != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
728 assert(iter->tree->child->parent == iter->tree); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
729 //printf("PT : Go DOWN\n"); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
730 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
731 |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
732 iter->file = -1; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
733 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
734 // Push subtree params |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
735 if(iter->config) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
736 play_tree_iter_push_params(iter); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
737 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
738 iter->stack_size++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
739 iter->status_stack = (int*)realloc(iter->status_stack,iter->stack_size*sizeof(int)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
740 if(iter->status_stack == NULL) { |
23614
bab9e6c606cc
Cast sizeof() to int in mp_msg arguments so it fits the format string on 64bit
reimar
parents:
18886
diff
changeset
|
741 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",iter->stack_size*(int)sizeof(int)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
742 return PLAY_TREE_ITER_ERROR; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
743 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
744 iter->status_stack[iter->stack_size-1] = iter->loop; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
745 // Set new status |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
746 iter->loop = iter->tree->loop-1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
747 if(d >= 0) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
748 iter->tree = iter->tree->child; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
749 else { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
750 play_tree_t* pt; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
751 for(pt = iter->tree->child ; pt->next != NULL ; pt = pt->next) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
752 /*NOTING*/; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
753 iter->tree = pt; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
754 } |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
755 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
756 return play_tree_iter_step(iter,0,with_nodes); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
757 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
758 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
759 char* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
760 play_tree_iter_get_file(play_tree_iter_t* iter, int d) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
761 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
762 assert(iter != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
763 assert(iter->tree->child == NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
764 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
765 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
766 if(iter->tree->files == NULL) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
767 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
768 |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
769 #ifdef MP_DEBUG |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
770 assert(iter->num_files > 0); |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
771 #endif |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
772 |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
773 if(iter->file >= iter->num_files-1 || iter->file < -1) |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
774 return NULL; |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
775 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
776 if(d > 0) { |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
777 if(iter->file >= iter->num_files - 1) |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
778 iter->file = 0; |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
779 else |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
780 iter->file++; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
781 } else if(d < 0) { |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
782 if(iter->file <= 0) |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
783 iter->file = iter->num_files - 1; |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
784 else |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
785 iter->file--; |
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
786 } |
9748 | 787 return iter->tree->files[iter->file]; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
788 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
789 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
790 play_tree_t* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
791 play_tree_cleanup(play_tree_t* pt) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
792 play_tree_t* iter, *tmp, *first; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
793 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
794 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
795 assert(pt != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
796 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
797 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
798 if( ! play_tree_is_valid(pt)) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
799 play_tree_remove(pt,1,1); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
800 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
801 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
802 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
803 first = pt->child; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
804 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
805 for(iter = pt->child ; iter != NULL ; ) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
806 tmp = iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
807 iter = iter->next; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
808 if(! play_tree_is_valid(tmp)) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
809 play_tree_remove(tmp,1,1); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
810 if(tmp == first) first = iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
811 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
812 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
813 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
814 for(iter = first ; iter != NULL ; ) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
815 tmp = iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
816 iter = iter->next; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
817 play_tree_cleanup(tmp); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
818 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
819 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
820 return pt; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
821 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
822 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
823 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
824 play_tree_iter_t* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
825 play_tree_iter_new_copy(play_tree_iter_t* old) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
826 play_tree_iter_t* iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
827 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
828 #ifdef MP_DEBUG |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
829 assert(old != NULL); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
830 #endif |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
831 |
18869 | 832 iter = malloc(sizeof(play_tree_iter_t)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
833 if(iter == NULL) { |
23614
bab9e6c606cc
Cast sizeof() to int in mp_msg arguments so it fits the format string on 64bit
reimar
parents:
18886
diff
changeset
|
834 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",(int)sizeof(play_tree_iter_t)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
835 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
836 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
837 ; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
838 memcpy(iter,old,sizeof(play_tree_iter_t)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
839 if(old->status_stack) { |
18869 | 840 iter->status_stack = malloc(old->stack_size * sizeof(int)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
841 if(iter->status_stack == NULL) { |
23614
bab9e6c606cc
Cast sizeof() to int in mp_msg arguments so it fits the format string on 64bit
reimar
parents:
18886
diff
changeset
|
842 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",old->stack_size * (int)sizeof(int)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
843 free(iter); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
844 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
845 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
846 memcpy(iter->status_stack,old->status_stack,iter->stack_size*sizeof(int)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
847 } |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
848 iter->config = NULL; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
4050
diff
changeset
|
849 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
850 return iter; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
851 } |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
852 |
9290
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
853 // HIGH Level API, by Fabian Franz (mplayer@fabian-franz.de) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
854 // |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
855 play_tree_iter_t* pt_iter_create(play_tree_t** ppt, m_config_t* config) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
856 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
857 play_tree_iter_t* r=NULL; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
858 #ifdef MP_DEBUG |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
859 assert(*ppt!=NULL); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
860 #endif |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
861 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
862 *ppt=play_tree_cleanup(*ppt); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
863 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
864 if(*ppt) { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
865 r = play_tree_iter_new(*ppt,config); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
866 if (r && play_tree_iter_step(r,0,0) != PLAY_TREE_ITER_ENTRY) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
867 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
868 play_tree_iter_free(r); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
869 r = NULL; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
870 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
871 } |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
872 |
9290
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
873 return r; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
874 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
875 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
876 void pt_iter_destroy(play_tree_iter_t** iter) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
877 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
878 if (iter && *iter) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
879 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
880 free(*iter); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
881 iter=NULL; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
882 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
883 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
884 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
885 char* pt_iter_get_file(play_tree_iter_t* iter, int d) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
886 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
887 int i=0; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
888 char* r; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
889 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
890 if (iter==NULL) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
891 return NULL; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
892 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
893 r = play_tree_iter_get_file(iter,d); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
894 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
895 while (!r && d!=0) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
896 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
897 if (play_tree_iter_step(iter,d,0) != PLAY_TREE_ITER_ENTRY) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
898 break; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
899 r=play_tree_iter_get_file(iter,d); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
900 i++; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
901 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
902 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
903 return r; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
904 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
905 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
906 void pt_iter_insert_entry(play_tree_iter_t* iter, play_tree_t* entry) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
907 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
908 play_tree_t *pt = iter->tree; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
909 #ifdef MP_DEBUG |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
910 assert(pt!=NULL); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
911 assert(entry!=NULL); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
912 assert(entry!=pt); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
913 #endif |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
914 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
915 play_tree_insert_entry(pt, entry); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
916 play_tree_set_params_from(entry,pt); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
917 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
918 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
919 void pt_iter_replace_entry(play_tree_iter_t* iter, play_tree_t* entry) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
920 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
921 play_tree_t *pt = iter->tree; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
922 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
923 pt_iter_insert_entry(iter, entry); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
924 play_tree_remove(pt, 1, 1); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
925 iter->tree=entry; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
926 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
927 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
928 //Add a new file as a new entry |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
929 void pt_add_file(play_tree_t** ppt, char* filename) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
930 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
931 play_tree_t *pt = *ppt, *entry = play_tree_new(); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
932 #ifdef MP_DEBUG |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
933 assert(entry!=NULL); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
934 #endif |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
935 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
936 play_tree_add_file(entry, filename); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
937 if (pt) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
938 play_tree_append_entry(pt, entry); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
939 else |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
940 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
941 pt=entry; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
942 *ppt=pt; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
943 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
944 play_tree_set_params_from(entry,pt); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
945 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
946 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
947 void pt_add_gui_file(play_tree_t** ppt, char* path, char* file) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
948 { |
12646 | 949 char* wholename = malloc(strlen(path)+strlen(file)+2); |
9290
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
950 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
951 if (wholename) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
952 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
953 strcpy(wholename, path); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
954 strcat(wholename, "/"); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
955 strcat(wholename, file); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
956 pt_add_file(ppt, wholename); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
957 free(wholename); // As pt_add_file strdups it anyway! |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
958 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
959 } |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
960 |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
961 void pt_iter_goto_head(play_tree_iter_t* iter) |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
962 { |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
963 iter->tree=iter->root; |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
964 play_tree_iter_step(iter, 0, 0); |
0e043196d176
this patch adds a high-level-api to playtree, allowing to use it more easily
arpi
parents:
8174
diff
changeset
|
965 } |