void Stream::connect() { if (isPassive()) m_timer->addObserver(*this, PassiveStreamTimerPriority); else m_timer->addObserver(*this, ActiveStreamTimerPriority); }
AVPacket* Stream::popEncodedData() { AVPacket* result = nullptr; sf::Lock l(m_readerMutex); if (!m_packetList.size() && !isPassive()) { m_dataSource.requestMoreData(*this); } if (m_packetList.size()) { result = m_packetList.front(); m_packetList.pop_front(); } else { if (m_stream->codec->codec->capabilities & CODEC_CAP_DELAY) { AVPacket* flushPacket = (AVPacket*)av_malloc(sizeof(*flushPacket)); av_init_packet(flushPacket); flushPacket->data = nullptr; flushPacket->size = 0; result = flushPacket; sfeLogDebug("Sending flush packet: " + mediaTypeToString(getStreamKind())); } } return result; }
void ThreadedAudioDevice::waitForThread(int waitMs) { if (!isPassive()) { assert(_thread != 0); // should not get called again! PRINT1("ThreadedAudioDevice::waitForThread: waiting for thread to finish\n"); if (pthread_join(_thread, NULL) == -1) { PRINT0("ThreadedAudioDevice::doStop: terminating thread!\n"); // JWM: pthread_cancel is not available in Android //pthread_cancel(_thread); //_thread = 0; } PRINT1("\tThreadedAudioDevice::waitForThread: thread done\n"); } }
void ThreadedAudioDevice::waitForThread(int waitMs) { if (!isPassive()) { //f assert(_thread != 0); // should not get called again! PRINT1("ThreadedAudioDevice::waitForThread: waiting for thread to finish\n"); // if (pthread_join(_thread, NULL) == -1) { // PRINT0("ThreadedAudioDevice::doStop: terminating thread!\n"); //#ifndef OF_ANDROID // pthread_cancel(_thread); //#endif // _thread = 0; // } PRINT1("\tThreadedAudioDevice::waitForThread: thread done\n"); } }
int ThreadedAudioDevice::startThread() { stopping(false); // Reset. if (isPassive()) // Nothing else to do here if passive mode. return 0; starting(true); #ifdef PROFILE getitimer(ITIMER_PROF, &globalTimerVal); #endif PRINT1("\tThreadedAudioDevice::startThread: starting thread\n"); int status = pthread_create(&_thread, NULL, _runProcess, this); if (status < 0) { error("Failed to create thread"); } return status; }
int ThreadedAudioDevice::startThread() { stopping(false); // Reset. if (isPassive()) // Nothing else to do here if passive mode. return 0; starting(true); #ifdef PROFILE getitimer(ITIMER_PROF, &globalTimerVal); #endif PRINT1("\tThreadedAudioDevice::startThread: starting thread\n"); // pthread_attr_t attr; // pthread_attr_init(&attr); // int status = pthread_attr_setschedpolicy(&attr, SCHED_RR); //if (status != 0) { // fprintf(stderr, "startThread: Failed to set scheduling policy\n"); //} // status = pthread_create(&_thread, &attr, _runProcess, this); // pthread_attr_destroy(&attr); //if (status < 0) { // error("Failed to create thread"); //} return 0; }