From febb57f618c0f932fca1f9f6400145b5ce1785d1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 14 Nov 2012 23:39:00 +0000 Subject: Try a bit of backwards compatibility in state file. --- src/lib/stream.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/lib/stream.cc') diff --git a/src/lib/stream.cc b/src/lib/stream.cc index fd7eccfbf..5bc184eb9 100644 --- a/src/lib/stream.cc +++ b/src/lib/stream.cc @@ -22,13 +22,25 @@ #include "stream.h" using namespace std; +using boost::optional; -AudioStream::AudioStream (string t) +AudioStream::AudioStream (string t, optional version) { stringstream n (t); - n >> _id >> _sample_rate >> _channel_layout; + + int name_index = 3; + if (!version) { + name_index = 2; + int channels; + n >> _id >> channels; + _channel_layout = av_get_default_channel_layout (channels); + _sample_rate = 0; + } else { + /* Current (marked version 1) */ + n >> _id >> _sample_rate >> _channel_layout; + } - for (int i = 0; i < 3; ++i) { + for (int i = 0; i < name_index; ++i) { size_t const s = t.find (' '); if (s != string::npos) { t = t.substr (s + 1); -- cgit v1.2.3