Try a bit of backwards compatibility in state file.
[dcpomatic.git] / src / lib / stream.cc
index fd7eccfbf2bfe69bec7272632a7d1f9b7ff36fca..5bc184eb9cd5c15e4fbc8b71504c11f5d56e3af1 100644 (file)
 #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);