1 | #ifndef AUDIOTRACK_H |
---|
2 | #define AUDIOTRACK_H |
---|
3 | |
---|
4 | struct audiotrack* checkaudiotrack(struct channel* chnode, struct audiotrack* atrack) |
---|
5 | { |
---|
6 | struct audiotrack* node = NULL; |
---|
7 | |
---|
8 | if(chnode != NULL) |
---|
9 | { |
---|
10 | node = chnode->audiotrack; |
---|
11 | while(node != NULL) |
---|
12 | { |
---|
13 | if(node == atrack) |
---|
14 | return node; |
---|
15 | node = node->next; |
---|
16 | } |
---|
17 | } |
---|
18 | return NULL; |
---|
19 | } |
---|
20 | |
---|
21 | void screenaudiotrack() |
---|
22 | { |
---|
23 | int rcret = 0, treffer = 0; |
---|
24 | struct skin* audiotrack = getscreen("audiotrack"); |
---|
25 | struct skin* listbox = getscreennode(audiotrack, "listbox"); |
---|
26 | struct skin* b4 = getscreennode(audiotrack, "b4"); |
---|
27 | struct skin* tmp = NULL; |
---|
28 | struct audiotrack* node = NULL; |
---|
29 | |
---|
30 | listbox->aktline = 1; |
---|
31 | listbox->aktpage = -1; |
---|
32 | |
---|
33 | if(status.aktservice->channel != NULL) |
---|
34 | { |
---|
35 | m_lock(&status.audiotrackmutex, 7); |
---|
36 | node = status.aktservice->channel->audiotrack; |
---|
37 | |
---|
38 | while(node != NULL) |
---|
39 | { |
---|
40 | tmp = addlistbox(audiotrack, listbox, tmp, 1); |
---|
41 | if(tmp != NULL) |
---|
42 | { |
---|
43 | changetext(tmp, node->name); |
---|
44 | tmp->type = CHOICEBOX; |
---|
45 | tmp->del = 1; |
---|
46 | tmp->handle = (char*)node; |
---|
47 | |
---|
48 | if(status.aktservice->channel->audiopid == node->audiopid) |
---|
49 | { |
---|
50 | changeinput(tmp, _("running")); |
---|
51 | treffer = 1; |
---|
52 | } |
---|
53 | else |
---|
54 | changeinput(tmp, ""); |
---|
55 | } |
---|
56 | node = node->next; |
---|
57 | } |
---|
58 | m_unlock(&status.audiotrackmutex, 7); |
---|
59 | } |
---|
60 | |
---|
61 | if(treffer == 0) listbox->aktline = 1; |
---|
62 | |
---|
63 | if(status.downmix == 1) |
---|
64 | changetext(b4, "passthrough"); |
---|
65 | else |
---|
66 | changetext(b4, getconfig("av_ac3mode", NULL)); |
---|
67 | |
---|
68 | drawscreen(audiotrack, 0, 0); |
---|
69 | addscreenrc(audiotrack, listbox); |
---|
70 | |
---|
71 | while(1) |
---|
72 | { |
---|
73 | rcret = waitrc(audiotrack, 0, 0); |
---|
74 | |
---|
75 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
76 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
77 | { |
---|
78 | if(listbox->select != NULL && listbox->select->handle != NULL) |
---|
79 | { |
---|
80 | m_lock(&status.audiotrackmutex, 7); |
---|
81 | if(checkaudiotrack(status.aktservice->channel, (struct audiotrack*)listbox->select->handle) != NULL) |
---|
82 | servicechangeaudio(status.aktservice->channel, (struct audiotrack*)listbox->select->handle); |
---|
83 | m_unlock(&status.audiotrackmutex, 7); |
---|
84 | } |
---|
85 | break; |
---|
86 | } |
---|
87 | if(rcret == getrcconfigint("rcyellow", NULL)) |
---|
88 | { |
---|
89 | clearscreen(audiotrack); |
---|
90 | screensubtitle(); |
---|
91 | break; |
---|
92 | } |
---|
93 | if(rcret == getrcconfigint("rcblue", NULL)) |
---|
94 | { |
---|
95 | char* ac3dev = NULL; |
---|
96 | ac3dev = getconfig("ac3dev", NULL); |
---|
97 | int ret = 0; |
---|
98 | if(ac3dev != NULL) |
---|
99 | { |
---|
100 | if(status.downmix == 1) |
---|
101 | { |
---|
102 | ret = writesys(ac3dev, "passthrough", 0); |
---|
103 | if(ret == 0) |
---|
104 | status.downmix = 0; |
---|
105 | else |
---|
106 | printf("ERROR: set AC3_mode to passthrough\n"); |
---|
107 | } |
---|
108 | else |
---|
109 | { |
---|
110 | ret = writesys(ac3dev, getconfig("av_ac3mode", NULL), 0); |
---|
111 | if(ret == 0) |
---|
112 | status.downmix = 1; |
---|
113 | else |
---|
114 | printf("ERROR: set AC3_mode to %s\n", getconfig("av_ac3mode", NULL)); |
---|
115 | } |
---|
116 | if(status.play == 1) |
---|
117 | playerresetts(); |
---|
118 | } |
---|
119 | break; |
---|
120 | } |
---|
121 | } |
---|
122 | |
---|
123 | delmarkedscreennodes(audiotrack, 1); |
---|
124 | delownerrc(audiotrack); |
---|
125 | clearscreen(audiotrack); |
---|
126 | } |
---|
127 | |
---|
128 | struct audiotrack* addaudiotrack(struct channel* chnode, char* langdesc, int pid, int audiocodec, struct audiotrack* last) |
---|
129 | { |
---|
130 | struct audiotrack *newnode = NULL, *prev = NULL, *node = NULL; |
---|
131 | char *tmpstr = NULL; |
---|
132 | |
---|
133 | if(chnode == NULL) |
---|
134 | { |
---|
135 | err("NULL detect"); |
---|
136 | return NULL; |
---|
137 | } |
---|
138 | |
---|
139 | newnode = (struct audiotrack*)calloc(1, sizeof(struct audiotrack)); |
---|
140 | if(newnode == NULL) |
---|
141 | { |
---|
142 | err("no memory"); |
---|
143 | return NULL; |
---|
144 | } |
---|
145 | |
---|
146 | newnode->audiopid = pid; |
---|
147 | newnode->audiocodec = audiocodec; |
---|
148 | if(ostrcmp(langdesc, "und") == 0) |
---|
149 | tmpstr = ostrcat(tmpstr, _("undefined"), 1, 0); |
---|
150 | else |
---|
151 | tmpstr = ostrcat(tmpstr, _(langdesc), 1, 0); |
---|
152 | switch(audiocodec) |
---|
153 | { |
---|
154 | case AC3: tmpstr = ostrcat(tmpstr, " (DOLBY DIGITAL)", 1, 0); break; |
---|
155 | case MPEGA: tmpstr = ostrcat(tmpstr, " (STEREO)", 1, 0); break; |
---|
156 | case DTS: tmpstr = ostrcat(tmpstr, " (DTS)", 1, 0); break; |
---|
157 | case DTSHD: tmpstr = ostrcat(tmpstr, " (DTSHD)", 1, 0); break; |
---|
158 | case LPCM: tmpstr = ostrcat(tmpstr, " (LPCM)", 1, 0); break; |
---|
159 | case AAC: tmpstr = ostrcat(tmpstr, " (AAC)", 1, 0); break; |
---|
160 | case AACHE: tmpstr = ostrcat(tmpstr, " (AACHE)", 1, 0); break; |
---|
161 | } |
---|
162 | |
---|
163 | newnode->name = tmpstr; |
---|
164 | |
---|
165 | m_lock(&status.audiotrackmutex, 7); |
---|
166 | node = chnode->audiotrack; |
---|
167 | if(last == NULL) |
---|
168 | { |
---|
169 | while(node != NULL) |
---|
170 | { |
---|
171 | prev = node; |
---|
172 | node = node->next; |
---|
173 | } |
---|
174 | } |
---|
175 | else |
---|
176 | { |
---|
177 | prev = last; |
---|
178 | node = last->next; |
---|
179 | } |
---|
180 | |
---|
181 | if(prev == NULL) |
---|
182 | chnode->audiotrack = newnode; |
---|
183 | else |
---|
184 | prev->next = newnode; |
---|
185 | |
---|
186 | newnode->next = node; |
---|
187 | |
---|
188 | m_unlock(&status.audiotrackmutex, 7); |
---|
189 | return newnode; |
---|
190 | } |
---|
191 | |
---|
192 | void freeaudiotrack(struct channel* chnode) |
---|
193 | { |
---|
194 | struct audiotrack *node = NULL, *prev = NULL; |
---|
195 | |
---|
196 | if(chnode == NULL) |
---|
197 | { |
---|
198 | err("NULL detect"); |
---|
199 | return; |
---|
200 | } |
---|
201 | |
---|
202 | m_lock(&status.audiotrackmutex, 7); |
---|
203 | node = chnode->audiotrack; |
---|
204 | prev = chnode->audiotrack; |
---|
205 | |
---|
206 | while(node != NULL) |
---|
207 | { |
---|
208 | prev = node; |
---|
209 | node = node->next; |
---|
210 | chnode->audiotrack = node; |
---|
211 | |
---|
212 | free(prev->name); |
---|
213 | prev->name = NULL; |
---|
214 | |
---|
215 | free(prev); |
---|
216 | prev = NULL; |
---|
217 | |
---|
218 | } |
---|
219 | m_unlock(&status.audiotrackmutex, 7); |
---|
220 | } |
---|
221 | |
---|
222 | #endif |
---|