Ticket #6597: 6597-transcode-win32.2.patch

File 6597-transcode-win32.2.patch, 8.9 KB (added by Jeff Lu <jll544@…>, 15 years ago)

Replaces previous transcode patch; adds fixes for corruption and unclosed filedescriptor for lossless MPEG2

  • programs/programs.pro

     
    1818    SUBDIRS += mythtranscode
    1919}
    2020
    21 mingw: SUBDIRS -= mythtranscode mythtranscode/replex
  • programs/mythtranscode/replex/replex.pro

     
    2323LIBS += -lmythavcodec-$$LIBVERSION -lmythavformat-$$LIBVERSION -lmythavutil-$$LIBVERSION
    2424LIBS += $$EXTRA_LIBS
    2525
     26mingw:LIBS += -lws2_32
     27
    2628isEmpty(QMAKE_EXTENSION_SHLIB) {
    2729  QMAKE_EXTENSION_SHLIB=so
    2830}
  • programs/mythtranscode/replex/replex.c

     
    23902390                                perror("Error opening output file");
    23912391                                exit(1);
    23922392                        }
     2393#ifdef USING_MINGW
     2394                        _setmode(rx.fd_out, _O_BINARY);
     2395#endif         
    23932396                        fprintf(stderr,"Output File is: %s\n",
    23942397                                filename);
    23952398                } else {
     
    24602463                        perror("Error opening output file");
    24612464                        exit(1);
    24622465                }
     2466#ifdef USING_MINGW
     2467                _setmode(rx.dmx_out[0], _O_BINARY);
     2468#endif         
    24632469                fprintf(stderr,"Video output File is: %s\n",
    24642470                        fname);
    24652471               
     
    24772483                                perror("Error opening output file");
    24782484                                exit(1);
    24792485                        }
     2486#ifdef USING_MINGW
     2487                        _setmode(rx.dmx_out[i+1], _O_BINARY);
     2488#endif         
    24802489                        fprintf(stderr,"Audio%d output File is: %s\n",i,fname);
    24812490                }
    24822491               
  • programs/mythtranscode/mythtranscode.pro

     
    99target.path = $${PREFIX}/bin
    1010INSTALLS = target
    1111
     12mingw:LIBS += -lws2_32
     13
    1214QMAKE_CLEAN += $(TARGET)
    1315
    1416# Input
  • programs/mythtranscode/main.cpp

     
    812812    if (gContext->GetNumSetting("TruncateDeletesSlowly", 0))
    813813        return slowDelete(filename);
    814814
    815     return unlink(filename.toLocal8Bit().constData());
     815    QFile ftarget(filename.toLocal8Bit().constData());
     816    return !ftarget.remove();
    816817}
    817818
    818819void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist, int &resultCode)
     
    854855        const QString newfile = cnf;
    855856        const QByteArray anewfile = newfile.toLocal8Bit();
    856857
    857         if (rename(fname.constData(), aoldfile.constData()) == -1)
     858        QFile srcQFile(fname.constData());
     859        if (!srcQFile.rename(aoldfile.constData()))
    858860        {
    859861            VERBOSE(VB_IMPORTANT,
    860862                    QString("mythtranscode: Error Renaming '%1' to '%2'")
    861863                    .arg(filename).arg(oldfile) + ENO);
    862864        }
    863865
    864         if (rename(atmpfile.constData(), anewfile.constData()) == -1)
     866        QFile tmpQFile(atmpfile.constData());       
     867        if (!tmpQFile.rename(anewfile.constData()))
    865868        {
    866869            VERBOSE(VB_IMPORTANT,
    867870                    QString("mythtranscode: Error Renaming '%1' to '%2'")
     
    966969                QFile checkFile(oldfileprev);
    967970
    968971                if ((oldfileprev != newfileprev) && (checkFile.exists()))
    969                     rename(aoldfileprev.constData(), anewfileprev.constData());
     972                    checkFile.rename(anewfileprev.constData());
    970973            }
    971974        }
    972975
  • programs/mythtranscode/transcode.cpp

     
    12011201        fifow->FIFODrain();
    12021202    }
    12031203    delete newFrame;
     1204    // HACK? - destructor apparently never called (Qt3/Qt4 deleteLater issue?)
     1205    // Pointers not reset; shouldn't dtor segfault if it was working properly?
    12041206    if (player_ctx)
    12051207        delete player_ctx;
     1208    // HACK - delete ringbuffer else outfile is open when we try to rename it
     1209    // As before, destructor is supposed to take care of these deletes for us!
     1210    if (nvr)
     1211        delete nvr;
     1212    if (outRingBuffer)
     1213        delete outRingBuffer;
     1214
    12061215    return REENCODE_OK;
    12071216}
    12081217
  • programs/mythtranscode/mpeg2fix.h

     
    131131
    132132  private:
    133133    multiplex_t *mplex;
     134    int fd_out;
    134135};
    135136
    136137class MPEG2fixup
  • programs/mythtranscode/mpeg2fix.cpp

     
    448448
    449449MPEG2replex::MPEG2replex() :
    450450    done(0),      otype(0),
    451     ext_count(0), mplex(0)
     451    ext_count(0), mplex(0), fd_out(0)
    452452{
    453453    memset(&vrbuf, 0, sizeof(vrbuf));
    454454    memset(extrbuf, 0, sizeof(extrbuf));
     
    474474        if (index_extrbuf[i].size)
    475475            ring_destroy(&index_extrbuf[i]);
    476476    }
     477    if (fd_out)
     478            close(fd_out);
    477479}
    478480
    479481int MPEG2replex::WaitBuffers()
     
    530532
    531533
    532534    int video_delay = 0, audio_delay = 0;
    533     int fd_out;
    534535
    535536    memset(&mx, 0, sizeof(mx));
    536537    memset(ext_ok, 0, sizeof(ext_ok));
     
    538539    mx.priv = (void *)this;
    539540
    540541    fd_out = open(outfile, O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
     542#ifdef USING_MINGW
     543    _setmode(fd_out, _O_BINARY);
     544#endif
    541545
    542546    //await buffer fill
    543547    pthread_mutex_lock(&mutex);
     
    10101014        VERBOSE(MPF_IMPORTANT, QString("Couldn't open file %1").arg(filename));
    10111015        return;
    10121016    }
     1017#ifdef USING_MINGW
     1018    _setmode(fh, _O_BINARY);
     1019#endif
    10131020
    10141021    write(fh, info->display_fbuf->buf[0],
    10151022          info->sequence->width * info->sequence->height);
     
    10271034        VERBOSE(MPF_IMPORTANT, QString("Couldn't open file %1").arg(filename));
    10281035        return;
    10291036    }
     1037#ifdef USING_MINGW
     1038    _setmode(fh, _O_BINARY);
     1039#endif
    10301040
    10311041    write(fh, data, size);
    10321042    close(fh);
  • libs/libmythtv/NuppelVideoRecorder.cpp

     
    1010#elif HAVE_SOUNDCARD_H
    1111    #include <soundcard.h>
    1212#endif
     13#ifndef USING_MINGW
    1314#include <sys/ioctl.h>
    1415#include <sys/mman.h>
     16#endif
    1517#include <cerrno>
    1618#include <cmath>
    1719
     
    778780 */
    779781bool NuppelVideoRecorder::MJPEGInit(void)
    780782{
     783#ifndef USING_MINGW
    781784    bool we_opened_fd = false;
    782785    int init_fd = fd;
    783786    if (init_fd < 0)
     
    819822            hmjpg_maxw = 640;
    820823        return true;
    821824    }
    822 
     825#endif // !USING_MINGW
    823826    VERBOSE(VB_IMPORTANT, LOC_ERR + "MJPEG not supported by device");
    824827    return false;
    825828}
     
    966969
    967970void NuppelVideoRecorder::ProbeV4L2(void)
    968971{
     972#ifndef USING_MINGW
    969973    usingv4l2 = true;
    970974
    971975    struct v4l2_capability vcap;
     
    995999    QString driver = (char *)vcap.driver;
    9961000    if (driver == "go7007")
    9971001        go7007 = true;
     1002#endif // !USING_MINGW   
    9981003}
    9991004
    10001005void NuppelVideoRecorder::StartRecording(void)
     
    10731078
    10741079void NuppelVideoRecorder::DoV4L(void)
    10751080{
     1081#ifndef USING_MINGW
    10761082    struct video_capability vc;
    10771083    struct video_mmap mm;
    10781084    struct video_mbuf vm;
     
    12551261
    12561262    recording = false;
    12571263    close(fd);
     1264#endif // !USING_MINGW   
    12581265}
    12591266
    12601267void NuppelVideoRecorder::DoV4L2(void)
    12611268{
     1269#ifndef USING_MINGW
    12621270    struct v4l2_format     vfmt;
    12631271    struct v4l2_buffer     vbuf;
    12641272    struct v4l2_requestbuffers vrbuf;
     
    16121620    recording = false;
    16131621    close(fd);
    16141622    close(channelfd);
     1623#endif // !USING_MINGW
    16151624}
    16161625
    16171626void NuppelVideoRecorder::DoMJPEG(void)
    16181627{
     1628#ifndef USING_MINGW
    16191629    struct mjpeg_params bparm;
    16201630
    16211631    if (ioctl(fd, MJPIOC_G_PARAMS, &bparm) < 0)
     
    17481758           
    17491759    recording = false;
    17501760    close(fd);
     1761#endif // !USING_MINGW   
    17511762}
    17521763
    17531764int NuppelVideoRecorder::SpawnChildren(void)
     
    26472658
    26482659void NuppelVideoRecorder::doVbiThread(void)
    26492660{
     2661#ifndef USING_MINGW   
    26502662    //VERBOSE(VB_IMPORTANT, LOC + "vbi begin");
    26512663    struct VBIData vbicallbackdata;
    26522664    struct vbi *pal_tt = NULL;
     
    27932805        cc_close(ntsc_cc);
    27942806
    27952807    //VERBOSE(VB_RECORD, LOC + "vbi end");
     2808#endif // !USING_MINGW
    27962809}
    27972810
    27982811
  • libs/libmythtv/libmythtv.pro

     
    583583    DEFINES += USING_D3D
    584584
    585585    HEADERS += videoout_d3d.h
    586     SOURCES -= NuppelVideoRecorder.cpp
    587586    SOURCES += videoout_d3d.cpp
    588587
    589588    LIBS += -lpthread