void decode() { // While we need to fill the buffer... while ( (mad_frame_decode(&frame, &stream) == -1) && ((stream.error == MAD_ERROR_BUFLEN) || (stream.error == MAD_ERROR_BUFPTR)) ) { // Fill up the remainder of the file buffer. int tmp; tmp = fillFileBuffer(); if (tmp==2) { endofstream = 1; //MusicPlayerNextSong(); /*! * * Put here the function that does something when the file has ended. * */ } // Give new buffer to the stream. mad_stream_buffer(&stream, fileBuffer, sizeof(fileBuffer)); } // Add to the timer the stream duration mad_timer_add(&timer, frame.header.duration); // Synth the frame. mad_synth_frame(&synth, &frame); }
void Logger::log(const std::string &tag, const char *funcName, const char *sourceFile, unsigned int lineNum, const std::string& fmt, ...) { std::string fileBuffer; fillFileBuffer(fileBuffer, tag, fmt, funcName, sourceFile, lineNum); // Print to file va_list args; const char* bufferCStr = fileBuffer.c_str(); va_start(args, bufferCStr); vfprintf(m_pLogFile, bufferCStr, args); va_end(args); if (printToScreen) { std::string outputBuffer; fillOutputBuffer(outputBuffer, tag, fmt, funcName, sourceFile, lineNum); // Print to screen const char* bufferCStr = outputBuffer.c_str(); va_start(args, bufferCStr); vfprintf(stdout, bufferCStr, args); va_end(args); } }