예제 #1
0
void DemodulatorInstance::terminate() {

#if ENABLE_DIGITAL_LAB
    if (activeOutput) {
        closeOutput();
    }
#endif

//    std::cout << "Terminating demodulator audio thread.." << std::endl;
    audioThread->terminate();

//    std::cout << "Terminating demodulator thread.." << std::endl;
    demodulatorThread->terminate();
   
//    std::cout << "Terminating demodulator preprocessor thread.." << std::endl;
    demodulatorPreThread->terminate();

    if (audioSinkThread != nullptr) {
        stopRecording();
    }

    //that will actually unblock the currently blocked push().
    pipeIQInputData->flush();
    pipeAudioData->flush();
    pipeIQDemodData->flush();
    threadQueueControl->flush();
}
예제 #2
0
파일: loopback.cpp 프로젝트: bekiS/qlcplus
Loopback::~Loopback()
{
    for (int i = 0; i < QLCIOPLUGINS_UNIVERSES; i++)
    {
        closeOutput(i);
        closeInput(i);
        delete [] m_values[i];
    }
}
예제 #3
0
bool DemodulatorInstance::isTerminated() {
    while (!pipeDemodNotify->empty()) {
        DemodulatorThreadCommand cmd;
        pipeDemodNotify->pop(cmd);

        switch (cmd.cmd) {
        case DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED:
            if (t_Audio) {
                t_Audio->join();
                audioTerminated = true;
                delete t_Audio;
                t_Audio = nullptr;
            }
            break;
        case DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED:
            if (t_Demod) {
                #ifdef __APPLE__
                pthread_join(t_Demod, nullptr);
                #else
                t_Demod->join();
                delete t_Demod;
                #endif
                t_Demod = nullptr;
            }
#if ENABLE_DIGITAL_LAB
            if (activeOutput) {
                closeOutput();
            }
#endif
            demodTerminated = true;
            break;
        case DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_PREPROCESS_TERMINATED:
            if (t_PreDemod) {
                #ifdef __APPLE__
                pthread_join(t_PreDemod, NULL);
                #else
                t_PreDemod->join();
                delete t_PreDemod;
                #endif
                preDemodTerminated = true;
                t_PreDemod = nullptr;
            }
            break;
        default:
            break;
        }
    }

    terminated = audioTerminated && demodTerminated && preDemodTerminated;

    return terminated;
}
예제 #4
0
파일: audio.cpp 프로젝트: czaks/qTox
/**
@brief Unsubscribe from capturing from an opened input device.

If the input device has no more subscriptions, it will be closed.
*/
void Audio::unsubscribeInput()
{
    qDebug() << "unsubscribing input" << inputSubscriptions;
    if (inputSubscriptions > 0)
        inputSubscriptions--;
    else if(inputSubscriptions < 0)
        inputSubscriptions = 0;

    if (!inputSubscriptions) {
        closeOutput();
        closeInput();
    }
}
예제 #5
0
void NamedLogWriter::open_(
    const boost::filesystem::path &path,
    const bool append)
{
    if (hasOutput()) {
        BOOST_THROW_EXCEPTION(OpenedWriterError() <<
                              OpenedWriterError::Path(path_));
    }
    try {
        path_ = path;
        if (append) {
            auto input = detail::openFileReadOnly(path_);
            boost::uuids::uuid format;
            detail::readFormatMagic(*input, format);
            if (format != MAGIC_FORMAT) {
                BOOST_THROW_EXCEPTION(IncompatibleFormatError() <<
                                      IncompatibleFormatError::Format(format));
            }
            auto logReader = detail::make_unique<LogReader>(std::move(input));
            if (logReader->messageTypePool().header() != pool_.header()) {
                BOOST_THROW_EXCEPTION(IncompatibleHeaderError());
            }
            logReader->fastCheck();
        }
        setOutput(openFile_(path_, append));
        if (append) {
            writeContinue();
        } else {
            try {
                write(nullptr, *headerData_);
            } catch (std::exception &) {
                BOOST_THROW_EXCEPTION(UnableToWriteHeaderError() <<
                                      enable_nested_current());
            }
        }
    } catch (std::exception &) {
        if (boost::exception *const e = boost::current_exception_cast<boost::exception>()) {
            *e << Error::Path(path_);
        }
        state_ = State::kBad;
        try { closeOutput(); } catch (std::exception &) {}
        throw;
    }
}
예제 #6
0
파일: main.c 프로젝트: Mohnish-SPU/DrumHero
void startRec()
{
	if(RecFlag == 0)
	{	
		setWindow(window,"mohnish/gb-drum-kit record1.jpg");
		printf("%d-Tempo \n",Tempo);
		setTempo(Tempo);
		setTime(4,4);
		openOutput(SongName,0,0);
		RecFlag = 1;
		PlayFlag = 1;
	}
	else
	{
		closeOutput();
		setWindow(window,"mohnish/gb-drum-kit changed1.jpg");
		RecFlag = 0;
	}	
}
예제 #7
0
void NamedLogWriter::write(
    const std::string &typeName,
    const google::protobuf::Message &message)
{
    if (!hasOutput()) {
        BOOST_THROW_EXCEPTION(ClosedWriterError());
    }
    BOOST_ASSERT(headerData_);
    try {
        write(&typeName, message);
    } catch (std::exception &e) {
        if (recoverable(e)) {
            state_ = State::kFail;
        } else {
            state_ = State::kBad;
            try { closeOutput(); } catch (std::exception &) {}
        }
        BOOST_THROW_EXCEPTION(UnableToWriteMessageError() <<
                              enable_nested_current());
    }
}
int main (int argc, char *argv[])
{
int i = 0;                      /* index & counter */

char line[MAXCHAR + 1] = "";            /* working line buffer  */
char previousLine [MAXCHAR + 1] = "";   /* previous line buffer  */

char author[MAXNAME + 1] = "";          /* author of the comments name */
int page = 0;                           /* page number */

FILE *filein = NULL;                    /* input file (author's comments) */
FILE *fileout = NULL;                   /* current output file (one comment) */ 

LINE_ANALYSIS_RESULT status = START_COMMENT;    /* result of line analysis */

/* 
 * check input parameter
 */
if (argc != 2)
    {
    printf("Usage:  splitIntoSingleComments  <input_file>\n");
    exit(-1);
    }
else
    {
    printf("-->Processing: %s\n", argv[1]);
    }
/* 
 * open input file
 */
filein = fopen(argv[1], "r");

/* 
 * extract from input file name (<author>.comments) the <author> field.
 *  REMARK: the first encountered dot '.' is used as separator.
 */
strcpy(author, argv[1]);
i = 0;
while (author[i] != '.')
    {
    i++;
    }
author[i] = '\0';

/* 
 * open the first output file (000): it will contains everything between the
 * beginning of the file and the first comment.
 */
fileout = openOutput(page, author);

/* 
 * process all lines in the input file
 */
while (getLine(filein, line) != EOF )
    {
    status = treatLine(line, previousLine, &page);
    switch (status)
        {
        case START_COMMENT:
            /* 
             * - close current output
             * - open a new output file (<ppp>-<author>.tmp_single_comments)
             * - write the sepaartor line (80 "-")
             * - copy the line into current output file
             */
            if ( previousLine[0] != '\0')
                fprintf(fileout, "\n");
            closeOutput(fileout, previousLine);

            fileout = openOutput(page, author);

            fprintf(fileout, "%s\n", line);
            break;

        case COPY:
            /*
             * - copy the line into current output file
             */
            fprintf(fileout, "%s\n", line);
            fflush(fileout);
            break;

        case SKIP:
            /*
             * - skip the line
             */
            break;

        default:
            /*
             * PANIC ERROR
             */
            printf("PANIC ERROR treatLine return status unknown: %d\n", status);
            exit(-1);
            break;
        }
    strcpy(previousLine, line);
    }

closeOutput(fileout, previousLine);

fclose(filein);
exit(0);
}
예제 #9
0
Velleman::~Velleman()
{
    closeOutput(0, 0);
    delete [] m_values;
}
예제 #10
0
void NamedLogWriter::close()
{
    state_ = State::kEof;
    closeOutput();
}
예제 #11
0
HIDDMXDevice::~HIDDMXDevice()
{
    closeInput();
    closeOutput();
    hid_close(m_handle);
}