source: titan/titan/audiotrack.h @ 39653

Last change on this file since 39653 was 39407, checked in by gost, 7 years ago

[titan] qick switch passthrough

File size: 4.6 KB
Line 
1#ifndef AUDIOTRACK_H
2#define AUDIOTRACK_H
3
4struct 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
21void 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                        }
117                        break;
118                }
119        }
120
121        delmarkedscreennodes(audiotrack, 1);
122        delownerrc(audiotrack);
123        clearscreen(audiotrack);
124}
125
126struct audiotrack* addaudiotrack(struct channel* chnode, char* langdesc, int pid, int audiocodec, struct audiotrack* last)
127{
128        struct audiotrack *newnode = NULL, *prev = NULL, *node = NULL;
129        char *tmpstr = NULL;
130
131        if(chnode == NULL)
132        {
133                err("NULL detect");
134                return NULL;
135        }
136
137        newnode = (struct audiotrack*)calloc(1, sizeof(struct audiotrack));
138        if(newnode == NULL)
139        {
140                err("no memory");
141                return NULL;
142        }
143
144        newnode->audiopid = pid;
145        newnode->audiocodec = audiocodec;
146        if(ostrcmp(langdesc, "und") == 0)
147                tmpstr = ostrcat(tmpstr, _("undefined"), 1, 0);
148        else
149                tmpstr = ostrcat(tmpstr, _(langdesc), 1, 0);
150        switch(audiocodec)
151        {
152                case AC3: tmpstr = ostrcat(tmpstr, " (DOLBY DIGITAL)", 1, 0); break;
153                case MPEGA: tmpstr = ostrcat(tmpstr, " (STEREO)", 1, 0); break;
154                case DTS: tmpstr = ostrcat(tmpstr, " (DTS)", 1, 0); break;
155                case LPCM: tmpstr = ostrcat(tmpstr, " (LPCM)", 1, 0); break;
156                case AAC: tmpstr = ostrcat(tmpstr, " (AAC)", 1, 0); break;
157                case AACHE: tmpstr = ostrcat(tmpstr, " (AACHE)", 1, 0); break;
158        }
159
160        newnode->name = tmpstr;
161
162        m_lock(&status.audiotrackmutex, 7);
163        node = chnode->audiotrack;
164        if(last == NULL)
165        {
166                while(node != NULL)
167                {
168                        prev = node;
169                        node = node->next;
170                }
171        }
172        else
173        {
174                prev = last;
175                node = last->next;
176        }
177
178        if(prev == NULL)
179                chnode->audiotrack = newnode;
180        else
181                prev->next = newnode;
182
183        newnode->next = node;
184
185        m_unlock(&status.audiotrackmutex, 7);
186        return newnode;
187}
188
189void freeaudiotrack(struct channel* chnode)
190{
191        struct audiotrack *node = NULL, *prev = NULL;
192
193        if(chnode == NULL)
194        {
195                err("NULL detect");
196                return;
197        }
198
199        m_lock(&status.audiotrackmutex, 7);
200        node = chnode->audiotrack;
201        prev = chnode->audiotrack;
202
203        while(node != NULL)
204        {
205                prev = node;
206                node = node->next;
207                chnode->audiotrack = node;
208
209                free(prev->name);
210                prev->name = NULL;
211
212                free(prev);
213                prev = NULL;
214
215        }
216        m_unlock(&status.audiotrackmutex, 7);
217}
218
219#endif
Note: See TracBrowser for help on using the repository browser.