driver/moviecut.cpp: fix saving header after truncate,

remove redundant CMovieInfo arg from api
This commit is contained in:
[CST] Focus
2016-02-09 16:35:25 +03:00
parent 0a98143e49
commit 00b97778a3
3 changed files with 16 additions and 16 deletions

View File

@@ -175,6 +175,9 @@ bool CMovieCut::truncateMovie(MI_MOVIE_INFO * minfo)
minfo->length = minfo->bookmarks.end/60; minfo->length = minfo->bookmarks.end/60;
minfo->bookmarks.end = 0; minfo->bookmarks.end = 0;
reset_atime(minfo->file.Name.c_str(), minfo->file.Time); reset_atime(minfo->file.Name.c_str(), minfo->file.Time);
CMovieInfo cmovie;
cmovie.saveMovieInfo(*minfo);
WriteHeader(minfo->file.Name.c_str(), newsize/secsize*1000);
return true; return true;
} }
@@ -238,8 +241,9 @@ int CMovieCut::read_psi(const char * spart, unsigned char * buf)
return -1; return -1;
} }
void CMovieCut::save_info(CMovieInfo * cmovie, MI_MOVIE_INFO * minfo, char * dpart, off64_t spos, off64_t secsize) void CMovieCut::save_info(MI_MOVIE_INFO * minfo, char * dpart, off64_t spos, off64_t secsize)
{ {
CMovieInfo cmovie;
MI_MOVIE_INFO ninfo = *minfo; MI_MOVIE_INFO ninfo = *minfo;
ninfo.file.Name = dpart; ninfo.file.Name = dpart;
ninfo.file.Size = spos; ninfo.file.Size = spos;
@@ -253,7 +257,7 @@ void CMovieCut::save_info(CMovieInfo * cmovie, MI_MOVIE_INFO * minfo, char * dpa
ninfo.bookmarks.user[book_nr].length = 0; ninfo.bookmarks.user[book_nr].length = 0;
} }
} }
cmovie->saveMovieInfo(ninfo); cmovie.saveMovieInfo(ninfo);
WriteHeader(ninfo.file.Name.c_str(), spos/secsize*1000); WriteHeader(ninfo.file.Name.c_str(), spos/secsize*1000);
reset_atime(dpart, minfo->file.Time); reset_atime(dpart, minfo->file.Time);
} }
@@ -302,7 +306,7 @@ int CMovieCut::getInput()
return retval; return retval;
} }
bool CMovieCut::cutMovie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie) bool CMovieCut::cutMovie(MI_MOVIE_INFO * minfo)
{ {
struct mybook books[MI_MOVIE_BOOK_USER_MAX+2]; struct mybook books[MI_MOVIE_BOOK_USER_MAX+2];
unsigned char psi[PSI_SIZE]; unsigned char psi[PSI_SIZE];
@@ -482,7 +486,7 @@ bool CMovieCut::cutMovie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie)
tt1 = time(0); tt1 = time(0);
printf("CMovieCut::%s: total written %" PRId64 " tooks %ld secs end time %s", __func__, spos, tt1-tt, ctime(&tt1)); printf("CMovieCut::%s: total written %" PRId64 " tooks %ld secs end time %s", __func__, spos, tt1-tt, ctime(&tt1));
save_info(cmovie, minfo, dpart, spos, secsize); save_info(minfo, dpart, spos, secsize);
retval = true; retval = true;
ret_err: ret_err:
if (srcfd >= 0) if (srcfd >= 0)
@@ -498,7 +502,7 @@ ret_err:
return retval; return retval;
} }
bool CMovieCut::copyMovie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie, bool onefile) bool CMovieCut::copyMovie(MI_MOVIE_INFO * minfo, bool onefile)
{ {
struct mybook books[MI_MOVIE_BOOK_USER_MAX+2]; struct mybook books[MI_MOVIE_BOOK_USER_MAX+2];
struct stat64 s; struct stat64 s;
@@ -619,13 +623,13 @@ bool CMovieCut::copyMovie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie, bool onefi
if (!onefile) { if (!onefile) {
close(dstfd); close(dstfd);
dstfd = -1; dstfd = -1;
save_info(cmovie, minfo, dpart, spos, secsize); save_info(minfo, dpart, spos, secsize);
time_t tt1 = time(0); time_t tt1 = time(0);
printf("copy: ********* %s: total written %" PRId64 " took %ld secs\n", dpart, spos, tt1-tt); printf("copy: ********* %s: total written %" PRId64 " took %ld secs\n", dpart, spos, tt1-tt);
} }
} /* for all books */ } /* for all books */
if (onefile) { if (onefile) {
save_info(cmovie, minfo, dpart, spos, secsize); save_info(minfo, dpart, spos, secsize);
time_t tt1 = time(0); time_t tt1 = time(0);
printf("copy: ********* %s: total written %" PRId64 " took %ld secs\n", dpart, spos, tt1-tt); printf("copy: ********* %s: total written %" PRId64 " took %ld secs\n", dpart, spos, tt1-tt);
} }

