Example #1
0
 // commands
 void action_play()
 {
   Multifile e = vector_lookup(files, folders.top().second);
   int nfiles = e.filenames.size();
   if (nfiles > 0)
     playmovie(e);
   else
     DialogWaitPrint pdialog(dgettext("mms-movie", "Folder is empty"), 1000);
 }
Example #2
0
void Xine::event_listener(void *user_data, const xine_event_t *event)
{
  Xine* xine = reinterpret_cast<Xine*>(user_data);
  Audio_s *audio_state = S_Audio_s::get_instance();
  /* fprintf(stderr, "got event type #%d\n", event->type); */

  switch(event->type) {

  case XINE_EVENT_QUIT:
    xine->playing = false;
    break;

  case XINE_EVENT_UI_PLAYBACK_FINISHED:
    pthread_mutex_lock(&xine->stream_mutex);
    if (xine->retry_track){
      xine->retry_track = false;
      xine->xine_request = _XINE_REQUEST_PLAY;
      pthread_cond_broadcast(&xine->stream_switch);
      pthread_mutex_unlock(&xine->stream_mutex);
    }
    else{
      xine->playing = false;
      xine->play_next_track = true;
      xine->seamless = true;
      pthread_mutex_unlock(&xine->stream_mutex);
      audio_state->get_audio()->next_audio_track();
    }
    //audio_state->get_audio()->update_playlist_view();
    break;
  case XINE_EVENT_PROGRESS:
  {
    xine_progress_data_t *pevent = reinterpret_cast<xine_progress_data_t *>(event->data);
      /* fprintf(stderr, "%s [%d%%]\n", pevent->description, pevent->percent); */
      audio_state->p->buffering_state = pevent->percent;
  }
  break;

#ifdef XINE_EVENT_MRL_REFERENCE_EXT
  case XINE_EVENT_MRL_REFERENCE_EXT:
  {
     std::string real_mrl = static_cast<xine_mrl_reference_data_ext_t*>(event->data)->mrl;
     pthread_mutex_lock(&xine->stream_mutex);
     dprintf("Xine: XINE_EVENT_MRL_REFERENCE_EXT -> '%s'\n", real_mrl);
     xine->file.path = real_mrl;
     xine->retry_track = true;
     pthread_mutex_unlock(&xine->stream_mutex);
  }
  break;
#endif

  case XINE_EVENT_UI_MESSAGE:
  {
    xine_ui_message_data_t *msg = reinterpret_cast<xine_ui_message_data_t*>(event->data);
    std::string err_m;
    std::string str = "Unknown event";
    switch(msg->type){

    case XINE_MSG_GENERAL_WARNING:
      err_m = dgettext("mms-audio-xine", "Xine engine warning");
      break;
    case XINE_MSG_UNKNOWN_HOST:
    case XINE_MSG_UNKNOWN_DEVICE:
    case XINE_MSG_NETWORK_UNREACHABLE:
    case XINE_MSG_CONNECTION_REFUSED:
    case XINE_MSG_FILE_NOT_FOUND:
    case XINE_MSG_READ_ERROR:
    case XINE_MSG_LIBRARY_LOAD_ERROR:
    case XINE_MSG_ENCRYPTED_SOURCE:
    case XINE_MSG_AUDIO_OUT_UNAVAILABLE:
    case XINE_MSG_PERMISSION_ERROR:
    case XINE_MSG_FILE_EMPTY:
      err_m = dgettext("mms-audio-xine", "Xine engine error");
      break;

    default:
      err_m = dgettext("mms-audio-xine","Xine engine message");
      break;
    }
    if(msg->explanation)
      str = reinterpret_cast<char*>(msg) + msg->explanation;

    if(msg->parameters){
      str += " - ";
      str += reinterpret_cast<char*>(msg) + msg->parameters;
    }

    DialogWaitPrint pdialog(4000);
    pdialog.add_line(err_m);
    pdialog.add_line(str);
    pdialog.print();
    fprintf (stderr, "%s\n%s\n", err_m.c_str(), str.c_str());
  }
  default:
    {
      break; /* nothing */
    }
  }
}
Example #3
0
bool Xine::make_new_stream(){

  if (stream)
    xine_dispose(stream);

  std::string ao_driver = "auto";
  GlobalOptions * go =  S_GlobalOptions::get_instance();
  global_audio_device gad = go->get_audio_device_audio();
  if (gad.dev_output != ""){
    ao_driver = gad.dev_output;
  }

  if (ao_port)
    xine_close_audio_driver(xine, ao_port);
  /* fprintf(stderr, "Audio driver: %s (%d)\n", ao_driver.c_str(), gad.pos); */

  ao_port = xine_open_audio_driver(xine, ao_driver.c_str(), NULL);

  if (ao_port == NULL){

    DialogWaitPrint pdialog(4000);
    pdialog.add_line(dgettext("mms-audio-xine", "Audio device unavailable: ") + ao_driver);
    pdialog.print();
    return false;
  }

  /* Xine uses its own config file for a lot of stuff */
   xine_cfg_entry_t config;

  /* for some reason this doesn't work for someone

  if (!xine_config_lookup_entry(xine, "input.cdda_device", &config)) {
    fprintf(stderr, "Xine: Can't set cdda device\n");
  }
  else{
    std::string str = S_Cd::get_instance()->get_device();
    config.str_value =  const_cast<char*>(str.c_str());
    xine_config_update_entry(xine, &config);
  } */

  /* Disable CDDB, we have our own CDDB library  */
  if (xine_config_lookup_entry(xine, "media.audio_cd.use_cddb", &config)){
    config.num_value = 0;
    xine_config_update_entry(xine, &config);
  }

  stream = xine_stream_new(xine, ao_port, NULL);

  if (stream == NULL){
    xine_close_audio_driver(xine, ao_port);
    ao_port = NULL;
    return false;
  }

  /* xine_set_param(stream, XINE_PARAM_VERBOSITY, XINE_VERBOSITY_DEBUG); */

  if (event_queue)
    xine_event_dispose_queue(event_queue);

  xine_set_param( stream, XINE_PARAM_METRONOM_PREBUFFER, 6000 );
  xine_set_param( stream, XINE_PARAM_IGNORE_VIDEO, 1 );
#ifdef XINE_PARAM_EARLY_FINISHED_EVENT
#ifdef XINE_PARAM_GAPLESS_SWITCH
  if (xine_check_version(1,1,1))
    xine_set_param(stream, XINE_PARAM_EARLY_FINISHED_EVENT, 1);

#ifdef XINE_PARAM_DELAY_FINISHED_EVENT
  xine_set_param(stream, XINE_PARAM_DELAY_FINISHED_EVENT, 0);
#endif
 
#endif
#endif

  event_queue = xine_event_new_queue(stream);
  mixer_cap = false;
  is_muted = xine_get_param(stream, XINE_PARAM_AUDIO_MUTE);
  if (is_muted == -1){
    is_muted = xine_get_param(stream, XINE_PARAM_AUDIO_AMP_MUTE);
    mixer_cap = true;
  }

  xine_event_create_listener_thread(event_queue, &Xine::event_listener, reinterpret_cast<void*>(this));
  return true;
}
Example #4
0
void inputRZImpl::print()
{
    QString fname = EGSdir + EGSfileName;
    QPrinter* printer = new QPrinter;
    printer->setPageSize( QPrinter::Letter );
    const int Margin = 20;
    const int MarginY = 30;
    int pageNo = 1;

    QPrintDialog pdialog(printer,this);

    if ( pdialog.exec()) {

cout << "let's print !!!" << endl;


        QPainter paint( printer );
        //if( !paint.begin( printer ) )              // paint on printer
        //     return;

       static const char *fonts[] = { "Helvetica", "Courier", "Times", 0 };
       static int	 sizes[] = { 10, 12, 18, 24, 36, 0 };
       int yPos = 0;

       QFont fontNormal( fonts[1], sizes[0] );
       QFont fontBold( fonts[0], sizes[0] );
       fontBold.setWeight( QFont::Black);

       paint.setFont( fontBold );
       QFontMetrics fmBold = paint.fontMetrics();
       paint.setFont( fontNormal );
       QFontMetrics fm = paint.fontMetrics();

       //qt3to4 -- BW
       //Q3PaintDeviceMetrics metrics( printer ); // need width/height

       QFile              fi( fname );
       //qt3to4 -- BW
       //Q3TextStream ts( &fi );
       QTextStream ts( &fi );
       QString          t;
       int StepsPerPage =  500;

       int LinesPerPage = (printer->height() - 2* MarginY) / fm.lineSpacing();
       if ( fi.open( QIODevice::ReadOnly ) ) {

            int NumOfPages = 1 + TotalTextLines( fname ) / LinesPerPage;
            int totalSteps = StepsPerPage * NumOfPages;

            QString msg( "Printing (page " );
                         msg += QString::number( pageNo );
                         msg += ")...";
            //qt3to4 -- BW
            //Q3ProgressDialog* dialog = new Q3ProgressDialog(msg, "Cancel",
             //                                                               totalSteps, this, "progress", true);
            QProgressDialog* dialog = new QProgressDialog(msg, "Cancel",0,totalSteps);
            //dialog->setTotalSteps( totalSteps );
            //dialog->setProgress( 0 );
            dialog->setValue(0);
            dialog->setMinimumDuration( 0 );

            int progress_count = 0;

           QString gui = "EGSnrc GUI for RZ Geometries:  " + EGSfileName;
           QDate currDate = QDate::currentDate();
           QString date = currDate.toString ( "dd.MM.yyyy" );
           paint.setFont( fontBold );
           paint.drawText( Margin, 0,  printer->width() - 2*Margin, fmBold.lineSpacing(),
                        Qt::AlignLeft | Qt::RichText, gui );
           paint.drawText( Margin, 0,  printer->width() - 2*Margin, fmBold.lineSpacing(),
                        Qt::AlignRight, date );
           paint.drawLine( Margin, MarginY - 10, printer->width() - Margin, MarginY - 10 );
           paint.drawLine( Margin, printer->height() - MarginY + 10,
                                    printer->width() - Margin, printer->height() - MarginY + 10 );
           paint.drawText( Margin, printer->height() - fmBold.lineSpacing(),
	                       printer->width(), fmBold.lineSpacing(),
                                     Qt::AlignHCenter, QString::number( pageNo ) );
           paint.setFont( fontNormal );

           do {
                progress_count++;
                qApp->processEvents();
                if ( dialog->wasCanceled() )
                     dialog->close();
                t = ts.readLine();

                if ( MarginY + yPos + fm.lineSpacing() > printer->height() - MarginY ) {
                         do{
                                    //dialog->setProgress( ++progress_count );
                                    dialog->setValue(++progress_count );
                         }while ( progress_count < StepsPerPage*pageNo );
	           msg = "Printing (page " + QString::number( ++pageNo ) + ")...";
	           dialog->setLabelText( msg );
                         printer->newPage();             // no more room on this page
                         yPos = 0;                       // back to top of page
                         paint.setFont( fontBold );
                         paint.drawText( Margin, 0,  printer->width() - 2*Margin, fmBold.lineSpacing(),
                                                   Qt::AlignLeft | Qt::RichText, gui );
                         paint.drawText( Margin, 0,  printer->width() - 2*Margin, fmBold.lineSpacing(),
                                                  Qt::AlignRight, date );
                        paint.drawLine( Margin, MarginY - 10, printer->width() - Margin, MarginY - 10 );
	          paint.drawLine( Margin, printer->height() - MarginY + 10,
                                    printer->width() - Margin, printer->height() - MarginY + 10 );
                        paint.drawText( Margin, printer->height() - fmBold.lineSpacing(),
	                       printer->width(), fmBold.lineSpacing(),
                                     Qt::AlignHCenter, QString::number( pageNo ) );
                         paint.setFont( fontNormal );
                }

                paint.drawText( Margin, MarginY + yPos,
                        printer->width(), fm.lineSpacing(),
                        Qt::TextExpandTabs | Qt::TextDontClip, t );

                yPos = yPos + fm.lineSpacing();

               dialog->setValue( progress_count );

           //qt3to4 -- BW
           //} while ( !ts.eof() );
          } while ( !ts.atEnd() );

          do{
               dialog->setValue( ++progress_count );
           }while ( progress_count < totalSteps );

          dialog->setValue( totalSteps );
          zap(dialog);
       }
       else {
               QMessageBox::critical( 0,
                        tr("Error printing "),
	          tr("Couldn't open file %1").arg(fname),
                        tr("Quit") );
       }

       fi.close();

    }
    else {
             QMessageBox::information( this, "Printing status", "Printing aborted");
    }

    delete printer;
}