summaryrefslogtreecommitdiff
path: root/src/lib/stream.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-11-14 23:39:00 +0000
committerCarl Hetherington <cth@carlh.net>2012-11-14 23:39:00 +0000
commitfebb57f618c0f932fca1f9f6400145b5ce1785d1 (patch)
tree3c30739e888245345b71ef25db7e8fd41ea2090f /src/lib/stream.cc
parent65e7ad9b9512816a3313db7e817ed2466d84d644 (diff)
Try a bit of backwards compatibility in state file.
Diffstat (limited to 'src/lib/stream.cc')
-rw-r--r--src/lib/stream.cc18
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);