Changeset 176 for smplayer/trunk/src/playerprocess.cpp
- Timestamp:
- May 3, 2016, 5:25:45 PM (9 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 175
- Property svn:mergeinfo changed
-
smplayer/trunk/src/playerprocess.cpp
r175 r176 48 48 if (isRunning()) { 49 49 qDebug("PlayerProcess::writeToStdin: %s", text.toUtf8().constData()); 50 #if !defined(Q_OS_OS2) 50 51 #ifdef Q_OS_WIN 51 52 write( text.toUtf8() + "\n"); … … 53 54 write( text.toLocal8Bit() + "\n"); 54 55 #endif 56 #else 57 PpipeWrite( text.toLocal8Bit() + "\n"); 58 #endif 55 59 } else { 56 60 qWarning("PlayerProcess::writeToStdin: process not running"); 57 61 } 62 #ifdef Q_OS_OS2 63 if (text == "quit" || text == "quit\n") { 64 PpipeClose(); 65 } 66 #endif 67 58 68 } 59 69 … … 98 108 #endif 99 109 110 #ifdef Q_OS_OS2 111 void PlayerProcess::PpipeOpen(const char *szPipeName) { 112 DosCreateNPipe( szPipeName, &hpipe, NP_ACCESS_DUPLEX, 1, 1024, 1024, 0 ); 113 } 114 115 void PlayerProcess::PpipeClose( void ) { 116 DosClose( hpipe ); 117 } 118 119 void 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 144 PipeThread::PipeThread(const QByteArray t, const HPIPE pipe) { 145 text = t; 146 hpipe = pipe; 147 } 148 149 PipeThread::~PipeThread() { 150 } 151 152 void 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 100 170 #include "moc_playerprocess.cpp"
Note:
See TracChangeset
for help on using the changeset viewer.