summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--input/input.c6
-rw-r--r--libmpcodecs/vd_theora.c6
-rw-r--r--stream/cache2.c35
-rw-r--r--stream/stream.c6
-rw-r--r--stream/stream.h3
5 files changed, 47 insertions, 9 deletions
diff --git a/input/input.c b/input/input.c
index a751cc2fc3..8651e83fbc 100644
--- a/input/input.c
+++ b/input/input.c
@@ -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;
diff --git a/libmpcodecs/vd_theora.c b/libmpcodecs/vd_theora.c
index 86fb5dc0dd..5ad3b35691 100644
--- a/libmpcodecs/vd_theora.c
+++ b/libmpcodecs/vd_theora.c
@@ -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;
}
diff --git a/stream/cache2.c b/stream/cache2.c
index b9a1f15faa..05905a6ded 100644
--- a/stream/cache2.c
+++ b/stream/cache2.c
@@ -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:
diff --git a/stream/stream.c b/stream/stream.c
index 165166245d..01245b757a 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -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);
}
diff --git a/stream/stream.h b/stream/stream.h
index 5cbc304e81..40ea321bc4 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -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;