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
31b380b2
Commit
31b380b2
authored
Aug 14, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/httpd: move code to _has_clients()
parent
a869dfea
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
11 deletions
+27
-11
httpd_output_plugin.c
src/output/httpd_output_plugin.c
+27
-11
No files found.
src/output/httpd_output_plugin.c
View file @
31b380b2
...
@@ -53,6 +53,31 @@ httpd_output_quark(void)
...
@@ -53,6 +53,31 @@ httpd_output_quark(void)
return
g_quark_from_static_string
(
"httpd_output"
);
return
g_quark_from_static_string
(
"httpd_output"
);
}
}
/**
* Check whether there is at least one client.
*
* Caller must lock the mutex.
*/
G_GNUC_PURE
static
bool
httpd_output_has_clients
(
const
struct
httpd_output
*
httpd
)
{
return
httpd
->
clients
!=
NULL
;
}
/**
* Check whether there is at least one client.
*/
G_GNUC_PURE
static
bool
httpd_output_lock_has_clients
(
const
struct
httpd_output
*
httpd
)
{
g_mutex_lock
(
httpd
->
mutex
);
bool
result
=
httpd_output_has_clients
(
httpd
);
g_mutex_unlock
(
httpd
->
mutex
);
return
result
;
}
static
void
static
void
httpd_listen_in_event
(
int
fd
,
const
struct
sockaddr
*
address
,
httpd_listen_in_event
(
int
fd
,
const
struct
sockaddr
*
address
,
size_t
address_length
,
int
uid
,
void
*
ctx
);
size_t
address_length
,
int
uid
,
void
*
ctx
);
...
@@ -475,13 +500,8 @@ httpd_output_play(struct audio_output *ao, const void *chunk, size_t size,
...
@@ -475,13 +500,8 @@ httpd_output_play(struct audio_output *ao, const void *chunk, size_t size,
GError
**
error
)
GError
**
error
)
{
{
struct
httpd_output
*
httpd
=
(
struct
httpd_output
*
)
ao
;
struct
httpd_output
*
httpd
=
(
struct
httpd_output
*
)
ao
;
bool
has_clients
;
g_mutex_lock
(
httpd
->
mutex
);
has_clients
=
httpd
->
clients
!=
NULL
;
g_mutex_unlock
(
httpd
->
mutex
);
if
(
h
as_clients
)
{
if
(
h
ttpd_output_lock_has_clients
(
httpd
)
)
{
bool
success
;
bool
success
;
success
=
httpd_output_encode_and_play
(
httpd
,
chunk
,
size
,
success
=
httpd_output_encode_and_play
(
httpd
,
chunk
,
size
,
...
@@ -502,11 +522,7 @@ httpd_output_pause(struct audio_output *ao)
...
@@ -502,11 +522,7 @@ httpd_output_pause(struct audio_output *ao)
{
{
struct
httpd_output
*
httpd
=
(
struct
httpd_output
*
)
ao
;
struct
httpd_output
*
httpd
=
(
struct
httpd_output
*
)
ao
;
g_mutex_lock
(
httpd
->
mutex
);
if
(
httpd_output_lock_has_clients
(
httpd
))
{
bool
has_clients
=
httpd
->
clients
!=
NULL
;
g_mutex_unlock
(
httpd
->
mutex
);
if
(
has_clients
)
{
static
const
char
silence
[
1020
];
static
const
char
silence
[
1020
];
return
httpd_output_play
(
ao
,
silence
,
sizeof
(
silence
),
return
httpd_output_play
(
ao
,
silence
,
sizeof
(
silence
),
NULL
)
>
0
;
NULL
)
>
0
;
...
...
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