aboutsummaryrefslogtreecommitdiff
path: root/src/MusicBuffer.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-04 15:30:10 +0100
committerMax Kellermann <max@duempel.org>2013-01-04 20:48:28 +0100
commit223b90d0d4e79f74ebafbd0db9aea70a3bf9b74b (patch)
treedd2cdd5f2b9e41f9c6d861cf270a7d37dc21a07d /src/MusicBuffer.cxx
parent692b2cfb79b0553fef9bb6bba317a3231a4c0055 (diff)
MusicBuffer: return memory to kernel when stopping playback
Use the new HugeAllocator as backend for SliceBuffer and call HugeDiscard() when the last chunk was returned.
Diffstat (limited to 'src/MusicBuffer.cxx')
-rw-r--r--src/MusicBuffer.cxx6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/MusicBuffer.cxx b/src/MusicBuffer.cxx
index ec6e5205..5fddddc2 100644
--- a/src/MusicBuffer.cxx
+++ b/src/MusicBuffer.cxx
@@ -21,6 +21,7 @@
#include "MusicBuffer.hxx"
#include "MusicChunk.hxx"
#include "util/SliceBuffer.hxx"
+#include "mpd_error.h"
#include <glib.h>
@@ -32,7 +33,10 @@ struct music_buffer : public SliceBuffer<music_chunk> {
music_buffer(unsigned num_chunks)
:SliceBuffer(num_chunks),
- mutex(g_mutex_new()) {}
+ mutex(g_mutex_new()) {
+ if (IsOOM())
+ MPD_ERROR("Failed to allocate buffer");
+ }
~music_buffer() {
g_mutex_free(mutex);