View File

@@ -41,7 +41,7 @@ class CMovieCut
int find_gop(unsigned char *buf, int r); int find_gop(unsigned char *buf, int r);
off64_t fake_read(int fd, unsigned char *buf, size_t size, off64_t fsize); off64_t fake_read(int fd, unsigned char *buf, size_t size, off64_t fsize);
int read_psi(const char * spart, unsigned char * buf); int read_psi(const char * spart, unsigned char * buf);
void save_info(CMovieInfo * cmovie, MI_MOVIE_INFO * minfo, char * dpart, off64_t spos, off64_t secsize); void save_info(MI_MOVIE_INFO * minfo, char * dpart, off64_t spos, off64_t secsize);
void findNewName(const char * fname, char * dpart,size_t dpart_len); void findNewName(const char * fname, char * dpart,size_t dpart_len);
static int compare_book(const void *x, const void *y); static int compare_book(const void *x, const void *y);
int getInput(); int getInput();
@@ -52,8 +52,8 @@ class CMovieCut
CMovieCut(); CMovieCut();
~CMovieCut(); ~CMovieCut();
bool truncateMovie(MI_MOVIE_INFO * minfo); bool truncateMovie(MI_MOVIE_INFO * minfo);
bool cutMovie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie); bool cutMovie(MI_MOVIE_INFO * minfo);
bool copyMovie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie, bool onefile); bool copyMovie(MI_MOVIE_INFO * minfo, bool onefile);
//int handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data); //int handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data);
}; };

View File

@@ -899,7 +899,7 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey)
delete hintBox; delete hintBox;
framebuffer->paintBackground(); // clear screen framebuffer->paintBackground(); // clear screen
CMovieCut mc; CMovieCut mc;
bool res = mc.copyMovie(m_movieSelectionHandler, &m_movieInfo, onefile); bool res = mc.copyMovie(m_movieSelectionHandler, onefile);
//g_RCInput->clearRCMsg(); //g_RCInput->clearRCMsg();
if (res == 0) if (res == 0)
ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_COPY_FAILED, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_COPY_FAILED, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR);
@@ -924,7 +924,7 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey)
delete hintBox; delete hintBox;
framebuffer->paintBackground(); // clear screen framebuffer->paintBackground(); // clear screen
CMovieCut mc; CMovieCut mc;
bool res = mc.cutMovie(m_movieSelectionHandler, &m_movieInfo); bool res = mc.cutMovie(m_movieSelectionHandler);
//g_RCInput->clearRCMsg(); //g_RCInput->clearRCMsg();
if (!res) if (!res)
ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_CUT_FAILED, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_CUT_FAILED, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR);
@@ -955,11 +955,7 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey)
if (!res) if (!res)
ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_TRUNCATE_FAILED, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_TRUNCATE_FAILED, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR);
else else
{
//printf("New movie info: size %lld len %d\n", res, m_movieSelectionHandler->bookmarks.end/60);
m_movieInfo.saveMovieInfo(*m_movieSelectionHandler);
m_doLoadMovies = true; m_doLoadMovies = true;
}
m_doRefresh = true; m_doRefresh = true;
} }
} }