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