Merge svn changes up to r31256

This commit is contained in:
Uoti Urpala 2010-05-30 16:39:41 +03:00
commit 0e0d88ede9
5 changed files with 47 additions and 9 deletions

View File

@ -1169,6 +1169,9 @@ static mp_cmd_t *check_autorepeat(struct input_ctx *ictx)
}
/**
* \param time time to wait at most for an event in milliseconds
*/
static mp_cmd_t *read_events(struct input_ctx *ictx, int time)
{
int i;
@ -1837,6 +1840,9 @@ static int print_cmd_list(m_option_t* cfg)
exit(0);
}
/**
* \param time time to wait for an interruption in milliseconds
*/
int mp_input_check_interrupt(struct input_ctx *ictx, int time)
{
mp_cmd_t* cmd;

View File

@ -98,7 +98,7 @@ static int init(sh_video_t *sh){
op.packet = extradata + 2;
op.b_o_s = 1;
if (extradata_size < op.bytes + 2) {
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Theora header too small\n");
mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Theora header too small\n");
goto err_out;
}
extradata += op.bytes + 2;
@ -110,7 +110,7 @@ static int init(sh_video_t *sh){
if ( (errorCode = theora_decode_header (&context->inf, &context->cc, &op)) )
{
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Broken Theora header; errorCode=%i!\n", errorCode);
mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Broken Theora header; errorCode=%i!\n", errorCode);
goto err_out;
}
}
@ -187,7 +187,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
errorCode = theora_decode_YUVout (&context->st, &yuv);
if (errorCode)
{
mp_msg(MSGT_DEMUX,MSGL_ERR,"Theora decode YUVout failed: %i \n",
mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode YUVout failed: %i \n",
errorCode);
return NULL;
}

View File

@ -22,7 +22,7 @@
// Note it runs in 2 processes (using fork()), but doesn't require locking!!
// TODO: seeking, data consistency checking
#define READ_USLEEP_TIME 10000
#define READ_SLEEP_TIME 10
// These defines are used to reduce the cost of many successive
// seeks (e.g. when a file has no index) by spinning quickly at first.
#define INITIAL_FILL_USLEEP_TIME 1000
@ -114,6 +114,8 @@ static void cache_stats(cache_vars_t *s)
static int cache_read(cache_vars_t *s, unsigned char *buf, int size)
{
int total=0;
int sleep_count = 0;
int last_max = s->max_filepos;
while(size>0){
int pos,newb,len;
@ -122,10 +124,21 @@ static int cache_read(cache_vars_t *s, unsigned char *buf, int size)
if(s->read_filepos>=s->max_filepos || s->read_filepos<s->min_filepos){
// eof?
if(s->eof) break;
if (s->max_filepos == last_max) {
if (sleep_count++ == 10)
mp_msg(MSGT_CACHE, MSGL_WARN, "Cache not filling!\n");
} else {
last_max = s->max_filepos;
sleep_count = 0;
}
// waiting for buffer fill...
usec_sleep(READ_USLEEP_TIME); // 10ms
if (stream_check_interrupt(READ_SLEEP_TIME)) {
s->eof = 1;
break;
}
continue; // try again...
}
sleep_count = 0;
newb=s->max_filepos-s->read_filepos; // new bytes in the buffer
if(newb<min_fill) min_fill=newb; // statistics...
@ -349,6 +362,9 @@ static void dummy_sighandler(int x) {
*/
static void cache_mainloop(cache_vars_t *s) {
int sleep_count = 0;
#if FORKED_CACHE
signal(SIGUSR1, SIG_IGN);
#endif
do {
if (!cache_fill(s)) {
#if FORKED_CACHE
@ -399,6 +415,10 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){
if (min > s->buffer_size - s->fill_limit) {
min = s->buffer_size - s->fill_limit;
}
// to make sure we wait for the cache process/thread to be active
// before continuing
if (min <= 0)
min = 1;
#if FORKED_CACHE
if((stream->cache_pid=fork())){
@ -522,6 +542,7 @@ int cache_stream_seek_long(stream_t *stream,off_t pos){
}
int cache_do_control(stream_t *stream, int cmd, void *arg) {
int sleep_count = 0;
cache_vars_t* s = stream->cache_data;
switch (cmd) {
case STREAM_CTRL_SEEK_TO_TIME:
@ -550,8 +571,14 @@ int cache_do_control(stream_t *stream, int cmd, void *arg) {
return STREAM_UNSUPPORTED;
}
cache_wakeup(stream);
while (s->control != -1)
usec_sleep(CONTROL_SLEEP_TIME);
while (s->control != -1) {
if (sleep_count++ == 1000)
mp_msg(MSGT_CACHE, MSGL_WARN, "Cache not responding!\n");
if (stream_check_interrupt(CONTROL_SLEEP_TIME)) {
s->eof = 1;
return STREAM_UNSUPPORTED;
}
}
switch (cmd) {
case STREAM_CTRL_GET_TIME_LENGTH:
case STREAM_CTRL_GET_CURRENT_TIME:

View File

@ -37,6 +37,7 @@
#include "mp_msg.h"
#include "osdep/shmem.h"
#include "osdep/timer.h"
#include "network.h"
#include "stream.h"
#include "libmpdemux/demuxer.h"
@ -490,7 +491,10 @@ void stream_set_interrupt_callback(int (*cb)(struct input_ctx *, int),
}
int stream_check_interrupt(int time) {
if(!stream_check_interrupt_cb) return 0;
if(!stream_check_interrupt_cb) {
usec_sleep(time * 1000);
return 0;
}
return stream_check_interrupt_cb(stream_check_interrupt_ctx, time);
}

View File

@ -336,7 +336,8 @@ stream_t *open_output_stream(const char *filename, struct MPOpts *options);
struct input_ctx;
void stream_set_interrupt_callback(int (*cb)(struct input_ctx*, int),
struct input_ctx *ctx);
/// Call the interrupt checking callback if there is one.
/// Call the interrupt checking callback if there is one and
/// wait for time milliseconds
int stream_check_interrupt(int time);
extern int dvd_title;