mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
AudioServer: Port threading to LibThread
This commit is contained in:
parent
d91efd4cd0
commit
1ac7fedefe
Notes:
sideshowbarker
2024-07-19 12:31:15 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/1ac7fedefea Pull-request: https://github.com/SerenityOS/serenity/pull/486 Reviewed-by: https://github.com/awesomekling
3 changed files with 9 additions and 8 deletions
|
@ -1,23 +1,21 @@
|
|||
#include <AK/BufferStream.h>
|
||||
#include <AudioServer/ASClientConnection.h>
|
||||
#include <AudioServer/ASMixer.h>
|
||||
#include <LibCore/CThread.h>
|
||||
#include <limits>
|
||||
|
||||
ASMixer::ASMixer()
|
||||
: m_device("/dev/audio", this)
|
||||
, m_sound_thread([this] {
|
||||
mix();
|
||||
return 0;
|
||||
})
|
||||
{
|
||||
if (!m_device.open(CIODevice::WriteOnly)) {
|
||||
dbgprintf("Can't open audio device: %s\n", m_device.error_string());
|
||||
return;
|
||||
}
|
||||
|
||||
CThread sound_thread([](void* context) -> int {
|
||||
ASMixer* mixer = (ASMixer*)context;
|
||||
mixer->mix();
|
||||
return 0;
|
||||
},
|
||||
this);
|
||||
m_sound_thread.start();
|
||||
}
|
||||
|
||||
ASMixer::~ASMixer()
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <LibAudio/ABuffer.h>
|
||||
#include <LibCore/CFile.h>
|
||||
#include <LibCore/CLock.h>
|
||||
#include <LibThread/Thread.h>
|
||||
|
||||
class ASClientConnection;
|
||||
|
||||
|
@ -65,6 +66,8 @@ private:
|
|||
CFile m_device;
|
||||
CLock m_lock;
|
||||
|
||||
LibThread::Thread m_sound_thread;
|
||||
|
||||
int m_main_volume { 100 };
|
||||
|
||||
void mix();
|
||||
|
|
|
@ -19,7 +19,7 @@ AudioServerEndpoint.h: AudioServer.ipc
|
|||
@echo "IPC $<"; $(IPCCOMPILER) $< > $@
|
||||
|
||||
$(APP): $(OBJS)
|
||||
$(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lc -lcore -lipc
|
||||
$(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lc -lcore -lipc -lthread
|
||||
|
||||
.cpp.o:
|
||||
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||
|
|
Loading…
Reference in a new issue