diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-11-14 23:39:00 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-11-14 23:39:00 +0000 |
| commit | febb57f618c0f932fca1f9f6400145b5ce1785d1 (patch) | |
| tree | 3c30739e888245345b71ef25db7e8fd41ea2090f /src/lib/stream.cc | |
| parent | 65e7ad9b9512816a3313db7e817ed2466d84d644 (diff) | |
Try a bit of backwards compatibility in state file.
Diffstat (limited to 'src/lib/stream.cc')
| -rw-r--r-- | src/lib/stream.cc | 18 |
1 files changed, 15 insertions, 3 deletions
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<int> 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); |
