From 440b1ea3ea0e2bc0f56c8f39f917e59d1761a3d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=81shin?= <kodest@gmail.com>
Date: Fri, 14 Nov 2008 15:23:18 +0100
Subject: [PATCH] wavpack: be more robust if the underlying stream is not
 seekable

The wavpack open function gives us an option called OPEN_STREAMING. This
provides more robust and error tolerant playback, but it automatically
disables seeking. (More exactly the wavpack lib will not return the
length information.) So, if the stream is already not seekable we can
use this option safely.
---
 src/decoder/wavpack_plugin.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/decoder/wavpack_plugin.c b/src/decoder/wavpack_plugin.c
index c771db621..4262d55fa 100644
--- a/src/decoder/wavpack_plugin.c
+++ b/src/decoder/wavpack_plugin.c
@@ -494,7 +494,7 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
 	char error[ERRORLEN];
 	WavpackContext *wpc;
 	struct input_stream is_wvc;
-	int open_flags = OPEN_2CH_MAX | OPEN_NORMALIZE /*| OPEN_STREAMING*/;
+	int open_flags = OPEN_2CH_MAX | OPEN_NORMALIZE;
 	struct wavpack_input isp, isp_wvc;
 	bool can_seek = is->seekable;
 
@@ -503,6 +503,10 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
 		can_seek &= is_wvc.seekable;
 	}
 
+	if (!can_seek) {
+		open_flags |= OPEN_STREAMING;
+	}
+
 	wavpack_input_init(&isp, decoder, is);
 	wpc = WavpackOpenFileInputEx(
 		&mpd_is_reader, &isp, &isp_wvc, error, open_flags, 23