2 Copyright 2006 Chris Tallon, Marten Richter
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "vaudioselector.h"
23 VAudioSelector::VAudioSelector(void* tparent, bool* availableAudioChannels, int currentAudioChannel, RecInfo* recInfo)
25 Log::getInstance()->log("VAS", Log::DEBUG, "%i", currentAudioChannel);
31 // setTitleText(tr("Audio"));
33 // setTitleBarColour(Colour::TITLEBARBACKGROUND);
35 sl.setSurface(surface);
36 sl.setSurfaceOffset(40, 30);
37 sl.setDimensions(area.w - 45, area.h - 30);
39 // Load data from availableAudioChannels, currentAudioChannel and recInfo
43 for (i = 0; i < PES_AUDIO_MAXCHANNELS; i++)
45 if (availableAudioChannels[i])
47 AudioChannel* ac = new AudioChannel();
50 ac->pestype = PES_AUDIO_START + i;
55 unsigned char numchan_recinfo = recInfo->numComponents;
56 unsigned char numchan_siz = acl.size();
57 int mp_audcounter = 0;
61 for (i = 0; i < numchan_siz; i++)
63 AudioChannel* ac = acl[i];
78 for (i = 0; i < numchan_recinfo; i++)
80 if (recInfo->streams[i] != 2) continue; //not an audio component
81 type = recInfo->types[i];
82 lang = recInfo->languages[i];
83 description = recInfo->descriptions[i];
84 AudioChannel* ac = NULL;
89 case 1: //mpaudio mono
90 case 3: //mpaudio stereo
91 if (mp_audcounter < numchan_siz) ac = acl[mp_audcounter];
95 if (ac3_counter + ac3_offset < numchan_siz) ac = acl[ac3_counter + ac3_offset];
102 if (ac->type == type_int)
104 if (description && (strlen(description) > 0))
106 ac->name = new char[strlen(description)+1];
107 strcpy(ac->name, description);
109 else if (lang && (strlen(lang) > 0))
111 ac->name = new char[strlen(lang)+1];
112 strcpy(ac->name, lang);
130 char tempString[300];
131 int audioChannelListSize = acl.size();
133 if (audioChannelListSize)
135 for(i = 0; i < audioChannelListSize; i++)
137 AudioChannel* ac = acl[i];
141 sl.addOption(ac->name, (ULONG)ac, (ac->pestype == currentAudioChannel));
145 SNPRINTF(tempString, 299, "%lu", (ULONG)(ac->pestype - PES_AUDIO_START));
146 sl.addOption(tempString, (ULONG)ac, (ac->pestype == currentAudioChannel));
152 sl.addOption(tr("No audio channel data available"), 0, 1);
156 VAudioSelector::~VAudioSelector()
158 int audioChannelListSize = acl.size();
159 for(int i = 0; i < audioChannelListSize; i++)
167 Message* m = new Message();
170 m->message = Message::CHILD_CLOSE;
171 Command::getInstance()->postMessageNoLock(m);
174 void VAudioSelector::draw()
177 rectangle(0, 0, area.w, 30, Colour::TITLEBARBACKGROUND);
178 drawText(tr("Audio"), 45, 5, Colour::LIGHTTEXT);
180 sl.setBackgroundColour(backgroundColour);
184 int VAudioSelector::handleCommand(int command)
200 ViewMan::getInstance()->updateView(this);
202 Message* m = new Message();
205 m->message = Message::AUDIO_CHANGE_CHANNEL;
206 m->parameter = ((AudioChannel*)sl.getCurrentOptionData())->pestype;
207 Command::getInstance()->postMessageNoLock(m);
211 case Remote::DF_DOWN:
217 ViewMan::getInstance()->updateView(this);
219 Message* m = new Message();
222 m->message = Message::AUDIO_CHANGE_CHANNEL;
223 m->parameter = ((AudioChannel*)sl.getCurrentOptionData())->pestype;
224 Command::getInstance()->postMessageNoLock(m);
233 void VAudioSelector::processMessage(Message* m)
235 if (m->message == Message::MOUSE_MOVE)
237 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
240 ViewMan::getInstance()->updateView(this);
243 else if (m->message == Message::MOUSE_LBDOWN)
245 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
247 ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
250 { //check if press is outside this view! then simulate cancel
251 int x=(m->parameter>>16)-getScreenX();
252 int y=(m->parameter&0xFFFF)-getScreenY();
253 if (x<0 || y <0 || x>getWidth() || y>getHeight())
255 ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press