Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ce6afe93
Commit
ce6afe93
authored
Feb 17, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/httpd/Page: convert to type alias on AllocatedArray
parent
6f04b223
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
64 deletions
+17
-64
HttpdClient.cxx
src/output/plugins/httpd/HttpdClient.cxx
+13
-13
HttpdInternal.hxx
src/output/plugins/httpd/HttpdInternal.hxx
+1
-1
HttpdOutputPlugin.cxx
src/output/plugins/httpd/HttpdOutputPlugin.cxx
+1
-1
IcyMetaDataServer.cxx
src/output/plugins/httpd/IcyMetaDataServer.cxx
+1
-2
Page.cxx
src/output/plugins/httpd/Page.cxx
+0
-28
Page.hxx
src/output/plugins/httpd/Page.hxx
+1
-18
meson.build
src/output/plugins/meson.build
+0
-1
No files found.
src/output/plugins/httpd/HttpdClient.cxx
View file @
ce6afe93
...
@@ -197,8 +197,8 @@ HttpdClient::ClearQueue() noexcept
...
@@ -197,8 +197,8 @@ HttpdClient::ClearQueue() noexcept
while
(
!
pages
.
empty
())
{
while
(
!
pages
.
empty
())
{
#ifndef NDEBUG
#ifndef NDEBUG
auto
&
page
=
pages
.
front
();
auto
&
page
=
pages
.
front
();
assert
(
queue_size
>=
page
->
GetS
ize
());
assert
(
queue_size
>=
page
->
s
ize
());
queue_size
-=
page
->
GetS
ize
();
queue_size
-=
page
->
s
ize
();
#endif
#endif
pages
.
pop
();
pages
.
pop
();
...
@@ -222,10 +222,10 @@ HttpdClient::CancelQueue() noexcept
...
@@ -222,10 +222,10 @@ HttpdClient::CancelQueue() noexcept
ssize_t
ssize_t
HttpdClient
::
TryWritePage
(
const
Page
&
page
,
size_t
position
)
noexcept
HttpdClient
::
TryWritePage
(
const
Page
&
page
,
size_t
position
)
noexcept
{
{
assert
(
position
<
page
.
GetS
ize
());
assert
(
position
<
page
.
s
ize
());
return
GetSocket
().
Write
(
page
.
GetD
ata
()
+
position
,
return
GetSocket
().
Write
(
page
.
d
ata
()
+
position
,
page
.
GetS
ize
()
-
position
);
page
.
s
ize
()
-
position
);
}
}
ssize_t
ssize_t
...
@@ -233,7 +233,7 @@ HttpdClient::TryWritePageN(const Page &page,
...
@@ -233,7 +233,7 @@ HttpdClient::TryWritePageN(const Page &page,
size_t
position
,
ssize_t
n
)
noexcept
size_t
position
,
ssize_t
n
)
noexcept
{
{
return
n
>=
0
return
n
>=
0
?
GetSocket
().
Write
(
page
.
GetD
ata
()
+
position
,
n
)
?
GetSocket
().
Write
(
page
.
d
ata
()
+
position
,
n
)
:
TryWritePage
(
page
,
position
);
:
TryWritePage
(
page
,
position
);
}
}
...
@@ -241,7 +241,7 @@ ssize_t
...
@@ -241,7 +241,7 @@ ssize_t
HttpdClient
::
GetBytesTillMetaData
()
const
noexcept
HttpdClient
::
GetBytesTillMetaData
()
const
noexcept
{
{
if
(
metadata_requested
&&
if
(
metadata_requested
&&
current_page
->
GetS
ize
()
-
current_position
>
metaint
-
metadata_fill
)
current_page
->
s
ize
()
-
current_position
>
metaint
-
metadata_fill
)
return
metaint
-
metadata_fill
;
return
metaint
-
metadata_fill
;
return
-
1
;
return
-
1
;
...
@@ -267,8 +267,8 @@ HttpdClient::TryWrite() noexcept
...
@@ -267,8 +267,8 @@ HttpdClient::TryWrite() noexcept
pages
.
pop
();
pages
.
pop
();
current_position
=
0
;
current_position
=
0
;
assert
(
queue_size
>=
current_page
->
GetS
ize
());
assert
(
queue_size
>=
current_page
->
s
ize
());
queue_size
-=
current_page
->
GetS
ize
();
queue_size
-=
current_page
->
s
ize
();
}
}
const
ssize_t
bytes_to_write
=
GetBytesTillMetaData
();
const
ssize_t
bytes_to_write
=
GetBytesTillMetaData
();
...
@@ -294,7 +294,7 @@ HttpdClient::TryWrite() noexcept
...
@@ -294,7 +294,7 @@ HttpdClient::TryWrite() noexcept
metadata_current_position
+=
nbytes
;
metadata_current_position
+=
nbytes
;
if
(
metadata
->
GetS
ize
()
-
metadata_current_position
==
0
)
{
if
(
metadata
->
s
ize
()
-
metadata_current_position
==
0
)
{
metadata_fill
=
0
;
metadata_fill
=
0
;
metadata_current_position
=
0
;
metadata_current_position
=
0
;
metadata_sent
=
true
;
metadata_sent
=
true
;
...
@@ -343,12 +343,12 @@ HttpdClient::TryWrite() noexcept
...
@@ -343,12 +343,12 @@ HttpdClient::TryWrite() noexcept
}
}
current_position
+=
nbytes
;
current_position
+=
nbytes
;
assert
(
current_position
<=
current_page
->
GetS
ize
());
assert
(
current_position
<=
current_page
->
s
ize
());
if
(
metadata_requested
)
if
(
metadata_requested
)
metadata_fill
+=
nbytes
;
metadata_fill
+=
nbytes
;
if
(
current_position
>=
current_page
->
GetS
ize
())
{
if
(
current_position
>=
current_page
->
s
ize
())
{
current_page
.
reset
();
current_page
.
reset
();
if
(
pages
.
empty
())
if
(
pages
.
empty
())
...
@@ -374,7 +374,7 @@ HttpdClient::PushPage(PagePtr page) noexcept
...
@@ -374,7 +374,7 @@ HttpdClient::PushPage(PagePtr page) noexcept
ClearQueue
();
ClearQueue
();
}
}
queue_size
+=
page
->
GetS
ize
();
queue_size
+=
page
->
s
ize
();
pages
.
emplace
(
std
::
move
(
page
));
pages
.
emplace
(
std
::
move
(
page
));
event
.
ScheduleWrite
();
event
.
ScheduleWrite
();
...
...
src/output/plugins/httpd/HttpdInternal.hxx
View file @
ce6afe93
...
@@ -143,7 +143,7 @@ private:
...
@@ -143,7 +143,7 @@ private:
* A temporary buffer for the httpd_output_read_page()
* A temporary buffer for the httpd_output_read_page()
* function.
* function.
*/
*/
char
buffer
[
32768
];
std
::
byte
buffer
[
32768
];
/**
/**
* The maximum and current number of clients connected
* The maximum and current number of clients connected
...
...
src/output/plugins/httpd/HttpdOutputPlugin.cxx
View file @
ce6afe93
...
@@ -164,7 +164,7 @@ HttpdOutput::ReadPage()
...
@@ -164,7 +164,7 @@ HttpdOutput::ReadPage()
if
(
size
==
0
)
if
(
size
==
0
)
return
nullptr
;
return
nullptr
;
return
std
::
make_shared
<
Page
>
(
buffer
,
size
);
return
std
::
make_shared
<
Page
>
(
ConstBuffer
{
buffer
,
size
}
);
}
}
inline
void
inline
void
...
...
src/output/plugins/httpd/IcyMetaDataServer.cxx
View file @
ce6afe93
...
@@ -113,6 +113,5 @@ icy_server_metadata_page(const Tag &tag, const TagType *types) noexcept
...
@@ -113,6 +113,5 @@ icy_server_metadata_page(const Tag &tag, const TagType *types) noexcept
if
(
icy_string
==
nullptr
)
if
(
icy_string
==
nullptr
)
return
nullptr
;
return
nullptr
;
return
std
::
make_shared
<
Page
>
(
icy_string
.
c_str
(),
return
std
::
make_shared
<
Page
>
(
ConstBuffer
<
std
::
byte
>
{(
const
std
::
byte
*
)
icy_string
.
c_str
(),
uint8_t
(
icy_string
[
0
])
*
16U
+
1U
});
uint8_t
(
icy_string
[
0
])
*
16
+
1
);
}
}
src/output/plugins/httpd/Page.cxx
deleted
100644 → 0
View file @
6f04b223
/*
* Copyright 2003-2021 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "Page.hxx"
#include <string.h>
Page
::
Page
(
const
void
*
data
,
size_t
size
)
noexcept
:
buffer
(
size
)
{
memcpy
(
&
buffer
.
front
(),
data
,
size
);
}
src/output/plugins/httpd/Page.hxx
View file @
ce6afe93
...
@@ -30,24 +30,7 @@
...
@@ -30,24 +30,7 @@
* reference-counted buffers around (using std::shared_ptr), when
* reference-counted buffers around (using std::shared_ptr), when
* several instances hold references to one buffer.
* several instances hold references to one buffer.
*/
*/
class
Page
{
using
Page
=
AllocatedArray
<
std
::
byte
>
;
AllocatedArray
<
std
::
byte
>
buffer
;
public
:
explicit
Page
(
size_t
_size
)
noexcept
:
buffer
(
_size
)
{}
explicit
Page
(
AllocatedArray
<
std
::
byte
>
&&
_buffer
)
noexcept
:
buffer
(
std
::
move
(
_buffer
))
{}
Page
(
const
void
*
data
,
size_t
size
)
noexcept
;
size_t
GetSize
()
const
noexcept
{
return
buffer
.
size
();
}
const
std
::
byte
*
GetData
()
const
noexcept
{
return
&
buffer
.
front
();
}
};
typedef
std
::
shared_ptr
<
Page
>
PagePtr
;
typedef
std
::
shared_ptr
<
Page
>
PagePtr
;
...
...
src/output/plugins/meson.build
View file @
ce6afe93
...
@@ -36,7 +36,6 @@ output_features.set('ENABLE_HTTPD_OUTPUT', get_option('httpd'))
...
@@ -36,7 +36,6 @@ output_features.set('ENABLE_HTTPD_OUTPUT', get_option('httpd'))
if get_option('httpd')
if get_option('httpd')
output_plugins_sources += [
output_plugins_sources += [
'httpd/IcyMetaDataServer.cxx',
'httpd/IcyMetaDataServer.cxx',
'httpd/Page.cxx',
'httpd/HttpdClient.cxx',
'httpd/HttpdClient.cxx',
'httpd/HttpdOutputPlugin.cxx',
'httpd/HttpdOutputPlugin.cxx',
]
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment