Skip to content

Commit 1ac7fed

Browse files
bugaevcawesomekling
authored andcommitted
AudioServer: Port threading to LibThread
1 parent d91efd4 commit 1ac7fed

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Servers/AudioServer/ASMixer.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
#include <AK/BufferStream.h>
22
#include <AudioServer/ASClientConnection.h>
33
#include <AudioServer/ASMixer.h>
4-
#include <LibCore/CThread.h>
54
#include <limits>
65

76
ASMixer::ASMixer()
87
: m_device("/dev/audio", this)
8+
, m_sound_thread([this] {
9+
mix();
10+
return 0;
11+
})
912
{
1013
if (!m_device.open(CIODevice::WriteOnly)) {
1114
dbgprintf("Can't open audio device: %s\n", m_device.error_string());
1215
return;
1316
}
1417

15-
CThread sound_thread([](void* context) -> int {
16-
ASMixer* mixer = (ASMixer*)context;
17-
mixer->mix();
18-
return 0;
19-
},
20-
this);
18+
m_sound_thread.start();
2119
}
2220

2321
ASMixer::~ASMixer()

Servers/AudioServer/ASMixer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <LibAudio/ABuffer.h>
99
#include <LibCore/CFile.h>
1010
#include <LibCore/CLock.h>
11+
#include <LibThread/Thread.h>
1112

1213
class ASClientConnection;
1314

@@ -65,6 +66,8 @@ class ASMixer : public CObject {
6566
CFile m_device;
6667
CLock m_lock;
6768

69+
LibThread::Thread m_sound_thread;
70+
6871
int m_main_volume { 100 };
6972

7073
void mix();

Servers/AudioServer/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ AudioServerEndpoint.h: AudioServer.ipc
1919
@echo "IPC $<"; $(IPCCOMPILER) $< > $@
2020

2121
$(APP): $(OBJS)
22-
$(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lc -lcore -lipc
22+
$(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lc -lcore -lipc -lthread
2323

2424
.cpp.o:
2525
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<

0 commit comments

Comments
 (0)