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
cb9a05ac
Commit
cb9a05ac
authored
Jan 30, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/httpd: safer cast, consider offset
parent
f1f22019
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
HttpdOutputPlugin.cxx
src/output/HttpdOutputPlugin.cxx
+16
-10
No files found.
src/output/HttpdOutputPlugin.cxx
View file @
cb9a05ac
...
@@ -165,10 +165,16 @@ httpd_output_init(const struct config_param *param,
...
@@ -165,10 +165,16 @@ httpd_output_init(const struct config_param *param,
return
&
httpd
->
base
;
return
&
httpd
->
base
;
}
}
static
inline
constexpr
HttpdOutput
*
Cast
(
audio_output
*
ao
)
{
return
(
HttpdOutput
*
)((
char
*
)
ao
-
offsetof
(
HttpdOutput
,
base
));
}
static
void
static
void
httpd_output_finish
(
struct
audio_output
*
ao
)
httpd_output_finish
(
struct
audio_output
*
ao
)
{
{
HttpdOutput
*
httpd
=
(
HttpdOutput
*
)
ao
;
HttpdOutput
*
httpd
=
Cast
(
ao
)
;
ao_base_finish
(
&
httpd
->
base
);
ao_base_finish
(
&
httpd
->
base
);
delete
httpd
;
delete
httpd
;
...
@@ -273,7 +279,7 @@ HttpdOutput::ReadPage()
...
@@ -273,7 +279,7 @@ HttpdOutput::ReadPage()
static
bool
static
bool
httpd_output_enable
(
struct
audio_output
*
ao
,
GError
**
error_r
)
httpd_output_enable
(
struct
audio_output
*
ao
,
GError
**
error_r
)
{
{
HttpdOutput
*
httpd
=
(
HttpdOutput
*
)
ao
;
HttpdOutput
*
httpd
=
Cast
(
ao
)
;
return
httpd
->
Bind
(
error_r
);
return
httpd
->
Bind
(
error_r
);
}
}
...
@@ -281,7 +287,7 @@ httpd_output_enable(struct audio_output *ao, GError **error_r)
...
@@ -281,7 +287,7 @@ httpd_output_enable(struct audio_output *ao, GError **error_r)
static
void
static
void
httpd_output_disable
(
struct
audio_output
*
ao
)
httpd_output_disable
(
struct
audio_output
*
ao
)
{
{
HttpdOutput
*
httpd
=
(
HttpdOutput
*
)
ao
;
HttpdOutput
*
httpd
=
Cast
(
ao
)
;
httpd
->
Unbind
();
httpd
->
Unbind
();
}
}
...
@@ -327,7 +333,7 @@ static bool
...
@@ -327,7 +333,7 @@ static bool
httpd_output_open
(
struct
audio_output
*
ao
,
struct
audio_format
*
audio_format
,
httpd_output_open
(
struct
audio_output
*
ao
,
struct
audio_format
*
audio_format
,
GError
**
error
)
GError
**
error
)
{
{
HttpdOutput
*
httpd
=
(
HttpdOutput
*
)
ao
;
HttpdOutput
*
httpd
=
Cast
(
ao
)
;
assert
(
httpd
->
clients
.
empty
());
assert
(
httpd
->
clients
.
empty
());
...
@@ -355,7 +361,7 @@ HttpdOutput::Close()
...
@@ -355,7 +361,7 @@ HttpdOutput::Close()
static
void
static
void
httpd_output_close
(
struct
audio_output
*
ao
)
httpd_output_close
(
struct
audio_output
*
ao
)
{
{
HttpdOutput
*
httpd
=
(
HttpdOutput
*
)
ao
;
HttpdOutput
*
httpd
=
Cast
(
ao
)
;
const
ScopeLock
protect
(
httpd
->
mutex
);
const
ScopeLock
protect
(
httpd
->
mutex
);
httpd
->
Close
();
httpd
->
Close
();
...
@@ -387,7 +393,7 @@ HttpdOutput::SendHeader(HttpdClient &client) const
...
@@ -387,7 +393,7 @@ HttpdOutput::SendHeader(HttpdClient &client) const
static
unsigned
static
unsigned
httpd_output_delay
(
struct
audio_output
*
ao
)
httpd_output_delay
(
struct
audio_output
*
ao
)
{
{
HttpdOutput
*
httpd
=
(
HttpdOutput
*
)
ao
;
HttpdOutput
*
httpd
=
Cast
(
ao
)
;
if
(
!
httpd
->
LockHasClients
()
&&
httpd
->
base
.
pause
)
{
if
(
!
httpd
->
LockHasClients
()
&&
httpd
->
base
.
pause
)
{
/* if there's no client and this output is paused,
/* if there's no client and this output is paused,
...
@@ -452,7 +458,7 @@ static size_t
...
@@ -452,7 +458,7 @@ static size_t
httpd_output_play
(
struct
audio_output
*
ao
,
const
void
*
chunk
,
size_t
size
,
httpd_output_play
(
struct
audio_output
*
ao
,
const
void
*
chunk
,
size_t
size
,
GError
**
error_r
)
GError
**
error_r
)
{
{
HttpdOutput
*
httpd
=
(
HttpdOutput
*
)
ao
;
HttpdOutput
*
httpd
=
Cast
(
ao
)
;
if
(
httpd
->
LockHasClients
())
{
if
(
httpd
->
LockHasClients
())
{
if
(
!
httpd
->
EncodeAndPlay
(
chunk
,
size
,
error_r
))
if
(
!
httpd
->
EncodeAndPlay
(
chunk
,
size
,
error_r
))
...
@@ -469,7 +475,7 @@ httpd_output_play(struct audio_output *ao, const void *chunk, size_t size,
...
@@ -469,7 +475,7 @@ httpd_output_play(struct audio_output *ao, const void *chunk, size_t size,
static
bool
static
bool
httpd_output_pause
(
struct
audio_output
*
ao
)
httpd_output_pause
(
struct
audio_output
*
ao
)
{
{
HttpdOutput
*
httpd
=
(
HttpdOutput
*
)
ao
;
HttpdOutput
*
httpd
=
Cast
(
ao
)
;
if
(
httpd
->
LockHasClients
())
{
if
(
httpd
->
LockHasClients
())
{
static
const
char
silence
[
1020
]
=
{
0
};
static
const
char
silence
[
1020
]
=
{
0
};
...
@@ -532,7 +538,7 @@ HttpdOutput::SendTag(const struct tag *tag)
...
@@ -532,7 +538,7 @@ HttpdOutput::SendTag(const struct tag *tag)
static
void
static
void
httpd_output_tag
(
struct
audio_output
*
ao
,
const
struct
tag
*
tag
)
httpd_output_tag
(
struct
audio_output
*
ao
,
const
struct
tag
*
tag
)
{
{
HttpdOutput
*
httpd
=
(
HttpdOutput
*
)
ao
;
HttpdOutput
*
httpd
=
Cast
(
ao
)
;
httpd
->
SendTag
(
tag
);
httpd
->
SendTag
(
tag
);
}
}
...
@@ -540,7 +546,7 @@ httpd_output_tag(struct audio_output *ao, const struct tag *tag)
...
@@ -540,7 +546,7 @@ httpd_output_tag(struct audio_output *ao, const struct tag *tag)
static
void
static
void
httpd_output_cancel
(
struct
audio_output
*
ao
)
httpd_output_cancel
(
struct
audio_output
*
ao
)
{
{
HttpdOutput
*
httpd
=
(
HttpdOutput
*
)
ao
;
HttpdOutput
*
httpd
=
Cast
(
ao
)
;
const
ScopeLock
protect
(
httpd
->
mutex
);
const
ScopeLock
protect
(
httpd
->
mutex
);
for
(
auto
&
client
:
httpd
->
clients
)
for
(
auto
&
client
:
httpd
->
clients
)
...
...
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