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.
This commit is contained in:
Max Kellermann
2013-01-04 15:30:10 +01:00
parent 692b2cfb79
commit 223b90d0d4
2 changed files with 28 additions and 5 deletions

View File

@@ -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);