aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decode.c12
-rw-r--r--src/inputStream.c1
-rw-r--r--src/inputStream.h2
-rw-r--r--src/inputStream_file.c2
-rw-r--r--src/inputStream_http.c2
5 files changed, 19 insertions, 0 deletions
diff --git a/src/decode.c b/src/decode.c
index 92f01a393..97896f67d 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -53,6 +53,18 @@ static void decodeStart(void)
dc.state = DECODE_STATE_START;
dc.command = DECODE_COMMAND_NONE;
+ /* wait for the input stream to become ready; its metadata
+ will be available then */
+
+ while (!inStream.ready) {
+ if (dc.command != DECODE_COMMAND_NONE)
+ goto stop;
+
+ ret = bufferInputStream(&inStream);
+ if (ret < 0)
+ goto stop;
+ }
+
/* for http streams, seekable is determined in bufferInputStream */
dc.seekable = inStream.seekable;
diff --git a/src/inputStream.c b/src/inputStream.c
index 9495beb8a..7686fed48 100644
--- a/src/inputStream.c
+++ b/src/inputStream.c
@@ -31,6 +31,7 @@ void initInputStream(void)
int openInputStream(InputStream * inStream, char *url)
{
+ inStream->ready = 0;
inStream->offset = 0;
inStream->size = 0;
inStream->error = 0;
diff --git a/src/inputStream.h b/src/inputStream.h
index c1e2e4f83..2e32c2a13 100644
--- a/src/inputStream.h
+++ b/src/inputStream.h
@@ -32,6 +32,8 @@ typedef int (*InputStreamAtEOFFunc) (InputStream * inStream);
typedef int (*InputStreamBufferFunc) (InputStream * inStream);
struct _InputStream {
+ int ready;
+
int error;
long offset;
size_t size;
diff --git a/src/inputStream_file.c b/src/inputStream_file.c
index 2e51e3f6c..7110eb2e8 100644
--- a/src/inputStream_file.c
+++ b/src/inputStream_file.c
@@ -52,6 +52,8 @@ int inputStream_fileOpen(InputStream * inStream, char *filename)
inStream->atEOFFunc = inputStream_fileAtEOF;
inStream->bufferFunc = inputStream_fileBuffer;
+ inStream->ready = 1;
+
return 0;
}
diff --git a/src/inputStream_http.c b/src/inputStream_http.c
index 3e99b0475..ace6da4ce 100644
--- a/src/inputStream_http.c
+++ b/src/inputStream_http.c
@@ -598,6 +598,7 @@ found:
xclose(data->fd);
data->fd = -1;
data->state = CONN_STATE_REDIRECT;
+ is->ready = 1;
return 0; /* success */
}
return -1;
@@ -696,6 +697,7 @@ static int recv_response(InputStream * is)
ringbuf_writer_reset(data->rb);
data->state = CONN_STATE_PREBUFFER;
+ is->ready = 1;
return 0;
}