Kernel/Userspace: Replace my custom SHM system with SysV shm

This allows xbanan to use shm!
This commit is contained in:
2026-08-08 01:52:12 +03:00
parent 2c4fee4a82
commit fc40820150
23 changed files with 327 additions and 225 deletions
@@ -1,8 +1,7 @@
#include "AudioServer.h"
#include <sys/banan-os.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/shm.h>
#include <sys/socket.h>
#include <unistd.h>
@@ -23,10 +22,7 @@ void AudioServer::on_client_disconnect(int fd)
ASSERT(it != m_audio_buffers.end());
if (it->value.buffer != nullptr)
{
const size_t bytes = sizeof(LibAudio::AudioBuffer) + it->value.buffer->capacity * sizeof(LibAudio::AudioBuffer::sample_t);
munmap(it->value.buffer, bytes);
}
shmdt(it->value.buffer);
m_audio_buffers.remove(it);
@@ -54,9 +50,9 @@ bool AudioServer::on_client_packet(int fd, LibAudio::Packet packet)
dwarnln("Client tried to map second audio buffer??");
return false;
}
audio_buffer.buffer = static_cast<LibAudio::AudioBuffer*>(smo_map(packet.parameter));
audio_buffer.buffer = static_cast<LibAudio::AudioBuffer*>(shmat(packet.parameter, nullptr, 0));
audio_buffer.queued_head = audio_buffer.buffer->tail;
if (audio_buffer.buffer == nullptr)
if (audio_buffer.buffer == SHM_FAILED)
{
dwarnln("Failed to map audio buffer: {}", strerror(errno));
return false;