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
51d793be
Commit
51d793be
authored
Aug 14, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/pulse: simplify _wait_stream()
One large loop and only one pa_stream_get_state() call.
parent
249dcd96
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
46 deletions
+7
-46
pulse_output_plugin.c
src/output/pulse_output_plugin.c
+7
-46
No files found.
src/output/pulse_output_plugin.c
View file @
51d793be
...
@@ -682,35 +682,6 @@ pulse_output_close(struct audio_output *ao)
...
@@ -682,35 +682,6 @@ pulse_output_close(struct audio_output *ao)
}
}
/**
/**
* Check if the stream is (already) connected, and waits for a signal
* if not. The mainloop must be locked before calling this function.
*
* @return the current stream state
*/
static
pa_stream_state_t
pulse_output_check_stream
(
struct
pulse_output
*
po
)
{
pa_stream_state_t
state
=
pa_stream_get_state
(
po
->
stream
);
assert
(
po
->
mainloop
!=
NULL
);
switch
(
state
)
{
case
PA_STREAM_READY
:
case
PA_STREAM_FAILED
:
case
PA_STREAM_TERMINATED
:
case
PA_STREAM_UNCONNECTED
:
break
;
case
PA_STREAM_CREATING
:
pa_threaded_mainloop_wait
(
po
->
mainloop
);
state
=
pa_stream_get_state
(
po
->
stream
);
break
;
}
return
state
;
}
/**
* Check if the stream is (already) connected, and waits if not. The
* Check if the stream is (already) connected, and waits if not. The
* mainloop must be locked before calling this function.
* mainloop must be locked before calling this function.
*
*
...
@@ -719,35 +690,25 @@ pulse_output_check_stream(struct pulse_output *po)
...
@@ -719,35 +690,25 @@ pulse_output_check_stream(struct pulse_output *po)
static
bool
static
bool
pulse_output_wait_stream
(
struct
pulse_output
*
po
,
GError
**
error_r
)
pulse_output_wait_stream
(
struct
pulse_output
*
po
,
GError
**
error_r
)
{
{
pa_stream_state_t
state
=
pa_stream_get_state
(
po
->
stream
);
while
(
true
)
{
switch
(
pa_stream_get_state
(
po
->
stream
))
{
switch
(
state
)
{
case
PA_STREAM_READY
:
case
PA_STREAM_READY
:
return
true
;
return
true
;
case
PA_STREAM_FAILED
:
case
PA_STREAM_FAILED
:
case
PA_STREAM_TERMINATED
:
case
PA_STREAM_TERMINATED
:
case
PA_STREAM_UNCONNECTED
:
case
PA_STREAM_UNCONNECTED
:
g_set_error
(
error_r
,
pulse_output_quark
(),
0
,
g_set_error
(
error_r
,
pulse_output_quark
(),
"disconnected"
);
pa_context_errno
(
po
->
context
),
"failed to connect the stream: %s"
,
pa_strerror
(
pa_context_errno
(
po
->
context
)));
return
false
;
return
false
;
case
PA_STREAM_CREATING
:
case
PA_STREAM_CREATING
:
pa_threaded_mainloop_wait
(
po
->
mainloop
);
break
;
break
;
}
}
do
{
state
=
pulse_output_check_stream
(
po
);
}
while
(
state
==
PA_STREAM_CREATING
);
if
(
state
!=
PA_STREAM_READY
)
{
g_set_error
(
error_r
,
pulse_output_quark
(),
0
,
"failed to connect the stream: %s"
,
pa_strerror
(
pa_context_errno
(
po
->
context
)));
return
false
;
}
}
return
true
;
}
}
/**
/**
...
...
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