Merge remote-tracking branch 'seife/master'

Origin commit data
------------------
Branch: master
Commit: 2ca16aedac
Author: martii <you@example.com>
Date: 2012-07-15 (Sun, 15 Jul 2012)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
martii
2012-07-15 20:13:18 +02:00
6 changed files with 67 additions and 6 deletions

View File

@@ -95,6 +95,10 @@ bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBuffe
int flags = O_RDWR; int flags = O_RDWR;
if (fd > -1) if (fd > -1)
lt_info("%s FD ALREADY OPENED? fd = %d\n", __FUNCTION__, fd); lt_info("%s FD ALREADY OPENED? fd = %d\n", __FUNCTION__, fd);
if (pes_type != DMX_PSI_CHANNEL)
flags |= O_NONBLOCK;
fd = open(devname[devnum], flags); fd = open(devname[devnum], flags);
if (fd < 0) if (fd < 0)
{ {

View File

@@ -112,6 +112,7 @@ cVideo::cVideo(int, void *, void *)
close(blankfd); close(blankfd);
} }
openDevice(); openDevice();
Pig(-1, -1, -1, -1);
} }
cVideo::~cVideo(void) cVideo::~cVideo(void)

View File

@@ -98,6 +98,9 @@ bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBuffe
int flags = O_RDWR; int flags = O_RDWR;
if (fd > -1) if (fd > -1)
lt_info("%s FD ALREADY OPENED? fd = %d\n", __FUNCTION__, fd); lt_info("%s FD ALREADY OPENED? fd = %d\n", __FUNCTION__, fd);
if (pes_type != DMX_PSI_CHANNEL)
flags |= O_NONBLOCK;
#if 0 #if 0
if (pes_type == DMX_TP_CHANNEL) if (pes_type == DMX_TP_CHANNEL)
{ {

View File

@@ -490,8 +490,34 @@ void cVideo::Standby(unsigned int bOn)
int cVideo::getBlank(void) int cVideo::getBlank(void)
{ {
lt_debug("%s\n", __FUNCTION__); static unsigned int lastcount = 0;
return 0; unsigned int count = 0;
size_t n = 0;
ssize_t r;
char *line = NULL;
char *p;
/* hack: the "mailbox" irq is not increasing if
* no audio or video is decoded... */
FILE *f = fopen("/proc/interrupts", "r");
if (! f) /* huh? */
return 0;
while ((r = getline(&line, &n, f)) != -1)
{
if (r <= strlen("mailbox")) /* should not happen... */
continue;
line[r - 1] = 0; /* remove \n */
if (!strcmp(&line[r - 1 - strlen("mailbox")], "mailbox"))
{
count = atoi(line + 5);
break;
}
}
free(line);
fclose(f);
int ret = (count == lastcount); /* no new decode -> return 1 */
lt_debug("%s: %d (irq++: %d)\n", __func__, ret, count - lastcount);
lastcount = count;
return ret;
} }
/* this function is regularly called, checks if video parameters /* this function is regularly called, checks if video parameters

View File

@@ -28,6 +28,7 @@ static pthread_cond_t playback_ready_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t playback_ready_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t playback_ready_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t currpos_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t currpos_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t inbufpos_mutex = PTHREAD_MUTEX_INITIALIZER;
static int dvrfd = -1; static int dvrfd = -1;
static int streamtype; static int streamtype;
@@ -295,7 +296,10 @@ void cPlayback::playthread(void)
if (playstate == STATE_INIT) if (playstate == STATE_INIT)
{ {
/* hack for timeshift to determine start PTS */ /* hack for timeshift to determine start PTS */
if (inbuf_read() < 0) pthread_mutex_lock(&inbufpos_mutex);
ret = inbuf_read();
pthread_mutex_unlock(&inbufpos_mutex);
if (ret < 0)
break; break;
usleep(100000); usleep(100000);
if (pts_start == -1) if (pts_start == -1)
@@ -308,7 +312,10 @@ void cPlayback::playthread(void)
usleep(1); usleep(1);
continue; continue;
} }
if (inbuf_read() < 0) pthread_mutex_lock(&inbufpos_mutex);
ret = inbuf_read();
pthread_mutex_unlock(&inbufpos_mutex);
if (ret < 0)
break; break;
/* autoselect PID for PLAYMODE_FILE */ /* autoselect PID for PLAYMODE_FILE */
@@ -326,9 +333,13 @@ void cPlayback::playthread(void)
} }
} }
pthread_mutex_lock(&inbufpos_mutex);
towrite = inbuf_pos / 188 * 188; /* TODO: smaller chunks? */ towrite = inbuf_pos / 188 * 188; /* TODO: smaller chunks? */
if (towrite == 0) if (towrite == 0)
{
pthread_mutex_unlock(&inbufpos_mutex);
continue; continue;
}
retry: retry:
ret = write(dvrfd, inbuf, towrite); ret = write(dvrfd, inbuf, towrite);
if (ret < 0) if (ret < 0)
@@ -340,6 +351,7 @@ void cPlayback::playthread(void)
} }
memmove(inbuf, inbuf + ret, inbuf_pos - ret); memmove(inbuf, inbuf + ret, inbuf_pos - ret);
inbuf_pos -= ret; inbuf_pos -= ret;
pthread_mutex_unlock(&inbufpos_mutex);
} }
pthread_cleanup_pop(1); pthread_cleanup_pop(1);
@@ -597,12 +609,14 @@ off_t cPlayback::seek_to_pts(int64_t pts)
newpos = mp_seekSync(newpos); newpos = mp_seekSync(newpos);
if (newpos < 0) if (newpos < 0)
return newpos; return newpos;
pthread_mutex_lock(&inbufpos_mutex);
inbuf_pos = 0; inbuf_pos = 0;
inbuf_sync = 0; inbuf_sync = 0;
while (inbuf_pos < INBUF_SIZE * 8 / 10) { while (inbuf_pos < INBUF_SIZE * 8 / 10) {
if (inbuf_read() <= 0) if (inbuf_read() <= 0)
break; // EOF break; // EOF
} }
pthread_mutex_unlock(&inbufpos_mutex);
if (pts_curr < pts_start) if (pts_curr < pts_start)
tmppts = pts_curr + 0x200000000ULL - pts_start; tmppts = pts_curr + 0x200000000ULL - pts_start;
else else
@@ -786,6 +800,7 @@ int64_t cPlayback::get_PES_PTS(uint8_t *buf, int len, bool last)
return pts; return pts;
} }
/* needs to be called with inbufpos_mutex locked! */
ssize_t cPlayback::inbuf_read() ssize_t cPlayback::inbuf_read()
{ {
if (filetype == FILETYPE_UNKNOWN) if (filetype == FILETYPE_UNKNOWN)

View File

@@ -108,6 +108,11 @@ cVideo::cVideo(int, void *, void *)
free(blank_data[i]); /* don't leak... */ free(blank_data[i]); /* don't leak... */
blank_data[i] = NULL; blank_data[i] = NULL;
} }
else
{ /* set framerate to 24fps... see getBlank() */
((char *)blank_data[i])[7] &= 0xF0;
((char *)blank_data[i])[7] += 2;
}
} }
close(blankfd); close(blankfd);
} }
@@ -497,8 +502,15 @@ void cVideo::Standby(unsigned int bOn)
int cVideo::getBlank(void) int cVideo::getBlank(void)
{ {
lt_debug("%s\n", __FUNCTION__); VIDEOINFO v;
return 0; memset(&v, 0, sizeof(v));
ioctl(fd, MPEG_VID_GET_V_INFO, &v);
/* HACK HACK HACK :-)
* setBlank() puts a 24fps black mpeg into the decoder...
* regular broadcast does not have 24fps, so if it is still
* there, video did not decode... */
lt_debug("%s: %hu (blank = 2)\n", __func__, v.frame_rate);
return (v.frame_rate == 2);
} }
/* set zoom in percent (100% == 1:1) */ /* set zoom in percent (100% == 1:1) */