-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index ba17732..c5d0a5b 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -93,388 +93,388 @@ static char * vmemo_xpm[] = { | |||
93 | "# c #4D525C", | 93 | "# c #4D525C", |
94 | "$ c #6B6C70", | 94 | "$ c #6B6C70", |
95 | "% c #E3E3E8", | 95 | "% c #E3E3E8", |
96 | "& c #EEEEF2", | 96 | "& c #EEEEF2", |
97 | "* c #EAEAEF", | 97 | "* c #EAEAEF", |
98 | "= c #CACAD0", | 98 | "= c #CACAD0", |
99 | "- c #474A51", | 99 | "- c #474A51", |
100 | "; c #171819", | 100 | "; c #171819", |
101 | "> c #9B9B9F", | 101 | "> c #9B9B9F", |
102 | ", c #EBEBF0", | 102 | ", c #EBEBF0", |
103 | "' c #F4F4F7", | 103 | "' c #F4F4F7", |
104 | ") c #F1F1F5", | 104 | ") c #F1F1F5", |
105 | "! c #DEDEE4", | 105 | "! c #DEDEE4", |
106 | "~ c #57575C", | 106 | "~ c #57575C", |
107 | "{ c #010101", | 107 | "{ c #010101", |
108 | "] c #A2A2A6", | 108 | "] c #A2A2A6", |
109 | "^ c #747477", | 109 | "^ c #747477", |
110 | "/ c #B5B5B8", | 110 | "/ c #B5B5B8", |
111 | "( c #AEAEB2", | 111 | "( c #AEAEB2", |
112 | "_ c #69696D", | 112 | "_ c #69696D", |
113 | ": c #525256", | 113 | ": c #525256", |
114 | "< c #181C24", | 114 | "< c #181C24", |
115 | "[ c #97979B", | 115 | "[ c #97979B", |
116 | "} c #A7A7AC", | 116 | "} c #A7A7AC", |
117 | "| c #B0B0B4", | 117 | "| c #B0B0B4", |
118 | "1 c #C8C8D1", | 118 | "1 c #C8C8D1", |
119 | "2 c #75757B", | 119 | "2 c #75757B", |
120 | "3 c #46464A", | 120 | "3 c #46464A", |
121 | "4 c #494A4F", | 121 | "4 c #494A4F", |
122 | "5 c #323234", | 122 | "5 c #323234", |
123 | "6 c #909095", | 123 | "6 c #909095", |
124 | "7 c #39393B", | 124 | "7 c #39393B", |
125 | "8 c #757578", | 125 | "8 c #757578", |
126 | "9 c #87878E", | 126 | "9 c #87878E", |
127 | "0 c #222224", | 127 | "0 c #222224", |
128 | "a c #414144", | 128 | "a c #414144", |
129 | "b c #6A6A6E", | 129 | "b c #6A6A6E", |
130 | "c c #020C16", | 130 | "c c #020C16", |
131 | "d c #6B6B6F", | 131 | "d c #6B6B6F", |
132 | "e c #68686D", | 132 | "e c #68686D", |
133 | "f c #5B5B60", | 133 | "f c #5B5B60", |
134 | "g c #8A8A8F", | 134 | "g c #8A8A8F", |
135 | "h c #6B6B6E", | 135 | "h c #6B6B6E", |
136 | "i c #ADADB2", | 136 | "i c #ADADB2", |
137 | "j c #828289", | 137 | "j c #828289", |
138 | "k c #3E3E41", | 138 | "k c #3E3E41", |
139 | "l c #CFCFD7", | 139 | "l c #CFCFD7", |
140 | "m c #4C4C50", | 140 | "m c #4C4C50", |
141 | "n c #000000", | 141 | "n c #000000", |
142 | "o c #66666A", | 142 | "o c #66666A", |
143 | "p c #505054", | 143 | "p c #505054", |
144 | "q c #838388", | 144 | "q c #838388", |
145 | "r c #A1A1A7", | 145 | "r c #A1A1A7", |
146 | "s c #A9A9AE", | 146 | "s c #A9A9AE", |
147 | "t c #A8A8B0", | 147 | "t c #A8A8B0", |
148 | "u c #5E5E63", | 148 | "u c #5E5E63", |
149 | "v c #3A3A3E", | 149 | "v c #3A3A3E", |
150 | "w c #BDBDC6", | 150 | "w c #BDBDC6", |
151 | "x c #59595E", | 151 | "x c #59595E", |
152 | "y c #76767C", | 152 | "y c #76767C", |
153 | "z c #373738", | 153 | "z c #373738", |
154 | "A c #717174", | 154 | "A c #717174", |
155 | "B c #727278", | 155 | "B c #727278", |
156 | "C c #1C1C1E", | 156 | "C c #1C1C1E", |
157 | "D c #3C3C3F", | 157 | "D c #3C3C3F", |
158 | "E c #ADADB6", | 158 | "E c #ADADB6", |
159 | "F c #54555A", | 159 | "F c #54555A", |
160 | "G c #8B8C94", | 160 | "G c #8B8C94", |
161 | "H c #5A5A5F", | 161 | "H c #5A5A5F", |
162 | "I c #BBBBC3", | 162 | "I c #BBBBC3", |
163 | "J c #C4C4CB", | 163 | "J c #C4C4CB", |
164 | "K c #909098", | 164 | "K c #909098", |
165 | "L c #737379", | 165 | "L c #737379", |
166 | "M c #343437", | 166 | "M c #343437", |
167 | "N c #8F8F98", | 167 | "N c #8F8F98", |
168 | "O c #000407", | 168 | "O c #000407", |
169 | "P c #2D3137", | 169 | "P c #2D3137", |
170 | "Q c #B0B1BC", | 170 | "Q c #B0B1BC", |
171 | "R c #3B3C40", | 171 | "R c #3B3C40", |
172 | "S c #6E6E74", | 172 | "S c #6E6E74", |
173 | "T c #95959C", | 173 | "T c #95959C", |
174 | "U c #74747A", | 174 | "U c #74747A", |
175 | "V c #1D1D1E", | 175 | "V c #1D1D1E", |
176 | "W c #91929A", | 176 | "W c #91929A", |
177 | "X c #42444A", | 177 | "X c #42444A", |
178 | "Y c #22282E", | 178 | "Y c #22282E", |
179 | "Z c #B0B2BC", | 179 | "Z c #B0B2BC", |
180 | "` c #898A90", | 180 | "` c #898A90", |
181 | " . c #65656A", | 181 | " . c #65656A", |
182 | ".. c #999AA2", | 182 | ".. c #999AA2", |
183 | "+. c #52535A", | 183 | "+. c #52535A", |
184 | "@. c #151B21", | 184 | "@. c #151B21", |
185 | "#. c #515257", | 185 | "#. c #515257", |
186 | "$. c #B5B5BE", | 186 | "$. c #B5B5BE", |
187 | "%. c #616167", | 187 | "%. c #616167", |
188 | "&. c #1A1D22", | 188 | "&. c #1A1D22", |
189 | "*. c #000713", | 189 | "*. c #000713", |
190 | "=. c #1F1F21", | 190 | "=. c #1F1F21", |
191 | " ", | 191 | " ", |
192 | " . + @ # ", | 192 | " . + @ # ", |
193 | " $ % & * = - ", | 193 | " $ % & * = - ", |
194 | " ; > , ' ) ! ~ ", | 194 | " ; > , ' ) ! ~ ", |
195 | " { ] ^ / ( _ : ", | 195 | " { ] ^ / ( _ : ", |
196 | " < [ } | 1 2 3 ", | 196 | " < [ } | 1 2 3 ", |
197 | " 4 5 6 7 8 9 0 a b c ", | 197 | " 4 5 6 7 8 9 0 a b c ", |
198 | " d e f g h i j 3 k l m n ", | 198 | " d e f g h i j 3 k l m n ", |
199 | " o p q r s t u v w n ", | 199 | " o p q r s t u v w n ", |
200 | " o x y z A B C D E n ", | 200 | " o x y z A B C D E n ", |
201 | " F G H I J K L M N O ", | 201 | " F G H I J K L M N O ", |
202 | " P Q R S T U V W X ", | 202 | " P Q R S T U V W X ", |
203 | " Y Z ` b ...+. ", | 203 | " Y Z ` b ...+. ", |
204 | " @.#.$.%.&. ", | 204 | " @.#.$.%.&. ", |
205 | " *.B =. ", | 205 | " *.B =. ", |
206 | " n n n n n n n n n "}; | 206 | " n n n n n n n n n "}; |
207 | 207 | ||
208 | 208 | ||
209 | VMemo::VMemo( QWidget *parent, const char *_name ) | 209 | VMemo::VMemo( QWidget *parent, const char *_name ) |
210 | : QWidget( parent, _name ) { | 210 | : QWidget( parent, _name ) { |
211 | setFixedHeight( 18 ); | 211 | setFixedHeight( 18 ); |
212 | setFixedWidth( 14 ); | 212 | setFixedWidth( 14 ); |
213 | 213 | ||
214 | recording = FALSE; | 214 | recording = FALSE; |
215 | 215 | ||
216 | t_timer = new QTimer( this ); | 216 | t_timer = new QTimer( this ); |
217 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 217 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
218 | 218 | ||
219 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 219 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
220 | if (uname(&name) != -1) { | 220 | if (uname(&name) != -1) { |
221 | QString release=name.release; | 221 | QString release=name.release; |
222 | 222 | ||
223 | Config vmCfg("Vmemo"); | 223 | Config vmCfg("Vmemo"); |
224 | vmCfg.setGroup("Defaults"); | 224 | vmCfg.setGroup("Defaults"); |
225 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 225 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
226 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 226 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
227 | 227 | ||
228 | qDebug("toggleKey %d", toggleKey); | 228 | qDebug("toggleKey %d", toggleKey); |
229 | 229 | ||
230 | if(release.find("embedix",0,TRUE) !=-1) | 230 | if(release.find("embedix",0,TRUE) !=-1) |
231 | systemZaurus=TRUE; | 231 | systemZaurus=TRUE; |
232 | else | 232 | else |
233 | systemZaurus=FALSE; | 233 | systemZaurus=FALSE; |
234 | 234 | ||
235 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 235 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
236 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 236 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
237 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 237 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
238 | 238 | ||
239 | if( toggleKey != -1 ) { | 239 | if( toggleKey != -1 ) { |
240 | // QPEApplication::grabKeyboard(); | 240 | // QPEApplication::grabKeyboard(); |
241 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); | 241 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); |
242 | // e << 4096; // Key_Escape | 242 | // e << 4096; // Key_Escape |
243 | // e << Key_F5; //4148 | 243 | // e << Key_F5; //4148 |
244 | e << toggleKey; | 244 | e << toggleKey; |
245 | e << QString("QPE/VMemo"); | 245 | e << QString("QPE/VMemo"); |
246 | e << QString("toggleRecord()"); | 246 | e << QString("toggleRecord()"); |
247 | } | 247 | } |
248 | if(toggleKey == 1) | 248 | if(toggleKey == 1) |
249 | usingIcon=TRUE; | 249 | usingIcon=TRUE; |
250 | else | 250 | else |
251 | usingIcon=FALSE; | 251 | usingIcon=FALSE; |
252 | if( vmCfg.readNumEntry("hideIcon",0) == 1) | 252 | if( vmCfg.readNumEntry("hideIcon",0) == 1) |
253 | hide(); | 253 | hide(); |
254 | } | 254 | } |
255 | } | 255 | } |
256 | 256 | ||
257 | VMemo::~VMemo() { | 257 | VMemo::~VMemo() { |
258 | } | 258 | } |
259 | 259 | ||
260 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 260 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
261 | qDebug("receive"); | 261 | qDebug("receive"); |
262 | QDataStream stream( data, IO_ReadOnly ); | 262 | QDataStream stream( data, IO_ReadOnly ); |
263 | 263 | ||
264 | if (msg == "toggleRecord()") { | 264 | if (msg == "toggleRecord()") { |
265 | 265 | ||
266 | if (recording) { | 266 | if (recording) { |
267 | fromToggle = TRUE; | 267 | fromToggle = TRUE; |
268 | mouseReleaseEvent(NULL); | 268 | mouseReleaseEvent(NULL); |
269 | stopRecording(); | 269 | stopRecording(); |
270 | } else { | 270 | } else { |
271 | fromToggle = TRUE; | 271 | fromToggle = TRUE; |
272 | // mousePressEvent(NULL); | 272 | // mousePressEvent(NULL); |
273 | startRecording(); | 273 | startRecording(); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | void VMemo::paintEvent( QPaintEvent* ) { | 278 | void VMemo::paintEvent( QPaintEvent* ) { |
279 | QPainter p(this); | 279 | QPainter p(this); |
280 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 280 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
281 | } | 281 | } |
282 | 282 | ||
283 | void VMemo::mousePressEvent( QMouseEvent * me) { | 283 | void VMemo::mousePressEvent( QMouseEvent * me) { |
284 | // just to be safe | 284 | // just to be safe |
285 | if (recording) { | 285 | // if (recording) { |
286 | recording = FALSE; | 286 | // recording = FALSE; |
287 | return; | 287 | // return; |
288 | } | 288 | // } |
289 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 289 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
290 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 290 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
291 | // if ( me->button() != LeftButton && me != NULL /*&& !systemZaurus*/) { | 291 | // if ( me->button() != LeftButton && me != NULL /*&& !systemZaurus*/) { |
292 | 292 | ||
293 | // if (!systemZaurus && me != NULL) | 293 | // if (!systemZaurus && me != NULL) |
294 | // return; | 294 | // return; |
295 | // } | 295 | // } |
296 | 296 | ||
297 | if(!recording) | 297 | if(!recording) |
298 | startRecording(); | 298 | startRecording(); |
299 | else | 299 | else |
300 | stopRecording(); | 300 | stopRecording(); |
301 | } | 301 | } |
302 | 302 | ||
303 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { | 303 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { |
304 | // if(usingIcon && !recording) | 304 | // if(usingIcon && !recording) |
305 | // stopRecording(); | 305 | // stopRecording(); |
306 | } | 306 | } |
307 | 307 | ||
308 | bool VMemo::startRecording() { | 308 | bool VMemo::startRecording() { |
309 | 309 | ||
310 | if ( recording) | 310 | if ( recording) |
311 | return FALSE; | 311 | return FALSE; |
312 | 312 | ||
313 | Config config( "Vmemo" ); | 313 | Config config( "Vmemo" ); |
314 | config.setGroup( "System" ); | 314 | config.setGroup( "System" ); |
315 | 315 | ||
316 | useAlerts = config.readBoolEntry("Alert",1); | 316 | useAlerts = config.readBoolEntry("Alert",1); |
317 | if(useAlerts) { | 317 | if(useAlerts) { |
318 | 318 | ||
319 | msgLabel = new QLabel( 0, "alertLabel" ); | 319 | msgLabel = new QLabel( 0, "alertLabel" ); |
320 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 320 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
321 | msgLabel->show(); | 321 | msgLabel->show(); |
322 | } | 322 | } |
323 | 323 | ||
324 | // if(useAlerts) | 324 | // if(useAlerts) |
325 | // QMessageBox::message("VMemo","Really Record?");//) ==1) | 325 | // QMessageBox::message("VMemo","Really Record?");//) ==1) |
326 | // return; | 326 | // return; |
327 | // } else { | 327 | // } else { |
328 | // if (!systemZaurus ) | 328 | // if (!systemZaurus ) |
329 | // QSound::play(Resource::findSound("vmemob")); | 329 | // QSound::play(Resource::findSound("vmemob")); |
330 | // } | 330 | // } |
331 | qDebug("Start recording engines"); | 331 | qDebug("Start recording engines"); |
332 | recording = TRUE; | 332 | recording = TRUE; |
333 | 333 | ||
334 | if (openDSP() == -1) { | 334 | if (openDSP() == -1) { |
335 | // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); | 335 | // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); |
336 | // delete msgLabel; | 336 | // delete msgLabel; |
337 | recording = FALSE; | 337 | recording = FALSE; |
338 | msgLabel=0; | 338 | msgLabel=0; |
339 | delete msgLabel; | 339 | delete msgLabel; |
340 | 340 | ||
341 | return FALSE; | 341 | return FALSE; |
342 | } | 342 | } |
343 | 343 | ||
344 | config.setGroup("Defaults"); | 344 | config.setGroup("Defaults"); |
345 | 345 | ||
346 | QDateTime dt = QDateTime::currentDateTime(); | 346 | QDateTime dt = QDateTime::currentDateTime(); |
347 | 347 | ||
348 | QString fName; | 348 | QString fName; |
349 | config.setGroup( "System" ); | 349 | config.setGroup( "System" ); |
350 | fName = QPEApplication::documentDir() ; | 350 | fName = QPEApplication::documentDir() ; |
351 | fileName = config.readEntry("RecLocation", fName); | 351 | fileName = config.readEntry("RecLocation", fName); |
352 | 352 | ||
353 | int s; | 353 | int s; |
354 | s=fileName.find(':'); | 354 | s=fileName.find(':'); |
355 | if(s) | 355 | if(s) |
356 | fileName=fileName.right(fileName.length()-s-2); | 356 | fileName=fileName.right(fileName.length()-s-2); |
357 | qDebug("pathname will be "+fileName); | 357 | qDebug("pathname will be "+fileName); |
358 | 358 | ||
359 | if( fileName.left(1).find('/') == -1) | 359 | if( fileName.left(1).find('/') == -1) |
360 | fileName="/"+fileName; | 360 | fileName="/"+fileName; |
361 | if( fileName.right(1).find('/') == -1) | 361 | if( fileName.right(1).find('/') == -1) |
362 | fileName+="/"; | 362 | fileName+="/"; |
363 | fName = "vm_"+ dt.toString()+ ".wav"; | 363 | fName = "vm_"+ dt.toString()+ ".wav"; |
364 | 364 | ||
365 | fileName+=fName; | 365 | fileName+=fName; |
366 | // No spaces in the filename | 366 | // No spaces in the filename |
367 | fileName.replace(QRegExp("'"),""); | 367 | fileName.replace(QRegExp("'"),""); |
368 | fileName.replace(QRegExp(" "),"_"); | 368 | fileName.replace(QRegExp(" "),"_"); |
369 | fileName.replace(QRegExp(":"),"."); | 369 | fileName.replace(QRegExp(":"),"."); |
370 | fileName.replace(QRegExp(","),""); | 370 | fileName.replace(QRegExp(","),""); |
371 | 371 | ||
372 | 372 | ||
373 | qDebug("filename is "+fileName); | 373 | qDebug("filename is "+fileName); |
374 | // open tmp file here | 374 | // open tmp file here |
375 | char *pointer; | 375 | char *pointer; |
376 | pointer=tmpnam(NULL); | 376 | pointer=tmpnam(NULL); |
377 | qDebug("Opening tmp file %s",pointer); | 377 | qDebug("Opening tmp file %s",pointer); |
378 | 378 | ||
379 | if(openWAV(pointer ) == -1) { | 379 | if(openWAV(pointer ) == -1) { |
380 | 380 | ||
381 | // if(openWAV(fileName.latin1()) == -1) { | 381 | // if(openWAV(fileName.latin1()) == -1) { |
382 | QString err("Could not open the temp file\n"); | 382 | QString err("Could not open the temp file\n"); |
383 | err += fileName; | 383 | err += fileName; |
384 | QMessageBox::critical(0, "vmemo", err, "Abort"); | 384 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
385 | ::close(dsp); | 385 | ::close(dsp); |
386 | return FALSE; | 386 | return FALSE; |
387 | } | 387 | } |
388 | if( record() ) { | 388 | if( record() ) { |
389 | 389 | ||
390 | QString cmd; | 390 | QString cmd; |
391 | if( fileName.find(".wav",0,TRUE) == -1) | 391 | if( fileName.find(".wav",0,TRUE) == -1) |
392 | fileName += ".wav"; | 392 | fileName += ".wav"; |
393 | 393 | ||
394 | cmd.sprintf("mv %s "+fileName, pointer); | 394 | cmd.sprintf("mv %s "+fileName, pointer); |
395 | // move tmp file to regular file here | 395 | // move tmp file to regular file here |
396 | 396 | ||
397 | system(cmd.latin1()); | 397 | system(cmd.latin1()); |
398 | 398 | ||
399 | QArray<int> cats(1); | 399 | QArray<int> cats(1); |
400 | cats[0] = config.readNumEntry("Category", 0); | 400 | cats[0] = config.readNumEntry("Category", 0); |
401 | 401 | ||
402 | QString dlName("vm_"); | 402 | QString dlName("vm_"); |
403 | dlName += dt.toString(); | 403 | dlName += dt.toString(); |
404 | DocLnk l; | 404 | DocLnk l; |
405 | l.setFile(fileName); | 405 | l.setFile(fileName); |
406 | l.setName(dlName); | 406 | l.setName(dlName); |
407 | l.setType("audio/x-wav"); | 407 | l.setType("audio/x-wav"); |
408 | l.setCategories(cats); | 408 | l.setCategories(cats); |
409 | l.writeLink(); | 409 | l.writeLink(); |
410 | return TRUE; | 410 | return TRUE; |
411 | } else | 411 | } else |
412 | return FALSE; | 412 | return FALSE; |
413 | 413 | ||
414 | } | 414 | } |
415 | 415 | ||
416 | void VMemo::stopRecording() { | 416 | void VMemo::stopRecording() { |
417 | show(); | 417 | show(); |
418 | qDebug("Stopped recording"); | 418 | qDebug("Stopped recording"); |
419 | recording = FALSE; | 419 | recording = FALSE; |
420 | if(useAlerts) { | 420 | if(useAlerts) { |
421 | msgLabel->close(); | 421 | msgLabel->close(); |
422 | msgLabel=0; | 422 | msgLabel=0; |
423 | delete msgLabel; | 423 | delete msgLabel; |
424 | } | 424 | } |
425 | t_timer->stop(); | 425 | t_timer->stop(); |
426 | Config cfg("Vmemo"); | 426 | Config cfg("Vmemo"); |
427 | cfg.setGroup("Defaults"); | 427 | cfg.setGroup("Defaults"); |
428 | if( cfg.readNumEntry("hideIcon",0) == 1 ) | 428 | if( cfg.readNumEntry("hideIcon",0) == 1 ) |
429 | hide(); | 429 | hide(); |
430 | } | 430 | } |
431 | 431 | ||
432 | int VMemo::openDSP() { | 432 | int VMemo::openDSP() { |
433 | Config cfg("Vmemo"); | 433 | Config cfg("Vmemo"); |
434 | cfg.setGroup("Record"); | 434 | cfg.setGroup("Record"); |
435 | 435 | ||
436 | speed = cfg.readNumEntry("SampleRate", 22050); | 436 | speed = cfg.readNumEntry("SampleRate", 22050); |
437 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 437 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
438 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 438 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
439 | format = AFMT_S16_LE; | 439 | format = AFMT_S16_LE; |
440 | resolution = 16; | 440 | resolution = 16; |
441 | } else { | 441 | } else { |
442 | format = AFMT_U8; | 442 | format = AFMT_U8; |
443 | resolution = 8; | 443 | resolution = 8; |
444 | } | 444 | } |
445 | 445 | ||
446 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); | 446 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); |
447 | 447 | ||
448 | if(systemZaurus) { | 448 | if(systemZaurus) { |
449 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 | 449 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 |
450 | channels=1; //zaurus has one input channel | 450 | channels=1; //zaurus has one input channel |
451 | } else { | 451 | } else { |
452 | dsp = open("/dev/dsp", O_RDONLY); | 452 | dsp = open("/dev/dsp", O_RDONLY); |
453 | } | 453 | } |
454 | 454 | ||
455 | if(dsp == -1) { | 455 | if(dsp == -1) { |
456 | perror("open(\"/dev/dsp\")"); | 456 | perror("open(\"/dev/dsp\")"); |
457 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 457 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
458 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); | 458 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); |
459 | return -1; | 459 | return -1; |
460 | } | 460 | } |
461 | 461 | ||
462 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 462 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
463 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 463 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
464 | return -1; | 464 | return -1; |
465 | } | 465 | } |
466 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 466 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
467 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 467 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
468 | return -1; | 468 | return -1; |
469 | } | 469 | } |
470 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 470 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
471 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 471 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
472 | return -1; | 472 | return -1; |
473 | } | 473 | } |
474 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 474 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
475 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 475 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
476 | return -1; | 476 | return -1; |
477 | } | 477 | } |
478 | 478 | ||
479 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute | 479 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute |
480 | 480 | ||