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
855f26c4
Commit
855f26c4
authored
Feb 05, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mixer: use reference instead of pointer for MixerPlugin
parent
f86e1595
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
29 deletions
+21
-29
MixerAll.cxx
src/mixer/MixerAll.cxx
+1
-1
MixerControl.cxx
src/mixer/MixerControl.cxx
+13
-21
MixerControl.hxx
src/mixer/MixerControl.hxx
+1
-1
MixerInternal.hxx
src/mixer/MixerInternal.hxx
+3
-3
Init.cxx
src/output/Init.cxx
+2
-2
read_mixer.cxx
test/read_mixer.cxx
+1
-1
No files found.
src/mixer/MixerAll.cxx
View file @
855f26c4
...
...
@@ -149,7 +149,7 @@ MultipleOutputs::SetSoftwareVolume(unsigned volume)
const
auto
mixer
=
ao
->
mixer
;
if
(
mixer
!=
nullptr
&&
mixer
->
plugin
==
&
software_mixer_plugin
)
&
mixer
->
plugin
==
&
software_mixer_plugin
)
mixer_set_volume
(
mixer
,
volume
,
IgnoreError
());
}
}
src/mixer/MixerControl.cxx
View file @
855f26c4
...
...
@@ -26,17 +26,13 @@
Mixer
*
mixer_new
(
EventLoop
&
event_loop
,
const
MixerPlugin
*
plugin
,
void
*
ao
,
const
MixerPlugin
&
plugin
,
void
*
ao
,
const
config_param
&
param
,
Error
&
error
)
{
Mixer
*
mixer
;
Mixer
*
mixer
=
plugin
.
init
(
event_loop
,
ao
,
param
,
error
)
;
assert
(
plugin
!=
nullptr
);
mixer
=
plugin
->
init
(
event_loop
,
ao
,
param
,
error
);
assert
(
mixer
==
nullptr
||
mixer
->
IsPlugin
(
*
plugin
));
assert
(
mixer
==
nullptr
||
mixer
->
IsPlugin
(
plugin
));
return
mixer
;
}
...
...
@@ -45,13 +41,12 @@ void
mixer_free
(
Mixer
*
mixer
)
{
assert
(
mixer
!=
nullptr
);
assert
(
mixer
->
plugin
!=
nullptr
);
/* mixers with the "global" flag set might still be open at
this point (see mixer_auto_close()) */
mixer_close
(
mixer
);
mixer
->
plugin
->
finish
(
mixer
);
mixer
->
plugin
.
finish
(
mixer
);
}
bool
...
...
@@ -60,16 +55,15 @@ mixer_open(Mixer *mixer, Error &error)
bool
success
;
assert
(
mixer
!=
nullptr
);
assert
(
mixer
->
plugin
!=
nullptr
);
const
ScopeLock
protect
(
mixer
->
mutex
);
if
(
mixer
->
open
)
success
=
true
;
else
if
(
mixer
->
plugin
->
open
==
nullptr
)
else
if
(
mixer
->
plugin
.
open
==
nullptr
)
success
=
mixer
->
open
=
true
;
else
success
=
mixer
->
open
=
mixer
->
plugin
->
open
(
mixer
,
error
);
success
=
mixer
->
open
=
mixer
->
plugin
.
open
(
mixer
,
error
);
mixer
->
failed
=
!
success
;
...
...
@@ -80,11 +74,10 @@ static void
mixer_close_internal
(
Mixer
*
mixer
)
{
assert
(
mixer
!=
nullptr
);
assert
(
mixer
->
plugin
!=
nullptr
);
assert
(
mixer
->
open
);
if
(
mixer
->
plugin
->
close
!=
nullptr
)
mixer
->
plugin
->
close
(
mixer
);
if
(
mixer
->
plugin
.
close
!=
nullptr
)
mixer
->
plugin
.
close
(
mixer
);
mixer
->
open
=
false
;
}
...
...
@@ -93,7 +86,6 @@ void
mixer_close
(
Mixer
*
mixer
)
{
assert
(
mixer
!=
nullptr
);
assert
(
mixer
->
plugin
!=
nullptr
);
const
ScopeLock
protect
(
mixer
->
mutex
);
...
...
@@ -104,7 +96,7 @@ mixer_close(Mixer *mixer)
void
mixer_auto_close
(
Mixer
*
mixer
)
{
if
(
!
mixer
->
plugin
->
global
)
if
(
!
mixer
->
plugin
.
global
)
mixer_close
(
mixer
);
}
...
...
@@ -129,14 +121,14 @@ mixer_get_volume(Mixer *mixer, Error &error)
assert
(
mixer
!=
nullptr
);
if
(
mixer
->
plugin
->
global
&&
!
mixer
->
failed
&&
if
(
mixer
->
plugin
.
global
&&
!
mixer
->
failed
&&
!
mixer_open
(
mixer
,
error
))
return
-
1
;
const
ScopeLock
protect
(
mixer
->
mutex
);
if
(
mixer
->
open
)
{
volume
=
mixer
->
plugin
->
get_volume
(
mixer
,
error
);
volume
=
mixer
->
plugin
.
get_volume
(
mixer
,
error
);
if
(
volume
<
0
&&
error
.
IsDefined
())
mixer_failed
(
mixer
);
}
else
...
...
@@ -151,12 +143,12 @@ mixer_set_volume(Mixer *mixer, unsigned volume, Error &error)
assert
(
mixer
!=
nullptr
);
assert
(
volume
<=
100
);
if
(
mixer
->
plugin
->
global
&&
!
mixer
->
failed
&&
if
(
mixer
->
plugin
.
global
&&
!
mixer
->
failed
&&
!
mixer_open
(
mixer
,
error
))
return
false
;
const
ScopeLock
protect
(
mixer
->
mutex
);
return
mixer
->
open
&&
mixer
->
plugin
->
set_volume
(
mixer
,
volume
,
error
);
mixer
->
plugin
.
set_volume
(
mixer
,
volume
,
error
);
}
src/mixer/MixerControl.hxx
View file @
855f26c4
...
...
@@ -32,7 +32,7 @@ struct MixerPlugin;
struct
config_param
;
Mixer
*
mixer_new
(
EventLoop
&
event_loop
,
const
MixerPlugin
*
plugin
,
void
*
ao
,
mixer_new
(
EventLoop
&
event_loop
,
const
MixerPlugin
&
plugin
,
void
*
ao
,
const
config_param
&
param
,
Error
&
error
);
...
...
src/mixer/MixerInternal.hxx
View file @
855f26c4
...
...
@@ -26,7 +26,7 @@
class
Mixer
{
public
:
const
MixerPlugin
*
plugin
;
const
MixerPlugin
&
plugin
;
/**
* This mutex protects all of the mixer struct, including its
...
...
@@ -47,12 +47,12 @@ public:
public
:
Mixer
(
const
MixerPlugin
&
_plugin
)
:
plugin
(
&
_plugin
),
:
plugin
(
_plugin
),
open
(
false
),
failed
(
false
)
{}
bool
IsPlugin
(
const
MixerPlugin
&
other
)
const
{
return
plugin
==
&
other
;
return
&
plugin
==
&
other
;
}
};
...
...
src/output/Init.cxx
View file @
855f26c4
...
...
@@ -129,10 +129,10 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput *ao,
if
(
plugin
==
nullptr
)
return
nullptr
;
return
mixer_new
(
event_loop
,
plugin
,
ao
,
param
,
error
);
return
mixer_new
(
event_loop
,
*
plugin
,
ao
,
param
,
error
);
case
MIXER_TYPE_SOFTWARE
:
mixer
=
mixer_new
(
event_loop
,
&
software_mixer_plugin
,
nullptr
,
mixer
=
mixer_new
(
event_loop
,
software_mixer_plugin
,
nullptr
,
config_param
(),
IgnoreError
());
assert
(
mixer
!=
nullptr
);
...
...
test/read_mixer.cxx
View file @
855f26c4
...
...
@@ -116,7 +116,7 @@ int main(int argc, gcc_unused char **argv)
EventLoop
event_loop
;
Error
error
;
Mixer
*
mixer
=
mixer_new
(
event_loop
,
&
alsa_mixer_plugin
,
nullptr
,
Mixer
*
mixer
=
mixer_new
(
event_loop
,
alsa_mixer_plugin
,
nullptr
,
config_param
(),
error
);
if
(
mixer
==
NULL
)
{
LogError
(
error
,
"mixer_new() failed"
);
...
...
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