output/httpd: use reference instead of pointer

This commit is contained in:
Max Kellermann 2013-12-31 16:32:33 +01:00
parent f1ac2cd336
commit 8b65b524d5
3 changed files with 14 additions and 14 deletions

View File

@ -48,13 +48,13 @@ HttpdClient::~HttpdClient()
void void
HttpdClient::Close() HttpdClient::Close()
{ {
httpd->RemoveClient(*this); httpd.RemoveClient(*this);
} }
void void
HttpdClient::LockClose() HttpdClient::LockClose()
{ {
const ScopeLock protect(httpd->mutex); const ScopeLock protect(httpd.mutex);
Close(); Close();
} }
@ -67,7 +67,7 @@ HttpdClient::BeginResponse()
current_page = nullptr; current_page = nullptr;
if (!head_method) if (!head_method)
httpd->SendHeader(*this); httpd.SendHeader(*this);
} }
/** /**
@ -155,13 +155,13 @@ HttpdClient::SendResponse()
"realTimeInfo.dlna.org: DLNA.ORG_TLAG=*\r\n" "realTimeInfo.dlna.org: DLNA.ORG_TLAG=*\r\n"
"contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0\r\n" "contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0\r\n"
"\r\n", "\r\n",
httpd->content_type); httpd.content_type);
} else if (metadata_requested) { } else if (metadata_requested) {
char *metadata_header = char *metadata_header =
icy_server_metadata_header(httpd->name, httpd->genre, icy_server_metadata_header(httpd.name, httpd.genre,
httpd->website, httpd.website,
httpd->content_type, httpd.content_type,
metaint); metaint);
g_strlcpy(buffer, metadata_header, sizeof(buffer)); g_strlcpy(buffer, metadata_header, sizeof(buffer));
@ -176,7 +176,7 @@ HttpdClient::SendResponse()
"Pragma: no-cache\r\n" "Pragma: no-cache\r\n"
"Cache-Control: no-cache, no-store\r\n" "Cache-Control: no-cache, no-store\r\n"
"\r\n", "\r\n",
httpd->content_type); httpd.content_type);
} }
ssize_t nbytes = SocketMonitor::Write(buffer, strlen(buffer)); ssize_t nbytes = SocketMonitor::Write(buffer, strlen(buffer));
@ -192,7 +192,7 @@ HttpdClient::SendResponse()
return true; return true;
} }
HttpdClient::HttpdClient(HttpdOutput *_httpd, int _fd, EventLoop &_loop, HttpdClient::HttpdClient(HttpdOutput &_httpd, int _fd, EventLoop &_loop,
bool _metadata_supported) bool _metadata_supported)
:BufferedSocket(_fd, _loop), :BufferedSocket(_fd, _loop),
httpd(_httpd), httpd(_httpd),
@ -262,7 +262,7 @@ HttpdClient::GetBytesTillMetaData() const
inline bool inline bool
HttpdClient::TryWrite() HttpdClient::TryWrite()
{ {
const ScopeLock protect(httpd->mutex); const ScopeLock protect(httpd.mutex);
assert(state == RESPONSE); assert(state == RESPONSE);
@ -270,7 +270,7 @@ HttpdClient::TryWrite()
if (pages.empty()) { if (pages.empty()) {
/* another thread has removed the event source /* another thread has removed the event source
while this thread was waiting for while this thread was waiting for
httpd->mutex */ httpd.mutex */
CancelWrite(); CancelWrite();
return true; return true;
} }

View File

@ -34,7 +34,7 @@ class HttpdClient final : BufferedSocket {
/** /**
* The httpd output object this client is connected to. * The httpd output object this client is connected to.
*/ */
HttpdOutput *const httpd; HttpdOutput &httpd;
/** /**
* The current state of the client. * The current state of the client.
@ -120,7 +120,7 @@ public:
* @param httpd the HTTP output device * @param httpd the HTTP output device
* @param fd the socket file descriptor * @param fd the socket file descriptor
*/ */
HttpdClient(HttpdOutput *httpd, int _fd, EventLoop &_loop, HttpdClient(HttpdOutput &httpd, int _fd, EventLoop &_loop,
bool _metadata_supported); bool _metadata_supported);
/** /**

View File

@ -179,7 +179,7 @@ httpd_output_finish(struct audio_output *ao)
inline void inline void
HttpdOutput::AddClient(int fd) HttpdOutput::AddClient(int fd)
{ {
clients.emplace_front(this, fd, GetEventLoop(), clients.emplace_front(*this, fd, GetEventLoop(),
encoder->plugin.tag == nullptr); encoder->plugin.tag == nullptr);
++clients_cnt; ++clients_cnt;