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
79b50b7d
Commit
79b50b7d
authored
Feb 16, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output_plugin: added inline wrapper functions
Similar to the decoder plugin API: added wrapper functions to increase code readability.
parent
67da4cfe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
33 deletions
+91
-33
output_control.c
src/output_control.c
+1
-2
output_init.c
src/output_init.c
+4
-3
output_plugin.h
src/output_plugin.h
+66
-0
output_thread.c
src/output_thread.c
+20
-28
No files found.
src/output_control.c
View file @
79b50b7d
...
...
@@ -140,8 +140,7 @@ void audio_output_finish(struct audio_output *ao)
g_thread_join
(
ao
->
thread
);
}
if
(
ao
->
plugin
->
finish
)
ao
->
plugin
->
finish
(
ao
->
data
);
ao_plugin_finish
(
ao
->
plugin
,
ao
->
data
);
notify_deinit
(
&
ao
->
notify
);
}
...
...
src/output_init.c
View file @
79b50b7d
...
...
@@ -69,7 +69,7 @@ audio_output_init(struct audio_output *ao, const struct config_param *param)
if
(
plugin
->
test_default_device
)
{
g_warning
(
"Attempting to detect a %s audio "
"device
\n
"
,
plugin
->
name
);
if
(
plugin
->
test_default_device
(
))
{
if
(
ao_plugin_test_default_device
(
plugin
))
{
g_warning
(
"Successfully detected a %s "
"audio device
\n
"
,
plugin
->
name
);
break
;
...
...
@@ -109,8 +109,9 @@ audio_output_init(struct audio_output *ao, const struct config_param *param)
notify_init
(
&
ao
->
notify
);
ao
->
command
=
AO_COMMAND_NONE
;
ao
->
data
=
plugin
->
init
(
ao
,
format
?
&
ao
->
config_audio_format
:
NULL
,
param
);
ao
->
data
=
ao_plugin_init
(
plugin
,
ao
,
format
?
&
ao
->
config_audio_format
:
NULL
,
param
);
if
(
ao
->
data
==
NULL
)
return
0
;
...
...
src/output_plugin.h
View file @
79b50b7d
...
...
@@ -112,4 +112,70 @@ struct audio_output_plugin {
bool
(
*
control
)(
void
*
data
,
int
cmd
,
void
*
arg
);
};
static
inline
bool
ao_plugin_test_default_device
(
const
struct
audio_output_plugin
*
plugin
)
{
return
plugin
->
test_default_device
!=
NULL
?
plugin
->
test_default_device
()
:
false
;
}
static
inline
void
*
ao_plugin_init
(
const
struct
audio_output_plugin
*
plugin
,
struct
audio_output
*
ao
,
const
struct
audio_format
*
audio_format
,
const
struct
config_param
*
param
)
{
return
plugin
->
init
(
ao
,
audio_format
,
param
);
}
static
inline
void
ao_plugin_finish
(
const
struct
audio_output_plugin
*
plugin
,
void
*
data
)
{
plugin
->
finish
(
data
);
}
static
inline
bool
ao_plugin_open
(
const
struct
audio_output_plugin
*
plugin
,
void
*
data
,
struct
audio_format
*
audio_format
)
{
return
plugin
->
open
(
data
,
audio_format
);
}
static
inline
void
ao_plugin_close
(
const
struct
audio_output_plugin
*
plugin
,
void
*
data
)
{
plugin
->
close
(
data
);
}
static
inline
void
ao_plugin_send_tag
(
const
struct
audio_output_plugin
*
plugin
,
void
*
data
,
const
struct
tag
*
tag
)
{
if
(
plugin
->
send_tag
!=
NULL
)
plugin
->
send_tag
(
data
,
tag
);
}
static
inline
bool
ao_plugin_play
(
const
struct
audio_output_plugin
*
plugin
,
void
*
data
,
const
void
*
chunk
,
size_t
size
)
{
return
plugin
->
play
(
data
,
chunk
,
size
);
}
static
inline
void
ao_plugin_cancel
(
const
struct
audio_output_plugin
*
plugin
,
void
*
data
)
{
if
(
plugin
->
cancel
!=
NULL
)
plugin
->
cancel
(
data
);
}
static
inline
bool
ao_plugin_pause
(
const
struct
audio_output_plugin
*
plugin
,
void
*
data
)
{
return
plugin
->
pause
!=
NULL
?
plugin
->
pause
(
data
)
:
false
;
}
#endif
src/output_thread.c
View file @
79b50b7d
...
...
@@ -43,7 +43,7 @@ ao_close(struct audio_output *ao)
{
assert
(
ao
->
open
);
ao
->
plugin
->
close
(
ao
->
data
);
ao
_plugin_close
(
ao
->
plugin
,
ao
->
data
);
pcm_convert_deinit
(
&
ao
->
convert_state
);
ao
->
open
=
false
;
}
...
...
@@ -69,9 +69,9 @@ static void ao_play(struct audio_output *ao)
return
;
}
ret
=
ao
->
plugin
->
play
(
ao
->
data
,
data
,
size
);
ret
=
ao
_plugin_play
(
ao
->
plugin
,
ao
->
data
,
data
,
size
);
if
(
!
ret
)
{
ao
->
plugin
->
cancel
(
ao
->
data
);
ao
_plugin_cancel
(
ao
->
plugin
,
ao
->
data
);
ao_close
(
ao
);
}
...
...
@@ -80,26 +80,18 @@ static void ao_play(struct audio_output *ao)
static
void
ao_pause
(
struct
audio_output
*
ao
)
{
ao
->
plugin
->
cancel
(
ao
->
data
);
if
(
ao
->
plugin
->
pause
!=
NULL
)
{
/* pause is supported */
ao_command_finished
(
ao
);
do
{
bool
ret
;
ret
=
ao
->
plugin
->
pause
(
ao
->
data
);
if
(
!
ret
)
{
ao_close
(
ao
);
break
;
}
}
while
(
ao
->
command
==
AO_COMMAND_NONE
);
}
else
{
/* pause is not supported - simply close the device */
ao_close
(
ao
);
ao_command_finished
(
ao
);
}
bool
ret
;
ao_plugin_cancel
(
ao
->
plugin
,
ao
->
data
);
ao_command_finished
(
ao
);
do
{
ret
=
ao_plugin_pause
(
ao
->
plugin
,
ao
->
data
);
if
(
!
ret
)
{
ao_close
(
ao
);
break
;
}
}
while
(
ao
->
command
==
AO_COMMAND_NONE
);
}
static
gpointer
audio_output_task
(
gpointer
arg
)
...
...
@@ -115,8 +107,8 @@ static gpointer audio_output_task(gpointer arg)
case
AO_COMMAND_OPEN
:
assert
(
!
ao
->
open
);
ret
=
ao
->
plugin
->
open
(
ao
->
data
,
&
ao
->
out_audio_format
);
ret
=
ao
_plugin_open
(
ao
->
plugin
,
ao
->
data
,
&
ao
->
out_audio_format
);
assert
(
!
ao
->
open
);
if
(
ret
)
{
...
...
@@ -130,8 +122,8 @@ static gpointer audio_output_task(gpointer arg)
case
AO_COMMAND_CLOSE
:
assert
(
ao
->
open
);
ao
->
plugin
->
cancel
(
ao
->
data
);
ao_plugin_cancel
(
ao
->
plugin
,
ao
->
data
);
ao_close
(
ao
);
ao_command_finished
(
ao
);
break
;
...
...
@@ -145,12 +137,12 @@ static gpointer audio_output_task(gpointer arg)
break
;
case
AO_COMMAND_CANCEL
:
ao
->
plugin
->
cancel
(
ao
->
data
);
ao
_plugin_cancel
(
ao
->
plugin
,
ao
->
data
);
ao_command_finished
(
ao
);
break
;
case
AO_COMMAND_SEND_TAG
:
ao
->
plugin
->
send_tag
(
ao
->
data
,
ao
->
args
.
tag
);
ao
_plugin_send_tag
(
ao
->
plugin
,
ao
->
data
,
ao
->
args
.
tag
);
ao_command_finished
(
ao
);
break
;
...
...
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