From 465d0482eaf7dc20b992642a1a5ac52704616abb Mon Sep 17 00:00:00 2001 From: GetAway Date: Tue, 12 Mar 2019 21:59:42 +0100 Subject: [PATCH] ShowPicture: return boolean expression Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/90c3600026eadce445007644c6944644ca04c871 Author: GetAway Date: 2019-03-12 (Tue, 12 Mar 2019) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/video.cpp | 19 ++++++++++++++----- libarmbox/video_lib.h | 2 +- libazbox/video.cpp | 16 +++++++++------- libazbox/video_lib.h | 2 +- libgeneric-pc/video.cpp | 7 +++++-- libgeneric-pc/video_lib.h | 2 +- libraspi/video.cpp | 4 ++-- libraspi/video_lib.h | 2 +- libspark/video.cpp | 17 +++++++++++++---- libspark/video_lib.h | 2 +- libtriple/video_td.cpp | 8 +++++--- libtriple/video_td.h | 2 +- 12 files changed, 54 insertions(+), 29 deletions(-) diff --git a/libarmbox/video.cpp b/libarmbox/video.cpp index 3e3f7ca..445b185 100644 --- a/libarmbox/video.cpp +++ b/libarmbox/video.cpp @@ -632,18 +632,26 @@ void cVideo::SetVideoMode(analog_mode_t mode) proc_put("/proc/stb/avs/0/colorformat", m, strlen(m)); } -void cVideo::ShowPicture(const char * fname) +bool cVideo::ShowPicture(const char * fname) { - hal_info("%s(%s)\n", __func__, fname); + bool ret = false; + hal_debug("%s(%s)\n", __func__, fname); if (video_standby) { /* does not work and the driver does not seem to like it */ hal_info("%s: video_standby == true\n", __func__); - return; + return ret; } + /* in movieplayer mode, fd is not opened */ + if (fd == -1) + { + hal_info("%s: decoder not opened\n", __func__); + return ret; + } + struct stat st; if (stat(fname, &st)){ - return; + return ret; } closeDevice(); openDevice(); @@ -663,8 +671,9 @@ void cVideo::ShowPicture(const char * fname) usleep(150000); ioctl(fd, VIDEO_STOP, 0); ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX); + ret = true; } - return; + return ret; } void cVideo::StopPicture() diff --git a/libarmbox/video_lib.h b/libarmbox/video_lib.h index 636c3a2..2b5cd50 100644 --- a/libarmbox/video_lib.h +++ b/libarmbox/video_lib.h @@ -233,7 +233,7 @@ class cVideo bool SetCECMode(VIDEO_HDMI_CEC_MODE); void SetCECAutoView(bool); void SetCECAutoStandby(bool); - void ShowPicture(const char * fname); + bool ShowPicture(const char * fname); void StopPicture(); void Standby(unsigned int bOn); void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600, int startx = 0, int starty = 0, int endx = 1279, int endy = 719); diff --git a/libazbox/video.cpp b/libazbox/video.cpp index f557f58..02d692a 100644 --- a/libazbox/video.cpp +++ b/libazbox/video.cpp @@ -321,8 +321,9 @@ void cVideo::SetVideoMode(analog_mode_t mode) proc_put("/proc/stb/avs/0/colorformat", m, strlen(m)); } -void cVideo::ShowPicture(const char * fname) +bool cVideo::ShowPicture(const char * fname) { + bool ret = false; hal_debug("%s(%s)\n", __func__, fname); char destname[512]; char cmd[512]; @@ -334,18 +335,18 @@ void cVideo::ShowPicture(const char * fname) { /* does not work and the driver does not seem to like it */ hal_info("%s: video_standby == true\n", __func__); - return; + return ret; } - if (fd < 0) + if (fd == -1) { - hal_info("%s: decoder not opened?\n", __func__); - return; + hal_info("%s: decoder not opened\n", __func__); + return ret; } strcpy(destname, "/var/cache"); if (stat(fname, &st2)) { hal_info("%s: could not stat %s (%m)\n", __func__, fname); - return; + return ret; } mkdir(destname, 0755); /* the cache filename is (example for /share/tuxbox/neutrino/icons/radiomode.jpg): @@ -395,10 +396,11 @@ void cVideo::ShowPicture(const char * fname) read(mfd, iframe, st.st_size); show_iframe(fd, iframe, st.st_size); free(iframe); + ret = true; out: close(mfd); pthread_mutex_unlock(&stillp_mutex); - return; + return ret; } void cVideo::StopPicture() diff --git a/libazbox/video_lib.h b/libazbox/video_lib.h index b6050f5..a17b863 100644 --- a/libazbox/video_lib.h +++ b/libazbox/video_lib.h @@ -175,7 +175,7 @@ class cVideo bool SetCECMode(VIDEO_HDMI_CEC_MODE) { return true; }; void SetCECAutoView(bool) { return; }; void SetCECAutoStandby(bool) { return; }; - void ShowPicture(const char * fname); + bool ShowPicture(const char * fname); void StopPicture(); void Standby(unsigned int bOn); void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600); diff --git a/libgeneric-pc/video.cpp b/libgeneric-pc/video.cpp index 102ea7b..5e167ce 100644 --- a/libgeneric-pc/video.cpp +++ b/libgeneric-pc/video.cpp @@ -235,8 +235,9 @@ void cVideo::SetVideoMode(analog_mode_t) { } -void cVideo::ShowPicture(const char *fname) +bool cVideo::ShowPicture(const char *fname) { + bool ret = false; hal_info("%s(%s)\n", __func__, fname); if (access(fname, R_OK)) return; @@ -260,7 +261,7 @@ void cVideo::ShowPicture(const char *fname) if (avformat_open_input(&avfc, fname, NULL, NULL) < 0) { hal_info("%s: Could not open file %s\n", __func__, fname); - return; + return ret; } if (avformat_find_stream_info(avfc, NULL) < 0) { @@ -333,6 +334,7 @@ void cVideo::ShowPicture(const char *fname) buf_num--; } buf_m.unlock(); + ret = true; } } av_packet_unref(&avpkt); @@ -344,6 +346,7 @@ void cVideo::ShowPicture(const char *fname) out_close: avformat_close_input(&avfc); hal_debug("%s(%s) end\n", __func__, fname); + return ret; } void cVideo::StopPicture() diff --git a/libgeneric-pc/video_lib.h b/libgeneric-pc/video_lib.h index 8201f7c..de6c012 100644 --- a/libgeneric-pc/video_lib.h +++ b/libgeneric-pc/video_lib.h @@ -180,7 +180,7 @@ class cVideo : public OpenThreads::Thread bool Pause(void); int SetStreamType(VIDEO_FORMAT type); - void ShowPicture(const char * fname); + bool ShowPicture(const char * fname); void SetSyncMode(AVSYNC_TYPE mode); bool SetCECMode(VIDEO_HDMI_CEC_MODE) { return true; }; diff --git a/libraspi/video.cpp b/libraspi/video.cpp index 7aa8f4c..0cda7dd 100644 --- a/libraspi/video.cpp +++ b/libraspi/video.cpp @@ -125,11 +125,11 @@ void cVideo::SetVideoMode(analog_mode_t) { } -void cVideo::ShowPicture(const char *fname) +bool cVideo::ShowPicture(const char *fname) { hal_info("%s(%s)\n", __func__, fname); if (access(fname, R_OK)) - return; + return true; } void cVideo::StopPicture() diff --git a/libraspi/video_lib.h b/libraspi/video_lib.h index e70c343..cc23a06 100644 --- a/libraspi/video_lib.h +++ b/libraspi/video_lib.h @@ -180,7 +180,7 @@ class cVideo bool SetCECMode(VIDEO_HDMI_CEC_MODE) { return true; }; void SetCECAutoView(bool) { return; }; void SetCECAutoStandby(bool) { return; }; - void ShowPicture(const char * fname); + bool ShowPicture(const char * fname); void StopPicture(); void Standby(unsigned int bOn); void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600); diff --git a/libspark/video.cpp b/libspark/video.cpp index eaf6927..ff1104b 100644 --- a/libspark/video.cpp +++ b/libspark/video.cpp @@ -564,8 +564,9 @@ void cVideo::SetVideoMode(analog_mode_t mode) proc_put("/proc/stb/avs/0/colorformat", m, strlen(m)); } -void cVideo::ShowPicture(const char * fname, const char *_destname) +bool cVideo::ShowPicture(const char * fname, const char *_destname) { + bool ret = false; hal_debug("%s(%s)\n", __func__, fname); //static const unsigned char pes_header[] = { 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x80, 0x00, 0x00 }; static const unsigned char pes_header[] = {0x0, 0x0, 0x1, 0xe0, 0x00, 0x00, 0x80, 0x80, 0x5, 0x21, 0x0, 0x1, 0x0, 0x1}; @@ -578,8 +579,15 @@ void cVideo::ShowPicture(const char * fname, const char *_destname) { /* does not work and the driver does not seem to like it */ hal_info("%s: video_standby == true\n", __func__); - return; + return ret; } + if (fd == -1) + { + /* in movieplayer mode, fd is not opened */ + hal_info("%s: decoder not opened\n", __func__); + return ret; + } + const char *lastDot = strrchr(fname, '.'); if (lastDot && !strcasecmp(lastDot + 1, "m2v")) strncpy(destname, fname, sizeof(destname)); @@ -591,7 +599,7 @@ void cVideo::ShowPicture(const char * fname, const char *_destname) if (stat(fname, &st2)) { hal_info("%s: could not stat %s (%m)\n", __func__, fname); - return; + return ret; } mkdir(destname, 0755); /* the cache filename is (example for /share/tuxbox/neutrino/icons/radiomode.jpg): @@ -657,10 +665,11 @@ void cVideo::ShowPicture(const char * fname, const char *_destname) write(fd, iframe, 8192); ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX); free(iframe); + ret = true; } out: close(mfd); - return; + return ret; } void cVideo::StopPicture() diff --git a/libspark/video_lib.h b/libspark/video_lib.h index 278b88e..d77415c 100644 --- a/libspark/video_lib.h +++ b/libspark/video_lib.h @@ -199,7 +199,7 @@ class cVideo bool SetCECMode(VIDEO_HDMI_CEC_MODE) { return true; }; void SetCECAutoView(bool) { return; }; void SetCECAutoStandby(bool) { return; }; - void ShowPicture(const char * fname, const char *_destname = NULL); + bool ShowPicture(const char * fname, const char *_destname = NULL); void StopPicture(); void Standby(unsigned int bOn); void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600, int startx = 0, int starty = 0, int endx = 1279, int endy = 719); diff --git a/libtriple/video_td.cpp b/libtriple/video_td.cpp index 33f1fc4..72e7e79 100644 --- a/libtriple/video_td.cpp +++ b/libtriple/video_td.cpp @@ -389,8 +389,9 @@ void cVideo::SetVideoMode(analog_mode_t mode) fop(ioctl, MPEG_VID_SET_OUTFMT, outputformat); } -void cVideo::ShowPicture(const char * fname) +bool cVideo::ShowPicture(const char * fname) { + bool ret = false; hal_debug("%s(%s)\n", __FUNCTION__, fname); char destname[512]; char cmd[512]; @@ -402,7 +403,7 @@ void cVideo::ShowPicture(const char * fname) if (stat(fname, &st2)) { hal_info("%s: could not stat %s (%m)\n", __func__, fname); - return; + return ret; } mkdir(destname, 0755); /* the cache filename is (example for /share/tuxbox/neutrino/icons/radiomode.jpg): @@ -451,13 +452,14 @@ void cVideo::ShowPicture(const char * fname) buf.ulStartAdrOff = (int)data; Stop(false); fop(ioctl, MPEG_VID_STILLP_WRITE, &buf); + ret = true; } free(data); } close(mfd); out: pthread_mutex_unlock(&stillp_mutex); - return; + return ret; #if 0 /* DirectFB based picviewer: works, but is slow and the infobar draws in the same plane */ diff --git a/libtriple/video_td.h b/libtriple/video_td.h index b9b7921..4c0e032 100644 --- a/libtriple/video_td.h +++ b/libtriple/video_td.h @@ -172,7 +172,7 @@ class cVideo bool SetCECMode(VIDEO_HDMI_CEC_MODE) { return true; }; void SetCECAutoView(bool) { return; }; void SetCECAutoStandby(bool) { return; }; - void ShowPicture(const char * fname); + bool ShowPicture(const char * fname); void StopPicture(); void Standby(unsigned int bOn); void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600);