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
7b5f7c04
Commit
7b5f7c04
authored
Apr 16, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MixerInternal: use Mutex instead of GMutex
parent
8ce9b530
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
27 deletions
+10
-27
MixerControl.cxx
src/MixerControl.cxx
+8
-23
MixerInternal.hxx
src/MixerInternal.hxx
+2
-4
No files found.
src/MixerControl.cxx
View file @
7b5f7c04
...
...
@@ -21,6 +21,8 @@
#include "MixerControl.hxx"
#include "MixerInternal.hxx"
#include <glib.h>
#include <assert.h>
#include <stddef.h>
...
...
@@ -48,14 +50,11 @@ mixer_free(Mixer *mixer)
{
assert
(
mixer
!=
NULL
);
assert
(
mixer
->
plugin
!=
NULL
);
assert
(
mixer
->
mutex
!=
NULL
);
/* mixers with the "global" flag set might still be open at
this point (see mixer_auto_close()) */
mixer_close
(
mixer
);
g_mutex_free
(
mixer
->
mutex
);
mixer
->
plugin
->
finish
(
mixer
);
}
...
...
@@ -67,7 +66,7 @@ mixer_open(Mixer *mixer, GError **error_r)
assert
(
mixer
!=
NULL
);
assert
(
mixer
->
plugin
!=
NULL
);
g_mutex_lock
(
mixer
->
mutex
);
const
ScopeLock
protect
(
mixer
->
mutex
);
if
(
mixer
->
open
)
success
=
true
;
...
...
@@ -78,8 +77,6 @@ mixer_open(Mixer *mixer, GError **error_r)
mixer
->
failed
=
!
success
;
g_mutex_unlock
(
mixer
->
mutex
);
return
success
;
}
...
...
@@ -102,12 +99,10 @@ mixer_close(Mixer *mixer)
assert
(
mixer
!=
NULL
);
assert
(
mixer
->
plugin
!=
NULL
);
g_mutex_lock
(
mixer
->
mutex
);
const
ScopeLock
protect
(
mixer
->
mutex
);
if
(
mixer
->
open
)
mixer_close_internal
(
mixer
);
g_mutex_unlock
(
mixer
->
mutex
);
}
void
...
...
@@ -142,7 +137,7 @@ mixer_get_volume(Mixer *mixer, GError **error_r)
!
mixer_open
(
mixer
,
error_r
))
return
-
1
;
g_mutex_lock
(
mixer
->
mutex
);
const
ScopeLock
protect
(
mixer
->
mutex
);
if
(
mixer
->
open
)
{
GError
*
error
=
NULL
;
...
...
@@ -155,16 +150,12 @@ mixer_get_volume(Mixer *mixer, GError **error_r)
}
else
volume
=
-
1
;
g_mutex_unlock
(
mixer
->
mutex
);
return
volume
;
}
bool
mixer_set_volume
(
Mixer
*
mixer
,
unsigned
volume
,
GError
**
error_r
)
{
bool
success
;
assert
(
mixer
!=
NULL
);
assert
(
volume
<=
100
);
...
...
@@ -172,14 +163,8 @@ mixer_set_volume(Mixer *mixer, unsigned volume, GError **error_r)
!
mixer_open
(
mixer
,
error_r
))
return
false
;
g_mutex_lock
(
mixer
->
mutex
);
if
(
mixer
->
open
)
{
success
=
mixer
->
plugin
->
set_volume
(
mixer
,
volume
,
error_r
);
}
else
success
=
false
;
g_mutex_unlock
(
mixer
->
mutex
);
const
ScopeLock
protect
(
mixer
->
mutex
);
return
success
;
return
mixer
->
open
&&
mixer
->
plugin
->
set_volume
(
mixer
,
volume
,
error_r
);
}
src/MixerInternal.hxx
View file @
7b5f7c04
...
...
@@ -22,8 +22,7 @@
#include "MixerPlugin.hxx"
#include "MixerList.hxx"
#include <glib.h>
#include "thread/Mutex.hxx"
class
Mixer
{
public
:
...
...
@@ -33,7 +32,7 @@ public:
* This mutex protects all of the mixer struct, including its
* implementation, so plugins don't have to deal with that.
*/
GMutex
*
mutex
;
Mutex
mutex
;
/**
* Is the mixer device currently open?
...
...
@@ -49,7 +48,6 @@ public:
public
:
Mixer
(
const
mixer_plugin
&
_plugin
)
:
plugin
(
&
_plugin
),
mutex
(
g_mutex_new
()),
open
(
false
),
failed
(
false
)
{}
...
...
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