Changeset 118 for smplayer/vendor/current/src/mplayerprocess.cpp
- Timestamp:
- Dec 22, 2011, 6:27:52 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/vendor/current/src/mplayerprocess.cpp
r90 r118 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 0Ricardo Villalba <rvm@escomposlinux.org>2 Copyright (C) 2006-2011 Ricardo Villalba <rvm@escomposlinux.org> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 79 79 80 80 MyProcess::start(); 81 82 #if !defined(Q_OS_OS2) 81 83 return waitForStarted(); 84 #else 85 bool r = waitForStarted(); 86 if (r) { 87 pidMP = QProcess::pid(); 88 qDebug("MPlayer PID %i", pidMP); 89 MPpipeOpen(); 90 } 91 return r; 92 #endif 82 93 } 83 94 … … 85 96 if (isRunning()) { 86 97 //qDebug("MplayerProcess::writeToStdin"); 98 #if !defined(Q_OS_OS2) 87 99 write( text.toLocal8Bit() + "\n"); 100 #else 101 MPpipeWrite( text.toLocal8Bit() + "\n"); 102 #endif 88 103 } else { 89 104 qWarning("MplayerProcess::writeToStdin: process not running"); 90 105 } 91 } 106 #ifdef Q_OS_OS2 107 if (text == "quit" || text == "quit\n") { 108 MPpipeClose(); 109 } 110 #endif 111 } 112 113 #ifdef Q_OS_OS2 114 void MplayerProcess::MPpipeOpen() { 115 char szPipeName[ 100 ]; 116 sprintf( szPipeName, "\\PIPE\\MPLAYER\\%x", pidMP ); 117 DosCreateNPipe( szPipeName, &hpipe, NP_ACCESS_DUPLEX, 1, 1024, 1024, 0 ); 118 } 119 120 void MplayerProcess::MPpipeClose( void ) { 121 DosClose( hpipe ); 122 } 123 124 void MplayerProcess::MPpipeWrite( const QByteArray text ) { 125 // MPlayer quitted ? 126 if ( !isRunning() ) 127 return; 128 129 // as things could hang when pipe communication is done direct here, i do a seperate thread for it 130 pipeThread = new PipeThread(text, hpipe); 131 132 pipeThread->start(); 133 while (!pipeThread->isRunning() && !pipeThread->isFinished()) { 134 qDebug("we sleep"); 135 DosSleep(10); 136 } 137 // we wait for max 2 seconds for the thread to be ended (we to this with max 20 loops) 138 int count = 0; 139 while (!pipeThread->wait(100) && count < 20) { 140 count ++; 141 } 142 if (count >= 20) { 143 pipeThread->terminate(); 144 qDebug("pipe communication terminated"); 145 } 146 delete pipeThread; 147 } 148 #endif 92 149 93 150 static QRegExp rx_av("^[AV]: *([0-9,:.-]+)"); … … 812 869 } 813 870 871 #ifdef Q_OS_OS2 872 PipeThread::PipeThread(const QByteArray t, const HPIPE pipe) { 873 text = t; 874 hpipe = pipe; 875 } 876 877 PipeThread::~PipeThread() { 878 } 879 880 void PipeThread::run() { 881 ULONG cbActual; 882 APIRET rc = NO_ERROR; 883 884 rc = DosConnectNPipe( hpipe ); 885 if (rc != NO_ERROR) 886 return; 887 888 // qDebug("pipe connected"); 889 DosWrite( hpipe, text.data(), strlen( text.data() ), &cbActual ); 890 891 // Wait for ACK 892 DosRead( hpipe, &cbActual, sizeof( ULONG ), &cbActual ); 893 DosDisConnectNPipe( hpipe ); 894 return; 895 } 896 #endif 897 814 898 #include "moc_mplayerprocess.cpp"
Note:
See TracChangeset
for help on using the changeset viewer.