Respect prebuffering_bytes= on existing streams when reloading.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 22 Jul 2015 22:01:39 +0000 (00:01 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 22 Jul 2015 22:01:39 +0000 (00:01 +0200)
main.cpp
server.cpp
server.h
serverpool.cpp
serverpool.h

index 2080d73..32d654c 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -185,6 +185,7 @@ void create_streams(const Config &config,
                        stream_index = servers->lookup_stream_by_url(stream_config.url);
                        assert(stream_index != -1);
                        servers->set_backlog_size(stream_index, stream_config.backlog_size);
+                       servers->set_prebuffering_bytes(stream_index, stream_config.prebuffering_bytes);
                        servers->set_encoding(stream_index,
                                              Stream::Encoding(stream_config.encoding));
                }
index 2f7a332..33a335a 100644 (file)
@@ -317,6 +317,13 @@ void Server::set_backlog_size(int stream_index, size_t new_size)
        assert(stream_index >= 0 && stream_index < ssize_t(streams.size()));
        streams[stream_index]->set_backlog_size(new_size);
 }
+
+void Server::set_prebuffering_bytes(int stream_index, size_t new_amount)
+{
+       MutexLock lock(&mutex);
+       assert(stream_index >= 0 && stream_index < ssize_t(streams.size()));
+       streams[stream_index]->prebuffering_bytes = new_amount;
+}
        
 void Server::set_encoding(int stream_index, Stream::Encoding encoding)
 {
index feea863..79c35f8 100644 (file)
--- a/server.h
+++ b/server.h
@@ -59,6 +59,7 @@ public:
        int add_stream_from_serialized(const StreamProto &stream, int data_fd);
        int lookup_stream_by_url(const std::string &url) const;
        void set_backlog_size(int stream_index, size_t new_size);
+       void set_prebuffering_bytes(int stream_index, size_t new_amount);
        void set_encoding(int stream_index, Stream::Encoding encoding);
 
 private:
index 310a0a7..a834e8c 100644 (file)
@@ -201,6 +201,13 @@ void ServerPool::set_backlog_size(int stream_index, size_t new_size)
        }       
 }
 
+void ServerPool::set_prebuffering_bytes(int stream_index, size_t new_amount)
+{
+       for (int i = 0; i < num_servers; ++i) {
+               servers[i].set_prebuffering_bytes(stream_index, new_amount);
+       }
+}
+
 void ServerPool::set_encoding(int stream_index, Stream::Encoding encoding)
 {
        for (int i = 0; i < num_servers; ++i) {
index 4b56544..e0c59cd 100644 (file)
@@ -49,6 +49,9 @@ public:
        // Changes the given stream's backlog size on all the servers.
        void set_backlog_size(int stream_index, size_t new_size);
 
+       // Changes the given stream's amount of forced prebuffering on all the servers.
+       void set_prebuffering_bytes(int stream_index, size_t new_amount);
+
        // Changes the given stream's encoding type on all the servers.
        void set_encoding(int stream_index, Stream::Encoding encoding);