aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-10 09:30:01 +0100
committerMax Kellermann <max@duempel.org>2013-01-10 10:12:54 +0100
commit06e0741a5293b1db2ef5f2b5778e3669f2dea70e (patch)
treec4087216ef0ff34a0854ff50dc259c0d13c41471 /src
parent0b93445380ba39c13813e1a236b183883f5a54db (diff)
PlayerControl: switch to the Mutex/Cond classes
Diffstat (limited to 'src')
-rw-r--r--src/PlayerControl.cxx7
-rw-r--r--src/PlayerControl.hxx14
-rw-r--r--src/PlayerThread.cxx2
3 files changed, 10 insertions, 13 deletions
diff --git a/src/PlayerControl.cxx b/src/PlayerControl.cxx
index 857322c5..6246e023 100644
--- a/src/PlayerControl.cxx
+++ b/src/PlayerControl.cxx
@@ -37,8 +37,6 @@ player_control::player_control(unsigned _buffer_chunks,
:buffer_chunks(_buffer_chunks),
buffered_before_play(_buffered_before_play),
thread(nullptr),
- mutex(g_mutex_new()),
- cond(g_cond_new()),
command(PLAYER_COMMAND_NONE),
state(PLAYER_STATE_STOP),
error_type(PLAYER_ERROR_NONE),
@@ -55,9 +53,6 @@ player_control::~player_control()
{
if (next_song != nullptr)
song_free(next_song);
-
- g_cond_free(cond);
- g_mutex_free(mutex);
}
void
@@ -76,7 +71,7 @@ static void
player_command_wait_locked(struct player_control *pc)
{
while (pc->command != PLAYER_COMMAND_NONE)
- g_cond_wait(pc->cond, pc->mutex);
+ pc->cond.wait(pc->mutex);
}
static void
diff --git a/src/PlayerControl.hxx b/src/PlayerControl.hxx
index 1a050320..322b95c8 100644
--- a/src/PlayerControl.hxx
+++ b/src/PlayerControl.hxx
@@ -21,6 +21,8 @@
#define MPD_PLAYER_H
#include "audio_format.h"
+#include "thread/Mutex.hxx"
+#include "thread/Cond.hxx"
#include <glib.h>
@@ -99,12 +101,12 @@ struct player_control {
/**
* This lock protects #command, #state, #error.
*/
- GMutex *mutex;
+ Mutex mutex;
/**
* Trigger this object after you have modified #command.
*/
- GCond *cond;
+ Cond cond;
enum player_command command;
enum player_state state;
@@ -158,7 +160,7 @@ struct player_control {
static inline void
player_lock(struct player_control *pc)
{
- g_mutex_lock(pc->mutex);
+ pc->mutex.lock();
}
/**
@@ -167,7 +169,7 @@ player_lock(struct player_control *pc)
static inline void
player_unlock(struct player_control *pc)
{
- g_mutex_unlock(pc->mutex);
+ pc->mutex.unlock();
}
/**
@@ -178,7 +180,7 @@ player_unlock(struct player_control *pc)
static inline void
player_wait(struct player_control *pc)
{
- g_cond_wait(pc->cond, pc->mutex);
+ pc->cond.wait(pc->mutex);
}
/**
@@ -198,7 +200,7 @@ player_wait_decoder(struct player_control *pc, struct decoder_control *dc);
static inline void
player_signal(struct player_control *pc)
{
- g_cond_signal(pc->cond);
+ pc->cond.signal();
}
/**
diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx
index 775e53ef..fb743236 100644
--- a/src/PlayerThread.cxx
+++ b/src/PlayerThread.cxx
@@ -147,7 +147,7 @@ player_command_finished_locked(struct player_control *pc)
assert(pc->command != PLAYER_COMMAND_NONE);
pc->command = PLAYER_COMMAND_NONE;
- g_cond_signal(pc->cond);
+ pc->cond.signal();
}
static void