-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 13 | ||||
-rw-r--r-- | core/multimedia/opieplayer/wavplugin/wavplugin.cpp | 2 |
2 files changed, 6 insertions, 9 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 1a0c7ca..a6202bc 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -229,394 +229,391 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
229 | 229 | ||
230 | videoView->addColumn("Title",150); | 230 | videoView->addColumn("Title",150); |
231 | videoView->addColumn("Size",45); | 231 | videoView->addColumn("Size",45); |
232 | videoView->addColumn("Media",35); | 232 | videoView->addColumn("Media",35); |
233 | videoView->setColumnAlignment(1, Qt::AlignRight); | 233 | videoView->setColumnAlignment(1, Qt::AlignRight); |
234 | videoView->setColumnAlignment(2, Qt::AlignRight); | 234 | videoView->setColumnAlignment(2, Qt::AlignRight); |
235 | 235 | ||
236 | tabWidget->insertTab( vTab,"Video"); | 236 | tabWidget->insertTab( vTab,"Video"); |
237 | 237 | ||
238 | Global::findDocuments(&vFiles, "video/*"); | 238 | Global::findDocuments(&vFiles, "video/*"); |
239 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 239 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
240 | for ( ; Vdit.current(); ++Vdit ) { | 240 | for ( ; Vdit.current(); ++Vdit ) { |
241 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | 241 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; |
242 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | 242 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; |
243 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | 243 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; |
244 | else storage="RAM"; | 244 | else storage="RAM"; |
245 | QListViewItem * newItem; | 245 | QListViewItem * newItem; |
246 | if ( QFile( Vdit.current()->file()).exists() ) { | 246 | if ( QFile( Vdit.current()->file()).exists() ) { |
247 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 247 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
248 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 248 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | //playlists list | 252 | //playlists list |
253 | QWidget *LTab; | 253 | QWidget *LTab; |
254 | LTab = new QWidget( tabWidget, "LTab" ); | 254 | LTab = new QWidget( tabWidget, "LTab" ); |
255 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 255 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
256 | playLists->setMinimumSize(233,260);; | 256 | playLists->setMinimumSize(233,260);; |
257 | tabWidget->insertTab(LTab,"Lists"); | 257 | tabWidget->insertTab(LTab,"Lists"); |
258 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 258 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
259 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 259 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
260 | 260 | ||
261 | 261 | ||
262 | // add the library area | 262 | // add the library area |
263 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 263 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
264 | 264 | ||
265 | 265 | ||
266 | connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 266 | connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
267 | this, SLOT( fauxPlay( QListViewItem *) ) ); | 267 | this, SLOT( fauxPlay( QListViewItem *) ) ); |
268 | connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 268 | connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
269 | this, SLOT( fauxPlay( QListViewItem *)) ); | 269 | this, SLOT( fauxPlay( QListViewItem *)) ); |
270 | 270 | ||
271 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 271 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
272 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 272 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
273 | 273 | ||
274 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 274 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
275 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 275 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
276 | 276 | ||
277 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 277 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
278 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 278 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
279 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 279 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
280 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 280 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
281 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 281 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
282 | 282 | ||
283 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 283 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
284 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 284 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
285 | 285 | ||
286 | setCentralWidget( vbox5 ); | 286 | setCentralWidget( vbox5 ); |
287 | 287 | ||
288 | Config cfg( "MediaPlayer" ); | 288 | Config cfg( "MediaPlayer" ); |
289 | readConfig( cfg ); | 289 | readConfig( cfg ); |
290 | 290 | ||
291 | initializeStates(); | 291 | initializeStates(); |
292 | } | 292 | } |
293 | 293 | ||
294 | 294 | ||
295 | PlayListWidget::~PlayListWidget() { | 295 | PlayListWidget::~PlayListWidget() { |
296 | Config cfg( "MediaPlayer" ); | 296 | Config cfg( "MediaPlayer" ); |
297 | writeConfig( cfg ); | 297 | writeConfig( cfg ); |
298 | 298 | ||
299 | if ( d->current ) | 299 | if ( d->current ) |
300 | delete d->current; | 300 | delete d->current; |
301 | delete d; | 301 | delete d; |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | void PlayListWidget::initializeStates() { | 305 | void PlayListWidget::initializeStates() { |
306 | 306 | ||
307 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 307 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
308 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 308 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
309 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 309 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
310 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 310 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
311 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 311 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
312 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 312 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
313 | // setPlaylist( mediaPlayerState->playlist() ); | 313 | // setPlaylist( mediaPlayerState->playlist() ); |
314 | setPlaylist( true); | 314 | setPlaylist( true); |
315 | d->selectedFiles->first(); | 315 | d->selectedFiles->first(); |
316 | 316 | ||
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | void PlayListWidget::readConfig( Config& cfg ) { | 320 | void PlayListWidget::readConfig( Config& cfg ) { |
321 | cfg.setGroup("PlayList"); | 321 | cfg.setGroup("PlayList"); |
322 | 322 | ||
323 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 323 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
324 | 324 | ||
325 | for ( int i = 0; i < noOfFiles; i++ ) { | 325 | for ( int i = 0; i < noOfFiles; i++ ) { |
326 | QString entryName; | 326 | QString entryName; |
327 | entryName.sprintf( "File%i", i + 1 ); | 327 | entryName.sprintf( "File%i", i + 1 ); |
328 | QString linkFile = cfg.readEntry( entryName ); | 328 | QString linkFile = cfg.readEntry( entryName ); |
329 | DocLnk lnk( linkFile ); | 329 | DocLnk lnk( linkFile ); |
330 | if ( lnk.isValid() ) | 330 | if ( lnk.isValid() ) |
331 | d->selectedFiles->addToSelection( lnk ); | 331 | d->selectedFiles->addToSelection( lnk ); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | void PlayListWidget::writeConfig( Config& cfg ) const { | 336 | void PlayListWidget::writeConfig( Config& cfg ) const { |
337 | cfg.setGroup("PlayList"); | 337 | cfg.setGroup("PlayList"); |
338 | 338 | ||
339 | int noOfFiles = 0; | 339 | int noOfFiles = 0; |
340 | 340 | ||
341 | d->selectedFiles->first(); | 341 | d->selectedFiles->first(); |
342 | do { | 342 | do { |
343 | const DocLnk *lnk = d->selectedFiles->current(); | 343 | const DocLnk *lnk = d->selectedFiles->current(); |
344 | if ( lnk ) { | 344 | if ( lnk ) { |
345 | QString entryName; | 345 | QString entryName; |
346 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 346 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
347 | cfg.writeEntry( entryName, lnk->linkFile() ); | 347 | cfg.writeEntry( entryName, lnk->linkFile() ); |
348 | // if this link does exist, add it so we have the file | 348 | // if this link does exist, add it so we have the file |
349 | // next time... | 349 | // next time... |
350 | if ( !QFile::exists( lnk->linkFile() ) ) { | 350 | if ( !QFile::exists( lnk->linkFile() ) ) { |
351 | // the way writing lnks doesn't really check for out | 351 | // the way writing lnks doesn't really check for out |
352 | // of disk space, but check it anyway. | 352 | // of disk space, but check it anyway. |
353 | if ( !lnk->writeLink() ) { | 353 | if ( !lnk->writeLink() ) { |
354 | QMessageBox::critical( 0, tr("Out of space"), | 354 | QMessageBox::critical( 0, tr("Out of space"), |
355 | tr( "There was a problem saving " | 355 | tr( "There was a problem saving " |
356 | "the playlist.\n" | 356 | "the playlist.\n" |
357 | "Your playlist " | 357 | "Your playlist " |
358 | "may be missing some entries\n" | 358 | "may be missing some entries\n" |
359 | "the next time you start it." ) | 359 | "the next time you start it." ) |
360 | ); | 360 | ); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | noOfFiles++; | 363 | noOfFiles++; |
364 | } | 364 | } |
365 | } while ( d->selectedFiles->next() ); | 365 | } while ( d->selectedFiles->next() ); |
366 | 366 | ||
367 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 367 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
368 | 368 | ||
369 | 369 | ||
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 373 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
374 | qDebug("add"); | 374 | qDebug("add"); |
375 | d->setDocumentUsed = FALSE; | 375 | d->setDocumentUsed = FALSE; |
376 | if ( mediaPlayerState->playlist() ) | 376 | if ( mediaPlayerState->playlist() ) |
377 | d->selectedFiles->addToSelection( lnk ); | 377 | d->selectedFiles->addToSelection( lnk ); |
378 | else | 378 | else |
379 | mediaPlayerState->setPlaying( TRUE ); | 379 | mediaPlayerState->setPlaying( TRUE ); |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | void PlayListWidget::clearList() { | 383 | void PlayListWidget::clearList() { |
384 | while ( first() ) | 384 | while ( first() ) |
385 | d->selectedFiles->removeSelected(); | 385 | d->selectedFiles->removeSelected(); |
386 | } | 386 | } |
387 | 387 | ||
388 | 388 | ||
389 | void PlayListWidget::addAllToList() { | 389 | void PlayListWidget::addAllToList() { |
390 | DocLnkSet files; | 390 | DocLnkSet files; |
391 | Global::findDocuments(&files, "video/*;audio/*"); | 391 | Global::findDocuments(&files, "video/*;audio/*"); |
392 | QListIterator<DocLnk> dit( files.children() ); | 392 | QListIterator<DocLnk> dit( files.children() ); |
393 | for ( ; dit.current(); ++dit ) | 393 | for ( ; dit.current(); ++dit ) |
394 | d->selectedFiles->addToSelection( **dit ); | 394 | d->selectedFiles->addToSelection( **dit ); |
395 | } | 395 | } |
396 | 396 | ||
397 | 397 | ||
398 | void PlayListWidget::addAllMusicToList() { | 398 | void PlayListWidget::addAllMusicToList() { |
399 | DocLnkSet files; | 399 | DocLnkSet files; |
400 | Global::findDocuments(&files, "audio/*"); | 400 | Global::findDocuments(&files, "audio/*"); |
401 | QListIterator<DocLnk> dit( files.children() ); | 401 | QListIterator<DocLnk> dit( files.children() ); |
402 | for ( ; dit.current(); ++dit ) | 402 | for ( ; dit.current(); ++dit ) |
403 | d->selectedFiles->addToSelection( **dit ); | 403 | d->selectedFiles->addToSelection( **dit ); |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | void PlayListWidget::addAllVideoToList() { | 407 | void PlayListWidget::addAllVideoToList() { |
408 | DocLnkSet files; | 408 | DocLnkSet files; |
409 | Global::findDocuments(&files, "video/*"); | 409 | Global::findDocuments(&files, "video/*"); |
410 | QListIterator<DocLnk> dit( files.children() ); | 410 | QListIterator<DocLnk> dit( files.children() ); |
411 | for ( ; dit.current(); ++dit ) | 411 | for ( ; dit.current(); ++dit ) |
412 | d->selectedFiles->addToSelection( **dit ); | 412 | d->selectedFiles->addToSelection( **dit ); |
413 | } | 413 | } |
414 | 414 | ||
415 | 415 | ||
416 | void PlayListWidget::setDocument(const QString& fileref) { | 416 | void PlayListWidget::setDocument(const QString& fileref) { |
417 | if ( fileref.isNull() ) { | 417 | if ( fileref.isNull() ) { |
418 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 418 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
419 | return; | 419 | return; |
420 | } | 420 | } |
421 | if ( mediaPlayerState->playlist() ) | 421 | addToSelection( DocLnk( fileref ) ); |
422 | addToSelection( DocLnk( fileref ) ); | 422 | d->setDocumentUsed = TRUE; |
423 | else { | 423 | qApp->processEvents(); |
424 | d->setDocumentUsed = TRUE; | ||
425 | if ( d->current ) | ||
426 | delete d->current; | ||
427 | d->current = new DocLnk( fileref ); | ||
428 | } | ||
429 | mediaPlayerState->setPlaying( FALSE ); | 424 | mediaPlayerState->setPlaying( FALSE ); |
425 | qApp->processEvents(); | ||
430 | mediaPlayerState->setPlaying( TRUE ); | 426 | mediaPlayerState->setPlaying( TRUE ); |
427 | d->selectedFiles->removeSelected( ); | ||
431 | } | 428 | } |
432 | 429 | ||
433 | 430 | ||
434 | void PlayListWidget::setActiveWindow() { | 431 | void PlayListWidget::setActiveWindow() { |
435 | // When we get raised we need to ensure that it switches views | 432 | // When we get raised we need to ensure that it switches views |
436 | char origView = mediaPlayerState->view(); | 433 | char origView = mediaPlayerState->view(); |
437 | mediaPlayerState->setView( 'l' ); // invalidate | 434 | mediaPlayerState->setView( 'l' ); // invalidate |
438 | mediaPlayerState->setView( origView ); // now switch back | 435 | mediaPlayerState->setView( origView ); // now switch back |
439 | } | 436 | } |
440 | 437 | ||
441 | 438 | ||
442 | void PlayListWidget::useSelectedDocument() { | 439 | void PlayListWidget::useSelectedDocument() { |
443 | d->setDocumentUsed = FALSE; | 440 | d->setDocumentUsed = FALSE; |
444 | } | 441 | } |
445 | 442 | ||
446 | 443 | ||
447 | const DocLnk *PlayListWidget::current() { | 444 | const DocLnk *PlayListWidget::current() { |
448 | 445 | ||
449 | // qDebug("in Playlist widget ::current"); | 446 | // qDebug("in Playlist widget ::current"); |
450 | if ( mediaPlayerState->playlist() ) { | 447 | if ( mediaPlayerState->playlist() ) { |
451 | return d->selectedFiles->current(); | 448 | return d->selectedFiles->current(); |
452 | } | 449 | } |
453 | else if ( d->setDocumentUsed && d->current ) { | 450 | else if ( d->setDocumentUsed && d->current ) { |
454 | return d->current; | 451 | return d->current; |
455 | } else { | 452 | } else { |
456 | return d->files->selected(); | 453 | return d->files->selected(); |
457 | } | 454 | } |
458 | } | 455 | } |
459 | 456 | ||
460 | 457 | ||
461 | bool PlayListWidget::prev() { | 458 | bool PlayListWidget::prev() { |
462 | if ( mediaPlayerState->playlist() ) { | 459 | if ( mediaPlayerState->playlist() ) { |
463 | if ( mediaPlayerState->shuffled() ) { | 460 | if ( mediaPlayerState->shuffled() ) { |
464 | const DocLnk *cur = current(); | 461 | const DocLnk *cur = current(); |
465 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 462 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
466 | for ( int i = 0; i < j; i++ ) { | 463 | for ( int i = 0; i < j; i++ ) { |
467 | if ( !d->selectedFiles->next() ) | 464 | if ( !d->selectedFiles->next() ) |
468 | d->selectedFiles->first(); | 465 | d->selectedFiles->first(); |
469 | } | 466 | } |
470 | if ( cur == current() ) | 467 | if ( cur == current() ) |
471 | if ( !d->selectedFiles->next() ) | 468 | if ( !d->selectedFiles->next() ) |
472 | d->selectedFiles->first(); | 469 | d->selectedFiles->first(); |
473 | return TRUE; | 470 | return TRUE; |
474 | } else { | 471 | } else { |
475 | if ( !d->selectedFiles->prev() ) { | 472 | if ( !d->selectedFiles->prev() ) { |
476 | if ( mediaPlayerState->looping() ) { | 473 | if ( mediaPlayerState->looping() ) { |
477 | return d->selectedFiles->last(); | 474 | return d->selectedFiles->last(); |
478 | } else { | 475 | } else { |
479 | return FALSE; | 476 | return FALSE; |
480 | } | 477 | } |
481 | } | 478 | } |
482 | return TRUE; | 479 | return TRUE; |
483 | } | 480 | } |
484 | } else { | 481 | } else { |
485 | return mediaPlayerState->looping(); | 482 | return mediaPlayerState->looping(); |
486 | } | 483 | } |
487 | } | 484 | } |
488 | 485 | ||
489 | 486 | ||
490 | bool PlayListWidget::next() { | 487 | bool PlayListWidget::next() { |
491 | if ( mediaPlayerState->playlist() ) { | 488 | if ( mediaPlayerState->playlist() ) { |
492 | if ( mediaPlayerState->shuffled() ) { | 489 | if ( mediaPlayerState->shuffled() ) { |
493 | return prev(); | 490 | return prev(); |
494 | } else { | 491 | } else { |
495 | if ( !d->selectedFiles->next() ) { | 492 | if ( !d->selectedFiles->next() ) { |
496 | if ( mediaPlayerState->looping() ) { | 493 | if ( mediaPlayerState->looping() ) { |
497 | return d->selectedFiles->first(); | 494 | return d->selectedFiles->first(); |
498 | } else { | 495 | } else { |
499 | return FALSE; | 496 | return FALSE; |
500 | } | 497 | } |
501 | } | 498 | } |
502 | return TRUE; | 499 | return TRUE; |
503 | } | 500 | } |
504 | } else { | 501 | } else { |
505 | return mediaPlayerState->looping(); | 502 | return mediaPlayerState->looping(); |
506 | } | 503 | } |
507 | } | 504 | } |
508 | 505 | ||
509 | 506 | ||
510 | bool PlayListWidget::first() { | 507 | bool PlayListWidget::first() { |
511 | if ( mediaPlayerState->playlist() ) | 508 | if ( mediaPlayerState->playlist() ) |
512 | return d->selectedFiles->first(); | 509 | return d->selectedFiles->first(); |
513 | else | 510 | else |
514 | return mediaPlayerState->looping(); | 511 | return mediaPlayerState->looping(); |
515 | } | 512 | } |
516 | 513 | ||
517 | 514 | ||
518 | bool PlayListWidget::last() { | 515 | bool PlayListWidget::last() { |
519 | if ( mediaPlayerState->playlist() ) | 516 | if ( mediaPlayerState->playlist() ) |
520 | return d->selectedFiles->last(); | 517 | return d->selectedFiles->last(); |
521 | else | 518 | else |
522 | return mediaPlayerState->looping(); | 519 | return mediaPlayerState->looping(); |
523 | } | 520 | } |
524 | 521 | ||
525 | 522 | ||
526 | void PlayListWidget::saveList() { | 523 | void PlayListWidget::saveList() { |
527 | 524 | ||
528 | QString filename; | 525 | QString filename; |
529 | InputDialog *fileDlg; | 526 | InputDialog *fileDlg; |
530 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); | 527 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); |
531 | fileDlg->exec(); | 528 | fileDlg->exec(); |
532 | if( fileDlg->result() == 1 ) { | 529 | if( fileDlg->result() == 1 ) { |
533 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 530 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
534 | qDebug("saving playlist "+filename+".playlist"); | 531 | qDebug("saving playlist "+filename+".playlist"); |
535 | 532 | ||
536 | // DocLnk *lnk; | 533 | // DocLnk *lnk; |
537 | // lnk.setName( filename); //sets file name | 534 | // lnk.setName( filename); //sets file name |
538 | // // lnk.setComment(title); | 535 | // // lnk.setComment(title); |
539 | // lnk.setFile( filename+".playlist"); //sets File property | 536 | // lnk.setFile( filename+".playlist"); //sets File property |
540 | // lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D | 537 | // lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D |
541 | // lnk.setIcon("MPEGPlayer"); | 538 | // lnk.setIcon("MPEGPlayer"); |
542 | // if(!lnk.writeLink()) | 539 | // if(!lnk.writeLink()) |
543 | // qDebug("Writing doclink did not work"); | 540 | // qDebug("Writing doclink did not work"); |
544 | 541 | ||
545 | Config cfg( filename +".playlist"); | 542 | Config cfg( filename +".playlist"); |
546 | writeConfig( cfg ); | 543 | writeConfig( cfg ); |
547 | } | 544 | } |
548 | DocLnk lnk; | 545 | DocLnk lnk; |
549 | lnk.setName( filename); //sets file name | 546 | lnk.setName( filename); //sets file name |
550 | // lnk.setComment(title); | 547 | // lnk.setComment(title); |
551 | lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property | 548 | lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property |
552 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 549 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
553 | lnk.setIcon("MPEGPlayer"); | 550 | lnk.setIcon("MPEGPlayer"); |
554 | if(!lnk.writeLink()) | 551 | if(!lnk.writeLink()) |
555 | qDebug("Writing doclink did not work"); | 552 | qDebug("Writing doclink did not work"); |
556 | 553 | ||
557 | if(fileDlg) | 554 | if(fileDlg) |
558 | delete fileDlg; | 555 | delete fileDlg; |
559 | } | 556 | } |
560 | 557 | ||
561 | 558 | ||
562 | void PlayListWidget::loadList( const DocLnk & lnk) { | 559 | void PlayListWidget::loadList( const DocLnk & lnk) { |
563 | qDebug("load list "+ lnk.name()+".playlist"); | 560 | qDebug("load list "+ lnk.name()+".playlist"); |
564 | clearList(); | 561 | clearList(); |
565 | Config cfg( lnk.name()+".playlist"); | 562 | Config cfg( lnk.name()+".playlist"); |
566 | readConfig(cfg); | 563 | readConfig(cfg); |
567 | tabWidget->setCurrentPage(0); | 564 | tabWidget->setCurrentPage(0); |
568 | setCaption("OpiePlayer: "+lnk.name()); | 565 | setCaption("OpiePlayer: "+lnk.name()); |
569 | } | 566 | } |
570 | 567 | ||
571 | 568 | ||
572 | void PlayListWidget::setPlaylist( bool shown ) { | 569 | void PlayListWidget::setPlaylist( bool shown ) { |
573 | if ( shown ) | 570 | if ( shown ) |
574 | d->playListFrame->show(); | 571 | d->playListFrame->show(); |
575 | else | 572 | else |
576 | d->playListFrame->hide(); | 573 | d->playListFrame->hide(); |
577 | } | 574 | } |
578 | 575 | ||
579 | 576 | ||
580 | void PlayListWidget::setView( char view ) { | 577 | void PlayListWidget::setView( char view ) { |
581 | if ( view == 'l' ) | 578 | if ( view == 'l' ) |
582 | showMaximized(); | 579 | showMaximized(); |
583 | else | 580 | else |
584 | hide(); | 581 | hide(); |
585 | } | 582 | } |
586 | 583 | ||
587 | void PlayListWidget::addSelected() { | 584 | void PlayListWidget::addSelected() { |
588 | 585 | ||
589 | switch (tabWidget->currentPageIndex()) { | 586 | switch (tabWidget->currentPageIndex()) { |
590 | case 0: //playlist | 587 | case 0: //playlist |
591 | break; | 588 | break; |
592 | case 1: { //audio | 589 | case 1: { //audio |
593 | addToSelection( audioView->selectedItem() ); | 590 | addToSelection( audioView->selectedItem() ); |
594 | } | 591 | } |
595 | break; | 592 | break; |
596 | case 2: { // video | 593 | case 2: { // video |
597 | addToSelection( videoView->selectedItem() ); | 594 | addToSelection( videoView->selectedItem() ); |
598 | } | 595 | } |
599 | break; | 596 | break; |
600 | }; | 597 | }; |
601 | } | 598 | } |
602 | 599 | ||
603 | void PlayListWidget::removeSelected() { | 600 | void PlayListWidget::removeSelected() { |
604 | d->selectedFiles->removeSelected( ); | 601 | d->selectedFiles->removeSelected( ); |
605 | } | 602 | } |
606 | 603 | ||
607 | 604 | ||
608 | void PlayListWidget::playIt( QListViewItem *it) { | 605 | void PlayListWidget::playIt( QListViewItem *it) { |
609 | // d->setDocumentUsed = FALSE; | 606 | // d->setDocumentUsed = FALSE; |
610 | mediaPlayerState->setPlaying(TRUE); | 607 | mediaPlayerState->setPlaying(TRUE); |
611 | } | 608 | } |
612 | 609 | ||
613 | void PlayListWidget::addToSelection( QListViewItem *it) { | 610 | void PlayListWidget::addToSelection( QListViewItem *it) { |
614 | d->setDocumentUsed = FALSE; | 611 | d->setDocumentUsed = FALSE; |
615 | 612 | ||
616 | if(it) { | 613 | if(it) { |
617 | // qDebug("add to selection"); | 614 | // qDebug("add to selection"); |
618 | switch (tabWidget->currentPageIndex()) { | 615 | switch (tabWidget->currentPageIndex()) { |
619 | case 1: { | 616 | case 1: { |
620 | // qDebug("case 1"); | 617 | // qDebug("case 1"); |
621 | QListIterator<DocLnk> dit( files.children() ); | 618 | QListIterator<DocLnk> dit( files.children() ); |
622 | for ( ; dit.current(); ++dit ) { | 619 | for ( ; dit.current(); ++dit ) { |
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index 4a0da16..4e82900 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp | |||
@@ -1,342 +1,342 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | 20 | // L.J.Potter added changes Fri 02-15-2002 |
21 | 21 | ||
22 | #include <stdio.h> | 22 | #include <stdio.h> |
23 | #include <stdarg.h> | 23 | #include <stdarg.h> |
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | #include <errno.h> | 25 | #include <errno.h> |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include "wavplugin.h" | 28 | #include "wavplugin.h" |
29 | 29 | ||
30 | //#define debugMsg(a) qDebug(a) | 30 | //#define debugMsg(a) qDebug(a) |
31 | #define debugMsg(a) | 31 | #define debugMsg(a) |
32 | 32 | ||
33 | 33 | ||
34 | struct RiffChunk { | 34 | struct RiffChunk { |
35 | char id[4]; | 35 | char id[4]; |
36 | Q_UINT32 size; | 36 | Q_UINT32 size; |
37 | char data[4]; | 37 | char data[4]; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | 40 | ||
41 | struct ChunkData { | 41 | struct ChunkData { |
42 | Q_INT16 formatTag; | 42 | Q_INT16 formatTag; |
43 | Q_INT16 channels; | 43 | Q_INT16 channels; |
44 | Q_INT32 samplesPerSec; | 44 | Q_INT32 samplesPerSec; |
45 | Q_INT32 avgBytesPerSec; | 45 | Q_INT32 avgBytesPerSec; |
46 | Q_INT16 blockAlign; | 46 | Q_INT16 blockAlign; |
47 | Q_INT16 wBitsPerSample; | 47 | Q_INT16 wBitsPerSample; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | 50 | ||
51 | const int sound_buffer_size = 512; // 4096; // you got to be kidding right? | 51 | const int sound_buffer_size = 512; // 4096; // you got to be kidding right? |
52 | 52 | ||
53 | 53 | ||
54 | class WavPluginData { | 54 | class WavPluginData { |
55 | public: | 55 | public: |
56 | QFile *input; | 56 | QFile *input; |
57 | 57 | ||
58 | int wavedata_remaining; | 58 | int wavedata_remaining; |
59 | ChunkData chunkdata; | 59 | ChunkData chunkdata; |
60 | RiffChunk chunk; | 60 | RiffChunk chunk; |
61 | uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data | 61 | uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data |
62 | int out,max; | 62 | int out,max; |
63 | int samples_due; | 63 | int samples_due; |
64 | int samples; | 64 | int samples; |
65 | 65 | ||
66 | WavPluginData() { | 66 | WavPluginData() { |
67 | max = out = sound_buffer_size; | 67 | max = out = sound_buffer_size; |
68 | wavedata_remaining = 0; | 68 | wavedata_remaining = 0; |
69 | samples_due = 0; | 69 | samples_due = 0; |
70 | samples = -1; | 70 | samples = -1; |
71 | } | 71 | } |
72 | 72 | ||
73 | // expands out samples to the frequency of 44kHz //not any more | 73 | // expands out samples to the frequency of 44kHz //not any more |
74 | bool add( short *output, long count, long& done, bool stereo ) | 74 | bool add( short *output, long count, long& done, bool stereo ) |
75 | { | 75 | { |
76 | done = 0; | 76 | done = 0; |
77 | qApp->processEvents(); | ||
78 | 77 | ||
79 | if ( input == 0 ) { | 78 | if ( input == 0 ) { |
80 | qDebug("no input"); | 79 | qDebug("no input"); |
81 | return FALSE; | 80 | return FALSE; |
82 | } | 81 | } |
83 | 82 | ||
84 | while ( count ) { | 83 | while ( count ) { |
85 | int l,r; | 84 | int l,r; |
86 | if ( getSample(l, r) == FALSE ) { | 85 | if ( getSample(l, r) == FALSE ) { |
87 | qDebug("didn't get sample"); | 86 | qDebug("didn't get sample"); |
88 | return FALSE; | 87 | return FALSE; |
89 | } | 88 | } |
90 | samples_due += chunkdata.samplesPerSec; | 89 | samples_due += chunkdata.samplesPerSec; |
91 | printf("samples due %d\r", samples_due); | 90 | printf("samples due %d\r", samples_due); |
92 | fflush(stdout); | 91 | fflush(stdout); |
93 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { | 92 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { |
94 | *output++ = l; | 93 | *output++ = l; |
95 | if ( stereo ) | 94 | if ( stereo ) |
96 | *output++ = r; | 95 | *output++ = r; |
97 | samples_due -= chunkdata.samplesPerSec; | 96 | samples_due -= chunkdata.samplesPerSec; |
98 | count--; | 97 | count--; |
99 | done++; | 98 | done++; |
100 | } | 99 | } |
101 | } | 100 | } |
102 | return TRUE; | 101 | return TRUE; |
103 | } | 102 | } |
104 | 103 | ||
105 | bool initialise() { | 104 | bool initialise() { |
106 | if ( input == 0 ) | 105 | if ( input == 0 ) |
107 | return FALSE; | 106 | return FALSE; |
108 | 107 | ||
109 | wavedata_remaining = -1; | 108 | wavedata_remaining = -1; |
110 | 109 | ||
111 | while ( wavedata_remaining == -1 ) { | 110 | while ( wavedata_remaining == -1 ) { |
112 | // Keep reading chunks... | 111 | // Keep reading chunks... |
113 | const int n = sizeof(chunk) - sizeof(chunk.data); | 112 | const int n = sizeof(chunk) - sizeof(chunk.data); |
114 | int t = input->readBlock( (char*)&chunk, n ); | 113 | int t = input->readBlock( (char*)&chunk, n ); |
115 | if ( t != n ) { | 114 | if ( t != n ) { |
116 | if ( t == -1 ) | 115 | if ( t == -1 ) |
117 | return FALSE; | 116 | return FALSE; |
118 | return TRUE; | 117 | return TRUE; |
119 | } | 118 | } |
120 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { | 119 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { |
121 | samples = wavedata_remaining = chunk.size; | 120 | samples = wavedata_remaining = chunk.size; |
122 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { | 121 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { |
123 | char d[4]; | 122 | char d[4]; |
124 | if ( input->readBlock(d,4) != 4 ) { | 123 | if ( input->readBlock(d,4) != 4 ) { |
125 | return FALSE; | 124 | return FALSE; |
126 | } | 125 | } |
127 | if ( qstrncmp(d,"WAVE",4) != 0 ) { | 126 | if ( qstrncmp(d,"WAVE",4) != 0 ) { |
128 | // skip | 127 | // skip |
129 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { | 128 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { |
130 | return FALSE; | 129 | return FALSE; |
131 | } | 130 | } |
132 | } | 131 | } |
133 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { | 132 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { |
134 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { | 133 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { |
135 | return FALSE; | 134 | return FALSE; |
136 | } | 135 | } |
137 | #define WAVE_FORMAT_PCM 1 | 136 | #define WAVE_FORMAT_PCM 1 |
138 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { | 137 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { |
139 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); | 138 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); |
140 | return FALSE; | 139 | return FALSE; |
141 | } | 140 | } |
142 | } else { | 141 | } else { |
143 | // ignored chunk | 142 | // ignored chunk |
144 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { | 143 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { |
145 | return FALSE; | 144 | return FALSE; |
146 | } | 145 | } |
147 | } | 146 | } |
148 | } // while | 147 | } // while |
149 | qDebug("bits %d", chunkdata.wBitsPerSample); | 148 | qDebug("bits %d", chunkdata.wBitsPerSample); |
150 | return TRUE; | 149 | return TRUE; |
151 | } | 150 | } |
152 | 151 | ||
153 | 152 | ||
154 | // gets a sample from the file | 153 | // gets a sample from the file |
155 | bool getSample(int& l, int& r) | 154 | bool getSample(int& l, int& r) |
156 | { | 155 | { |
157 | l = r = 0; | 156 | l = r = 0; |
158 | 157 | ||
159 | if ( input == 0 ) | 158 | if ( input == 0 ) |
160 | return FALSE; | 159 | return FALSE; |
161 | 160 | ||
162 | if ( (wavedata_remaining < 0) || !max ) | 161 | if ( (wavedata_remaining < 0) || !max ) |
163 | return FALSE; | 162 | return FALSE; |
164 | 163 | ||
165 | if ( out >= max ) { | 164 | if ( out >= max ) { |
166 | max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); | 165 | max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); |
167 | 166 | ||
168 | wavedata_remaining -= max; | 167 | wavedata_remaining -= max; |
169 | 168 | ||
170 | out = 0; | 169 | out = 0; |
171 | if ( max <= 0 ) { | 170 | if ( max <= 0 ) { |
172 | max = 0; | 171 | max = 0; |
173 | return TRUE; | 172 | return TRUE; |
174 | } | 173 | } |
175 | } | 174 | } |
176 | if ( chunkdata.wBitsPerSample == 8 ) { | 175 | if ( chunkdata.wBitsPerSample == 8 ) { |
177 | l = (data[out++] - 128) * 128; | 176 | l = (data[out++] - 128) * 128; |
178 | } else { | 177 | } else { |
179 | l = ((short*)data)[out/2]; | 178 | l = ((short*)data)[out/2]; |
180 | out += 2; | 179 | out += 2; |
181 | } | 180 | } |
182 | if ( chunkdata.channels == 1 ) { | 181 | if ( chunkdata.channels == 1 ) { |
183 | r = l; | 182 | r = l; |
184 | } else { | 183 | } else { |
185 | if ( chunkdata.wBitsPerSample == 8 ) { | 184 | if ( chunkdata.wBitsPerSample == 8 ) { |
186 | r = (data[out++] - 128) * 128; | 185 | r = (data[out++] - 128) * 128; |
187 | } else { | 186 | } else { |
188 | r = ((short*)data)[out/2]; | 187 | r = ((short*)data)[out/2]; |
189 | out += 2; | 188 | out += 2; |
190 | } | 189 | } |
191 | } | 190 | } |
192 | return TRUE; | 191 | return TRUE; |
193 | } // getSample | 192 | } // getSample |
194 | 193 | ||
195 | }; | 194 | }; |
196 | 195 | ||
197 | 196 | ||
198 | WavPlugin::WavPlugin() { | 197 | WavPlugin::WavPlugin() { |
199 | d = new WavPluginData; | 198 | d = new WavPluginData; |
200 | d->input = 0; | 199 | d->input = 0; |
201 | } | 200 | } |
202 | 201 | ||
203 | 202 | ||
204 | WavPlugin::~WavPlugin() { | 203 | WavPlugin::~WavPlugin() { |
205 | close(); | 204 | close(); |
206 | delete d; | 205 | delete d; |
207 | } | 206 | } |
208 | 207 | ||
209 | 208 | ||
210 | bool WavPlugin::isFileSupported( const QString& path ) { | 209 | bool WavPlugin::isFileSupported( const QString& path ) { |
211 | // qDebug( "WavPlugin::isFileSupported" ); | 210 | // qDebug( "WavPlugin::isFileSupported" ); |
212 | 211 | ||
213 | char *ext = strrchr( path.latin1(), '.' ); | 212 | char *ext = strrchr( path.latin1(), '.' ); |
214 | 213 | ||
215 | // Test file extension | 214 | // Test file extension |
216 | if ( ext ) { | 215 | if ( ext ) { |
217 | if ( strncasecmp(ext, ".raw", 4) == 0 ) | 216 | if ( strncasecmp(ext, ".raw", 4) == 0 ) |
218 | return TRUE; | 217 | return TRUE; |
219 | if ( strncasecmp(ext, ".wav", 4) == 0 ) | 218 | if ( strncasecmp(ext, ".wav", 4) == 0 ) |
220 | return TRUE; | 219 | return TRUE; |
221 | if ( strncasecmp(ext, ".wave", 4) == 0 ) | 220 | if ( strncasecmp(ext, ".wave", 4) == 0 ) |
222 | return TRUE; | 221 | return TRUE; |
223 | } | 222 | } |
224 | 223 | ||
225 | return FALSE; | 224 | return FALSE; |
226 | } | 225 | } |
227 | 226 | ||
228 | 227 | ||
229 | bool WavPlugin::open( const QString& path ) { | 228 | bool WavPlugin::open( const QString& path ) { |
230 | // qDebug( "WavPlugin::open" ); | 229 | // qDebug( "WavPlugin::open" ); |
231 | 230 | ||
232 | d->max = d->out = sound_buffer_size; | 231 | d->max = d->out = sound_buffer_size; |
233 | d->wavedata_remaining = 0; | 232 | d->wavedata_remaining = 0; |
234 | d->samples_due = 0; | 233 | d->samples_due = 0; |
235 | 234 | ||
236 | d->input = new QFile( path ); | 235 | d->input = new QFile( path ); |
237 | if ( d->input->open(IO_ReadOnly) == FALSE ) { | 236 | if ( d->input->open(IO_ReadOnly) == FALSE ) { |
238 | qDebug("couldn't open file"); | 237 | qDebug("couldn't open file"); |
239 | delete d->input; | 238 | delete d->input; |
240 | d->input = 0; | 239 | d->input = 0; |
241 | return FALSE; | 240 | return FALSE; |
242 | } | 241 | } |
243 | 242 | ||
244 | d->initialise(); | 243 | d->initialise(); |
244 | qApp->processEvents(); | ||
245 | 245 | ||
246 | return TRUE; | 246 | return TRUE; |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | bool WavPlugin::close() { | 250 | bool WavPlugin::close() { |
251 | // qDebug( "WavPlugin::close" ); | 251 | // qDebug( "WavPlugin::close" ); |
252 | 252 | ||
253 | d->input->close(); | 253 | d->input->close(); |
254 | delete d->input; | 254 | delete d->input; |
255 | d->input = 0; | 255 | d->input = 0; |
256 | return TRUE; | 256 | return TRUE; |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | bool WavPlugin::isOpen() { | 260 | bool WavPlugin::isOpen() { |
261 | // qDebug( "WavPlugin::isOpen" ); | 261 | // qDebug( "WavPlugin::isOpen" ); |
262 | return ( d->input != 0 ); | 262 | return ( d->input != 0 ); |
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | int WavPlugin::audioStreams() { | 266 | int WavPlugin::audioStreams() { |
267 | // qDebug( "WavPlugin::audioStreams" ); | 267 | // qDebug( "WavPlugin::audioStreams" ); |
268 | return 1; | 268 | return 1; |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | int WavPlugin::audioChannels( int ) { | 272 | int WavPlugin::audioChannels( int ) { |
273 | // qDebug( "WavPlugin::audioChannels" ); | 273 | // qDebug( "WavPlugin::audioChannels" ); |
274 | return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples | 274 | return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | int WavPlugin::audioFrequency( int ) { | 278 | int WavPlugin::audioFrequency( int ) { |
279 | // qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec ); | 279 | // qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec ); |
280 | return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 | 280 | return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | int WavPlugin::audioSamples( int ) { | 284 | int WavPlugin::audioSamples( int ) { |
285 | // qDebug( "WavPlugin::audioSamples" ); | 285 | // qDebug( "WavPlugin::audioSamples" ); |
286 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, | 286 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, |
287 | // Therefore if source is mono we will double the number of samples | 287 | // Therefore if source is mono we will double the number of samples |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | bool WavPlugin::audioSetSample( long, int ) { | 291 | bool WavPlugin::audioSetSample( long, int ) { |
292 | // qDebug( "WavPlugin::audioSetSample" ); | 292 | // qDebug( "WavPlugin::audioSetSample" ); |
293 | return FALSE; | 293 | return FALSE; |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | long WavPlugin::audioGetSample( int ) { | 297 | long WavPlugin::audioGetSample( int ) { |
298 | // qDebug( "WavPlugin::audioGetSample" ); | 298 | // qDebug( "WavPlugin::audioGetSample" ); |
299 | return 0; | 299 | return 0; |
300 | } | 300 | } |
301 | 301 | ||
302 | /* | 302 | /* |
303 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { | 303 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { |
304 | debugMsg( "WavPlugin::audioReadSamples" ); | 304 | debugMsg( "WavPlugin::audioReadSamples" ); |
305 | return FALSE; | 305 | return FALSE; |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { | 309 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { |
310 | debugMsg( "WavPlugin::audioReReadSamples" ); | 310 | debugMsg( "WavPlugin::audioReReadSamples" ); |
311 | return FALSE; | 311 | return FALSE; |
312 | } | 312 | } |
313 | 313 | ||
314 | 314 | ||
315 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { | 315 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { |
316 | debugMsg( "WavPlugin::audioReadMonoSamples" ); | 316 | debugMsg( "WavPlugin::audioReadMonoSamples" ); |
317 | return !d->add( output, samples, samplesMade, FALSE ); | 317 | return !d->add( output, samples, samplesMade, FALSE ); |
318 | } | 318 | } |
319 | 319 | ||
320 | 320 | ||
321 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { | 321 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { |
322 | debugMsg( "WavPlugin::audioReadStereoSamples" ); | 322 | debugMsg( "WavPlugin::audioReadStereoSamples" ); |
323 | return !d->add( output, samples, samplesMade, TRUE ); | 323 | return !d->add( output, samples, samplesMade, TRUE ); |
324 | } | 324 | } |
325 | */ | 325 | */ |
326 | 326 | ||
327 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { | 327 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { |
328 | // qDebug( "WavPlugin::audioReadSamples" ); | 328 | // qDebug( "WavPlugin::audioReadSamples" ); |
329 | return d->add( output, samples, samplesMade, channels != 1 ); | 329 | return d->add( output, samples, samplesMade, channels != 1 ); |
330 | } | 330 | } |
331 | 331 | ||
332 | double WavPlugin::getTime() { | 332 | double WavPlugin::getTime() { |
333 | // qDebug( "WavPlugin::getTime" ); //this is a stupid hack here!! | 333 | // qDebug( "WavPlugin::getTime" ); //this is a stupid hack here!! |
334 | return d->chunkdata.wBitsPerSample; /*0.0*/; | 334 | return d->chunkdata.wBitsPerSample; /*0.0*/; |
335 | } | 335 | } |
336 | 336 | ||
337 | // int WavPlugin::audioBitsPerSample( int ) { | 337 | // int WavPlugin::audioBitsPerSample( int ) { |
338 | // // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); | 338 | // // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); |
339 | // return d->chunkdata.wBitsPerSample; // | 339 | // return d->chunkdata.wBitsPerSample; // |
340 | // } | 340 | // } |
341 | 341 | ||
342 | 342 | ||