mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
AudioServer: Assorted infrastructure work
* Add a LibAudio, and move WAV file parsing there (via AWavFile and AWavLoader) * Add CLocalSocket, and CSocket::connect() variant for local address types. We make some small use of this in WindowServer (as that's where we modelled it from), but don't get too invasive as this PR is already quite large, and the WS I/O is a bit carefully done * Add an AClientConnection which will eventually be used to talk to AudioServer (and make use of it in Piano, though right now it really doesn't do anything except connect, using our new CLocalSocket...)
This commit is contained in:
parent
983245113a
commit
ffa8cb668f
22 changed files with 431 additions and 162 deletions
|
@ -35,6 +35,8 @@ bool CSocket::connect(const CSocketAddress& address, int port)
|
|||
{
|
||||
ASSERT(!is_connected());
|
||||
ASSERT(address.type() == CSocketAddress::Type::IPv4);
|
||||
dbgprintf("Connecting to %s...", address.to_string().characters());
|
||||
|
||||
ASSERT(port > 0 && port <= 65535);
|
||||
|
||||
struct sockaddr_in addr;
|
||||
|
@ -47,7 +49,6 @@ bool CSocket::connect(const CSocketAddress& address, int port)
|
|||
m_destination_address = address;
|
||||
m_destination_port = port;
|
||||
|
||||
dbgprintf("Connecting to %s...", address.to_string().characters());
|
||||
fflush(stdout);
|
||||
int rc = ::connect(fd(), (struct sockaddr*)&addr, sizeof(addr));
|
||||
if (rc < 0) {
|
||||
|
@ -71,6 +72,26 @@ bool CSocket::connect(const CSocketAddress& address, int port)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CSocket::connect(const CSocketAddress& address)
|
||||
{
|
||||
ASSERT(!is_connected());
|
||||
ASSERT(address.type() == CSocketAddress::Type::Local);
|
||||
dbgprintf("Connecting to %s...", address.to_string().characters());
|
||||
|
||||
sockaddr_un saddr;
|
||||
saddr.sun_family = AF_LOCAL;
|
||||
strcpy(saddr.sun_path, address.to_string().characters());
|
||||
|
||||
int rc = ::connect(fd(), (const sockaddr*)&saddr, sizeof(saddr));
|
||||
if (rc < 0) {
|
||||
perror("connect");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_connected = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
ByteBuffer CSocket::receive(int max_size)
|
||||
{
|
||||
auto buffer = read(max_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue