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
27206368
Commit
27206368
authored
Sep 16, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/pulse: improve locking
Always lock the main loop when operating on PULSE objects. Document this.
parent
443e9638
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
pulse_output_plugin.c
src/output/pulse_output_plugin.c
+11
-11
No files found.
src/output/pulse_output_plugin.c
View file @
27206368
...
@@ -248,6 +248,8 @@ pulse_output_delete_stream(struct pulse_output *po)
...
@@ -248,6 +248,8 @@ pulse_output_delete_stream(struct pulse_output *po)
/**
/**
* Frees and clears the context.
* Frees and clears the context.
*
* Caller must lock the main loop.
*/
*/
static
void
static
void
pulse_output_delete_context
(
struct
pulse_output
*
po
)
pulse_output_delete_context
(
struct
pulse_output
*
po
)
...
@@ -266,6 +268,8 @@ pulse_output_delete_context(struct pulse_output *po)
...
@@ -266,6 +268,8 @@ pulse_output_delete_context(struct pulse_output *po)
/**
/**
* Create, set up and connect a context.
* Create, set up and connect a context.
*
*
* Caller must lock the main loop.
*
* @return true on success, false on error
* @return true on success, false on error
*/
*/
static
bool
static
bool
...
@@ -356,12 +360,8 @@ pulse_output_enable(void *data, GError **error_r)
...
@@ -356,12 +360,8 @@ pulse_output_enable(void *data, GError **error_r)
return
false
;
return
false
;
}
}
pa_threaded_mainloop_unlock
(
po
->
mainloop
);
/* create the libpulse context and connect it */
/* create the libpulse context and connect it */
pa_threaded_mainloop_lock
(
po
->
mainloop
);
if
(
!
pulse_output_setup_context
(
po
,
error_r
))
{
if
(
!
pulse_output_setup_context
(
po
,
error_r
))
{
pa_threaded_mainloop_unlock
(
po
->
mainloop
);
pa_threaded_mainloop_unlock
(
po
->
mainloop
);
pa_threaded_mainloop_stop
(
po
->
mainloop
);
pa_threaded_mainloop_stop
(
po
->
mainloop
);
...
@@ -393,6 +393,8 @@ pulse_output_disable(void *data)
...
@@ -393,6 +393,8 @@ pulse_output_disable(void *data)
* Check if the context is (already) connected, and waits if not. If
* Check if the context is (already) connected, and waits if not. If
* the context has been disconnected, retry to connect.
* the context has been disconnected, retry to connect.
*
*
* Caller must lock the main loop.
*
* @return true on success, false on error
* @return true on success, false on error
*/
*/
static
bool
static
bool
...
@@ -402,8 +404,6 @@ pulse_output_wait_connection(struct pulse_output *po, GError **error_r)
...
@@ -402,8 +404,6 @@ pulse_output_wait_connection(struct pulse_output *po, GError **error_r)
pa_context_state_t
state
;
pa_context_state_t
state
;
pa_threaded_mainloop_lock
(
po
->
mainloop
);
if
(
po
->
context
==
NULL
&&
!
pulse_output_setup_context
(
po
,
error_r
))
if
(
po
->
context
==
NULL
&&
!
pulse_output_setup_context
(
po
,
error_r
))
return
false
;
return
false
;
...
@@ -412,7 +412,6 @@ pulse_output_wait_connection(struct pulse_output *po, GError **error_r)
...
@@ -412,7 +412,6 @@ pulse_output_wait_connection(struct pulse_output *po, GError **error_r)
switch
(
state
)
{
switch
(
state
)
{
case
PA_CONTEXT_READY
:
case
PA_CONTEXT_READY
:
/* nothing to do */
/* nothing to do */
pa_threaded_mainloop_unlock
(
po
->
mainloop
);
return
true
;
return
true
;
case
PA_CONTEXT_UNCONNECTED
:
case
PA_CONTEXT_UNCONNECTED
:
...
@@ -423,7 +422,6 @@ pulse_output_wait_connection(struct pulse_output *po, GError **error_r)
...
@@ -423,7 +422,6 @@ pulse_output_wait_connection(struct pulse_output *po, GError **error_r)
"failed to connect: %s"
,
"failed to connect: %s"
,
pa_strerror
(
pa_context_errno
(
po
->
context
)));
pa_strerror
(
pa_context_errno
(
po
->
context
)));
pulse_output_delete_context
(
po
);
pulse_output_delete_context
(
po
);
pa_threaded_mainloop_unlock
(
po
->
mainloop
);
return
false
;
return
false
;
case
PA_CONTEXT_CONNECTING
:
case
PA_CONTEXT_CONNECTING
:
...
@@ -506,6 +504,8 @@ pulse_output_open(void *data, struct audio_format *audio_format,
...
@@ -506,6 +504,8 @@ pulse_output_open(void *data, struct audio_format *audio_format,
assert
(
po
->
mainloop
!=
NULL
);
assert
(
po
->
mainloop
!=
NULL
);
pa_threaded_mainloop_lock
(
po
->
mainloop
);
if
(
po
->
context
!=
NULL
)
{
if
(
po
->
context
!=
NULL
)
{
switch
(
pa_context_get_state
(
po
->
context
))
{
switch
(
pa_context_get_state
(
po
->
context
))
{
case
PA_CONTEXT_UNCONNECTED
:
case
PA_CONTEXT_UNCONNECTED
:
...
@@ -525,8 +525,10 @@ pulse_output_open(void *data, struct audio_format *audio_format,
...
@@ -525,8 +525,10 @@ pulse_output_open(void *data, struct audio_format *audio_format,
}
}
}
}
if
(
!
pulse_output_wait_connection
(
po
,
error_r
))
if
(
!
pulse_output_wait_connection
(
po
,
error_r
))
{
pa_threaded_mainloop_unlock
(
po
->
mainloop
);
return
false
;
return
false
;
}
/* MPD doesn't support the other pulseaudio sample formats, so
/* MPD doesn't support the other pulseaudio sample formats, so
we just force MPD to send us everything as 16 bit */
we just force MPD to send us everything as 16 bit */
...
@@ -536,8 +538,6 @@ pulse_output_open(void *data, struct audio_format *audio_format,
...
@@ -536,8 +538,6 @@ pulse_output_open(void *data, struct audio_format *audio_format,
ss
.
rate
=
audio_format
->
sample_rate
;
ss
.
rate
=
audio_format
->
sample_rate
;
ss
.
channels
=
audio_format
->
channels
;
ss
.
channels
=
audio_format
->
channels
;
pa_threaded_mainloop_lock
(
po
->
mainloop
);
/* create a stream .. */
/* create a stream .. */
po
->
stream
=
pa_stream_new
(
po
->
context
,
po
->
name
,
&
ss
,
NULL
);
po
->
stream
=
pa_stream_new
(
po
->
context
,
po
->
name
,
&
ss
,
NULL
);
...
...
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