Пример #1
0
void OMXPlayerSync::update ( int src_alpha )
{
   if( ( syncType == SYNC_SERVER )  )
    {
      alpha = src_alpha;
      syncServer();
    }

   if ( updateTicker >= UPDATE_THRESHOLD )
   {
      if( ( syncType == SYNC_CLIENT )  )
      {
//	 printf( "\r%d = ", updateTicker );
	 syncClient( true );
         updateJitter ();
         updateSpeed ();
      }
      updateTicker = 0;
      displayVerbose ();
   }
   else
   {
      syncClient( false );
      updateTicker++;
   }
}
Пример #2
0
/* Forks a process to run in background and                            *
 * 1) Listen for server broadcasting its play time                     *
 * 2) Listen for clients indicating that they are ready to run         *
 */
void OMXPlayerSync::start ( bool m_pause )
{
   // Pause movie, unpause later via tcp communication

   if ( syncType == SYNC_SERVER )
   {
    if( m_pause )
    {
	pause = true;
	printf( "%d: Pause\n", port );
	pauseMovie();
    }
    printf("%d: Connect\n", port);
    setUpConnection ();
    printf("%d: Sync\n", port);
    syncServer ();
    unpauseMovie();
    printf("%d: Broadcast\n", port);
    ServerBcast();
   }
   else
   { //Client
    printf("%d: Pause\n", port);
    pauseMovie ();
    pause = true;
    printf("%d: Connect\n", port);
    setUpConnection ();
    printf("%d: Sync\n", port);
    syncClient ( false );
    printf("%d: Unpause\n", port);
    unpauseMovie ();
   }
   printf("%d: Go\n", port);
   displayVerbose ();
}
Пример #3
0
/**
 * @brief If is currently a server, reports updates in sync journal to the central services.
 * @return True if success
 */
bool CentralServiceReporter::reportSyncJournal()
{
    QObject parent;
    if (!m_proxyConnection->session(&parent)->isServer())
        return true;

    bool ok;
    QVariantMap serverState = getServerSyncState(&ok);
    if (!ok) {
        m_proxyConnection->message("Central Service Report: Failed to access the service");
        return false;
    }

    SyncServer syncServer(m_proxyConnection);
    QVariantList updates = syncServer.updates(serverState, true, QString());
    if (!updates.count())
        return true;

    ISettings *settings = m_proxyConnection->settings(&parent);
    settings->beginGroup("current_workspace");

    QVariantMap message;
    message.insert("workspace_id", settings->value("id").toString());
    message.insert("workspace_name", settings->value("name").toString());

    bool success = true;
    if (updates.count() < MaxUpdatesInReport) {
        message.insert("updates", updates);
        success = sendUpdates(message);
    } else {
        for (int i = 0; i < updates.count() && success; i += MaxUpdatesInReport) {
            message.insert("updates", updates.mid(i, MaxUpdatesInReport));
            success = sendUpdates(message);
        }
    }
    if (!success)
        m_proxyConnection->message("Central Service Report: Failed to report updates to the service");
    return success;
}