Skip to content

Commit d4e8fa5

Browse files
committed
MusicBuffer: preallocate physical RAM for audio buffer when playback starts
To reduce page faults during playback.
1 parent e888725 commit d4e8fa5

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ver 0.25 (not yet released)
1111
- pipewire: add option "reconnect_stream"
1212
* player
1313
- support replay gain parameter in stream URI
14+
- preallocate physical RAM for audio buffer when playback starts
1415
* switch to C++23
1516
* require Meson 1.2
1617

src/MusicBuffer.hxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public:
5252
return buffer.GetCapacity();
5353
}
5454

55+
void PopulateMemory() noexcept {
56+
buffer.PopulateMemory();
57+
}
58+
5559
/**
5660
* Give all memory allocations back to the kernel.
5761
*

src/player/Thread.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,12 @@ try {
12711271

12721272
{
12731273
const ScopeUnlock unlock(mutex);
1274+
1275+
/* allocate physical RAM for the whole
1276+
buffer to reduce page faults
1277+
later */
1278+
buffer.PopulateMemory();
1279+
12741280
do_play(*this, dc, buffer);
12751281

12761282
/* give the main thread a chance to

0 commit comments

Comments
 (0)