diff --git a/ChangeLog b/ChangeLog index b8d71c9..ca5e67e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2018-01-12 GetAway1 + + ShowPicture: return boolean expression + 2017-11-02 Thilo Graf version 0.2.0-generic-pc diff --git a/azbox/video.cpp b/azbox/video.cpp index a8061f8..51fa851 100644 --- a/azbox/video.cpp +++ b/azbox/video.cpp @@ -351,13 +351,14 @@ 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) { - vdec->ShowPicture(fname); + return vdec->ShowPicture(fname); } -void VDec::ShowPicture(const char * fname) +bool VDec::ShowPicture(const char * fname) { + bool ret = false; lt_debug("%s(%s)\n", __func__, fname); char destname[512]; char cmd[512]; @@ -369,18 +370,18 @@ void VDec::ShowPicture(const char * fname) { /* does not work and the driver does not seem to like it */ lt_info("%s: video_standby == true\n", __func__); - return; + return ret; } if (fd < 0) { - lt_info("%s: decoder not opened?\n", __func__); - return; + lt_info("%s: decoder not opened\n", __func__); + return ret; } strcpy(destname, "/var/cache"); if (stat(fname, &st2)) { lt_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): @@ -430,10 +431,11 @@ void VDec::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/azbox/video_priv.h b/azbox/video_priv.h index 5bcb638..a2fc569 100644 --- a/azbox/video_priv.h +++ b/azbox/video_priv.h @@ -46,7 +46,7 @@ public: int setBlank(int blank); int SetStreamType(VIDEO_FORMAT type); void SetSyncMode(AVSYNC_TYPE mode); - void ShowPicture(const char * fname); + bool ShowPicture(const char * fname); void Standby(unsigned int bOn); void Pig(int x, int y, int w, int h, int osd_w, int osd_h); diff --git a/generic-pc/video.cpp b/generic-pc/video.cpp index de42940..8a12d9d 100644 --- a/generic-pc/video.cpp +++ b/generic-pc/video.cpp @@ -282,16 +282,17 @@ void cVideo::SetVideoMode(analog_mode_t) { } -void cVideo::ShowPicture(const char *fname) +bool cVideo::ShowPicture(const char *fname) { - vdec->ShowPicture(fname); + return vdec->ShowPicture(fname); } -void VDec::ShowPicture(const char *fname) +bool VDec::ShowPicture(const char *fname) { + bool ret = false; lt_info("%s(%s)\n", __func__, fname); if (access(fname, R_OK)) - return; + return ret; still_m.lock(); stillpicture = true; buf_num = 0; @@ -312,7 +313,7 @@ void VDec::ShowPicture(const char *fname) if (avformat_open_input(&avfc, fname, NULL, NULL) < 0) { lt_info("%s: Could not open file %s\n", __func__, fname); - return; + return ret; } if (avformat_find_stream_info(avfc, NULL) < 0) { @@ -385,6 +386,7 @@ void VDec::ShowPicture(const char *fname) buf_num--; } buf_m.unlock(); + ret = true; } } av_packet_unref(&avpkt); @@ -396,6 +398,7 @@ void VDec::ShowPicture(const char *fname) out_close: avformat_close_input(&avfc); lt_debug("%s(%s) end\n", __func__, fname); + return ret; } void cVideo::StopPicture() diff --git a/generic-pc/video_priv.h b/generic-pc/video_priv.h index 067d9b5..aaa8408 100644 --- a/generic-pc/video_priv.h +++ b/generic-pc/video_priv.h @@ -80,7 +80,7 @@ class VDec : public OpenThreads::Thread int Stop(bool blank = true); int SetStreamType(VIDEO_FORMAT type); - void ShowPicture(const char * fname); + bool ShowPicture(const char * fname); void Pig(int x, int y, int w, int h); bool GetScreenImage(unsigned char * &data, int &xres, int &yres, bool get_video = true, bool get_osd = false, bool scale_to_video = false); SWFramebuffer *getDecBuf(void); diff --git a/include/video_hal.h b/include/video_hal.h index efaed07..d15442f 100644 --- a/include/video_hal.h +++ b/include/video_hal.h @@ -189,7 +189,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 1e2b03e..15e0219 100644 --- a/libspark/video.cpp +++ b/libspark/video.cpp @@ -394,13 +394,14 @@ 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) { - vdec->ShowPicture(fname); + return vdec->ShowPicture(fname); } -void VDec::ShowPicture(const char * fname) +bool VDec::ShowPicture(const char * fname) { + bool ret = false; lt_debug("%s(%s)\n", __func__, fname); char destname[512]; char cmd[512]; @@ -411,13 +412,19 @@ void VDec::ShowPicture(const char * fname) { /* does not work and the driver does not seem to like it */ lt_info("%s: video_standby == true\n", __func__); - return; + return ret; } + if (fd == -1) + { + lt_info("%s: decoder not opened\n", __func__); + return ret; + } + strcpy(destname, "/var/cache"); if (stat(fname, &st2)) { lt_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): @@ -470,10 +477,11 @@ void VDec::ShowPicture(const char * fname) video_still_picture sp = { iframe, st.st_size }; fop(ioctl, VIDEO_STILLPICTURE, &sp); free(iframe); + ret = true; } out: close(mfd); - return; + return ret; } void cVideo::StopPicture() diff --git a/libspark/video_priv.h b/libspark/video_priv.h index 2e5cde1..43e11d8 100644 --- a/libspark/video_priv.h +++ b/libspark/video_priv.h @@ -46,7 +46,7 @@ public: int Stop(bool blank = true); int SetStreamType(VIDEO_FORMAT type); void SetSyncMode(AVSYNC_TYPE mode); - void ShowPicture(const char * fname); + bool ShowPicture(const char * fname); void Standby(unsigned int bOn); /* used internally by dmx */ diff --git a/libtriple/video_priv.h b/libtriple/video_priv.h index 4d36bf5..d5b3e56 100644 --- a/libtriple/video_priv.h +++ b/libtriple/video_priv.h @@ -75,7 +75,7 @@ public: /* set video_system */ int SetVideoSystem(int video_system, bool remember = true); - 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); diff --git a/libtriple/video_td.cpp b/libtriple/video_td.cpp index d6f9010..ad9d0ac 100644 --- a/libtriple/video_td.cpp +++ b/libtriple/video_td.cpp @@ -469,13 +469,14 @@ void VDec::SetVideoMode(analog_mode_t mode) fop(ioctl, MPEG_VID_SET_OUTFMT, outputformat); } -void cVideo::ShowPicture(const char * fname) +bool cVideo::ShowPicture(const char * fname) { - _vdec->ShowPicture(fname); + return _vdec->ShowPicture(fname); } -void VDec::ShowPicture(const char * fname) +bool VDec::ShowPicture(const char * fname) { + bool ret = false; lt_debug("%s(%s)\n", __FUNCTION__, fname); char destname[512]; char cmd[512]; @@ -487,7 +488,7 @@ void VDec::ShowPicture(const char * fname) if (stat(fname, &st2)) { lt_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): @@ -542,13 +543,14 @@ void VDec::ShowPicture(const char * fname) /* writing twice seems to be more reliable */ fop(ioctl, MPEG_VID_STILLP_WRITE, &buf); 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/raspi/video.cpp b/raspi/video.cpp index 696b34c..e904dc8 100644 --- a/raspi/video.cpp +++ b/raspi/video.cpp @@ -129,11 +129,11 @@ void cVideo::SetVideoMode(analog_mode_t) { } -void cVideo::ShowPicture(const char *fname) +bool cVideo::ShowPicture(const char *fname) { lt_info("%s(%s)\n", __func__, fname); if (access(fname, R_OK)) - return; + return true; } void cVideo::StopPicture()