Ignore:
Timestamp:
May 3, 2016, 5:25:45 PM (9 years ago)
Author:
Silvan Scherrer
Message:

smplayer: update trunk to version 16.4

Location:
smplayer/trunk
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • smplayer/trunk

  • smplayer/trunk/src/playerprocess.cpp

    r175 r176  
    4848        if (isRunning()) {
    4949                qDebug("PlayerProcess::writeToStdin: %s", text.toUtf8().constData());
     50#if !defined(Q_OS_OS2)
    5051                #ifdef Q_OS_WIN
    5152                write( text.toUtf8() + "\n");
     
    5354                write( text.toLocal8Bit() + "\n");
    5455                #endif
     56#else
     57                PpipeWrite( text.toLocal8Bit() + "\n");
     58#endif
    5559        } else {
    5660                qWarning("PlayerProcess::writeToStdin: process not running");
    5761        }
     62#ifdef Q_OS_OS2
     63        if (text == "quit" || text == "quit\n") {
     64                PpipeClose();
     65        }
     66#endif
     67
    5868}
    5969
     
    98108#endif
    99109
     110#ifdef Q_OS_OS2
     111void PlayerProcess::PpipeOpen(const char *szPipeName) {
     112        DosCreateNPipe( szPipeName, &hpipe, NP_ACCESS_DUPLEX, 1, 1024, 1024, 0 );
     113}
     114
     115void PlayerProcess::PpipeClose( void ) {
     116        DosClose( hpipe );
     117}
     118
     119void PlayerProcess::PpipeWrite( const QByteArray text ) {
     120        // MPlayer quitted ?
     121        if ( !isRunning() )
     122                return;
     123
     124// as things could hang when pipe communication is done direct here, i do a seperate thread for it
     125        pipeThread = new PipeThread(text, hpipe);
     126   
     127        pipeThread->start();
     128        while (!pipeThread->isRunning() && !pipeThread->isFinished()) {
     129                qDebug("we sleep");
     130                DosSleep(10);
     131        }
     132// we wait for max 2 seconds for the thread to be ended (we to this with max 20 loops)
     133        int count = 0;
     134        while (!pipeThread->wait(100) && count < 20) {
     135                count ++;
     136        }
     137        if (count >= 20) {
     138                pipeThread->terminate();
     139                qDebug("pipe communication terminated");
     140        }
     141        delete pipeThread;
     142}
     143
     144PipeThread::PipeThread(const QByteArray t, const HPIPE pipe) {
     145        text = t;
     146        hpipe = pipe;
     147}
     148
     149PipeThread::~PipeThread() {
     150}
     151
     152void PipeThread::run() {
     153        ULONG cbActual;
     154        APIRET rc = NO_ERROR;
     155
     156        rc = DosConnectNPipe( hpipe );
     157        if (rc != NO_ERROR)
     158                return;
     159
     160//      qDebug("pipe connected");   
     161        DosWrite( hpipe, text.data(), strlen( text.data() ), &cbActual );
     162
     163        // Wait for ACK
     164        DosRead( hpipe, &cbActual, sizeof( ULONG ), &cbActual );
     165        DosDisConnectNPipe( hpipe );
     166        return;
     167}
     168#endif
     169
    100170#include "moc_playerprocess.cpp"
Note: See TracChangeset for help on using the changeset viewer.