DirectShowPlayerService::~DirectShowPlayerService() { { QMutexLocker locker(&m_mutex); releaseGraph(); m_pendingTasks = Shutdown; ::SetEvent(m_taskHandle); } m_taskThread->wait(); delete m_taskThread; if (m_audioOutput) { m_audioOutput->Release(); m_audioOutput = 0; } if (m_videoOutput) { m_videoOutput->Release(); m_videoOutput = 0; } delete m_playerControl; delete m_audioEndpointControl; delete m_metaDataControl; delete m_videoRendererControl; #ifndef Q_WS_SIMULATOR delete m_videoWindowControl; #endif ::CloseHandle(m_taskHandle); CoUninitialize(); }
int main(int argc, char **agv) { int i; int visited[SIZE]; Graph *graph = initGraph(SIZE); printf("%d\n", sizeof(int **)); graph->edgeMat[0][1] = 1; graph->edgeMat[0][2] = 1; graph->edgeMat[1][2] = 1; graph->edgeMat[2][0] = 1; graph->edgeMat[2][3] = 1; graph->edgeMat[3][3] = 1; for(i = 0; i < graph->V; i++) { visited[i] = 0; } printf("DFS rec "); depthFirstSearch(graph, visited, 2); for(i = 0; i < graph->V; i++) { visited[i] = 0; } printf("\n DFS non_rec "); depthFirstSearchNonRec(graph, visited, 2); printf("\n BFS non_rec"); breadthFirstSearch(graph, 2); releaseGraph(graph); return 0; }
int main(int argc, char ** argv) { Graph *g; GraphIteratorRef i; HCStateRef hc; VArray *vo; Status stat = STATUS_OK; StatusRef s = &stat; UInt pts; UInt t; bool prune = 0; if (argc == 1) { print_usage(); exit(0); } /* first scan arguments for -h or -p flags */ for (t = 0; t < argc; t++) { if (argv[t][0] == '-' && argv[t][1]){ if (argv[t][1]=='h'){ print_usage(); exit(0); } prune = argv[t][1] == 'p'; } } i = allocateGraphIterator(s); initGraphIteratorWithFiles(i,argc - 1 , ++argv); while ( loadNextGraph(i, &g, s) ){ pts = g->vertex_count; vo = sortVerticesDegreeDesc( initVArray(allocateVArray(pts, s)), g->degree); hc = initHCState(allocateHCState(g->vertex_count, s), g->degree, g->adj_lists, vo); if (prune) { if (firstHamiltonianCycle(hc)){ printf("%s is Hamiltonian.\n", g->name); } } else { if (firstHamiltonianCycleWithPruning(hc)){ printf("%s is Hamiltonian.\n", g->name); } } releaseHCState(hc); releaseVArray(vo); releaseGraph(g); } releaseGraphIterator(i); return 0; }
void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream) { QMutexLocker locker(&m_mutex); m_pendingTasks = 0; if (m_graph) releaseGraph(); m_resources = media.resources(); m_stream = stream; m_error = QMediaPlayer::NoError; m_errorString = QString(); m_position = 0; m_duration = 0; m_streamTypes = 0; m_executedTasks = 0; m_buffering = false; m_seekable = false; m_atEnd = false; m_metaDataControl->updateGraph(0, 0); if (m_resources.isEmpty() && !stream) { m_pendingTasks = 0; m_graphStatus = NoMedia; m_url.clear(); } else if (stream && (!stream->isReadable() || stream->isSequential())) { m_pendingTasks = 0; m_graphStatus = InvalidMedia; m_error = QMediaPlayer::ResourceError; } else { // {36b73882-c2c8-11cf-8b46-00805f6cef60} static const GUID iid_IFilterGraph2 = { 0x36b73882, 0xc2c8, 0x11cf, {0x8b, 0x46, 0x00, 0x80, 0x5f, 0x6c, 0xef, 0x60} }; m_graphStatus = Loading; m_graph = com_new<IFilterGraph2>(CLSID_FilterGraph, iid_IFilterGraph2); if (stream) m_pendingTasks = SetStreamSource; else m_pendingTasks = SetUrlSource; ::SetEvent(m_taskHandle); } m_playerControl->updateError(m_error, m_errorString); m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); m_playerControl->updateState(QMediaPlayer::StoppedState); m_playerControl->updatePosition(m_position); updateStatus(); }
QMediaControl *DirectShowPlayerService::requestControl(const char *name) { if (qstrcmp(name, QMediaPlayerControl_iid) == 0) { return m_playerControl; } else if (qstrcmp(name, QAudioEndpointSelector_iid) == 0) { return m_audioEndpointControl; } else if (qstrcmp(name, QMetaDataReaderControl_iid) == 0) { return m_metaDataControl; } else if (qstrcmp(name, QVideoRendererControl_iid) == 0) { #ifndef Q_WS_SIMULATOR if (!m_videoRendererControl && !m_videoWindowControl) { #else if (!m_videoRendererControl) { #endif m_videoRendererControl = new DirectShowVideoRendererControl(m_loop); connect(m_videoRendererControl, SIGNAL(filterChanged()), this, SLOT(videoOutputChanged())); return m_videoRendererControl; } #ifndef Q_WS_SIMULATOR } else if (qstrcmp(name, QVideoWindowControl_iid) == 0) { if (!m_videoRendererControl && !m_videoWindowControl) { m_videoWindowControl = new Vmr9VideoWindowControl; setVideoOutput(m_videoWindowControl->filter()); return m_videoWindowControl; } #endif } return 0; } void DirectShowPlayerService::releaseControl(QMediaControl *control) { if (!control) { qWarning("QMediaService::releaseControl():" " Attempted release of null control"); } else if (control == m_videoRendererControl) { setVideoOutput(0); delete m_videoRendererControl; m_videoRendererControl = 0; #ifndef Q_WS_SIMULATOR } else if (control == m_videoWindowControl) { setVideoOutput(0); delete m_videoWindowControl; m_videoWindowControl = 0; #endif } } void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream) { QMutexLocker locker(&m_mutex); m_pendingTasks = 0; if (m_graph) releaseGraph(); m_resources = media.resources(); m_stream = stream; m_error = QMediaPlayer::NoError; m_errorString = QString(); m_position = 0; m_duration = 0; m_streamTypes = 0; m_executedTasks = 0; m_buffering = false; m_seekable = false; m_atEnd = false; m_metaDataControl->updateGraph(0, 0); if (m_resources.isEmpty() && !stream) { m_pendingTasks = 0; m_graphStatus = NoMedia; m_url.clear(); } else if (stream && (!stream->isReadable() || stream->isSequential())) { m_pendingTasks = 0; m_graphStatus = InvalidMedia; m_error = QMediaPlayer::ResourceError; } else { // {36b73882-c2c8-11cf-8b46-00805f6cef60} static const GUID iid_IFilterGraph2 = { 0x36b73882, 0xc2c8, 0x11cf, {0x8b, 0x46, 0x00, 0x80, 0x5f, 0x6c, 0xef, 0x60} }; m_graphStatus = Loading; m_graph = com_new<IFilterGraph2>(CLSID_FilterGraph, iid_IFilterGraph2); if (stream) m_pendingTasks = SetStreamSource; else m_pendingTasks = SetUrlSource; ::SetEvent(m_taskHandle); } m_playerControl->updateError(m_error, m_errorString); m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); m_playerControl->updateState(QMediaPlayer::StoppedState); m_playerControl->updatePosition(m_position); updateStatus(); }