aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile.am14
-rw-r--r--src/IOThread.cxx (renamed from src/io_thread.c)44
-rw-r--r--src/IOThread.hxx (renamed from src/io_thread.h)7
-rw-r--r--src/Main.cxx2
-rw-r--r--src/input/CurlInputPlugin.cxx2
-rw-r--r--src/input/SoupInputPlugin.cxx2
-rw-r--r--test/dump_playlist.cxx2
-rw-r--r--test/dump_text_file.cxx2
-rw-r--r--test/read_tags.cxx2
-rw-r--r--test/run_decoder.cxx2
-rw-r--r--test/run_input.cxx3
-rw-r--r--test/run_output.cxx2
12 files changed, 40 insertions, 44 deletions
diff --git a/Makefile.am b/Makefile.am
index cb4def839..146170060 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -242,7 +242,7 @@ src_mpd_SOURCES = \
src/Log.cxx src/Log.hxx \
src/ls.cxx \
src/io_error.h \
- src/io_thread.c src/io_thread.h \
+ src/IOThread.cxx src/IOThread.hxx \
src/Main.cxx src/Main.hxx \
src/Win32Main.cxx \
src/GlobalEvents.cxx src/GlobalEvents.hxx \
@@ -1065,7 +1065,7 @@ test_run_input_LDADD = \
$(GLIB_LIBS)
test_run_input_SOURCES = test/run_input.c \
test/stdbin.h \
- src/io_thread.c src/io_thread.h \
+ src/IOThread.cxx \
src/conf.c src/tokenizer.c src/utils.c src/string_util.c\
src/Tag.cxx src/TagNames.c src/TagPool.cxx src/TagSave.cxx \
src/uri.c \
@@ -1077,7 +1077,7 @@ test_dump_text_file_LDADD = \
$(GLIB_LIBS)
test_dump_text_file_SOURCES = test/dump_text_file.cxx \
test/stdbin.h \
- src/io_thread.c src/io_thread.h \
+ src/IOThread.cxx \
src/conf.c src/tokenizer.c src/utils.c src/string_util.c\
src/Tag.cxx src/TagNames.c src/TagPool.cxx \
src/text_input_stream.c src/fifo_buffer.c \
@@ -1095,7 +1095,7 @@ test_dump_playlist_LDADD = \
$(GLIB_LIBS)
test_dump_playlist_SOURCES = test/dump_playlist.cxx \
$(DECODER_SRC) \
- src/io_thread.c src/io_thread.h \
+ src/IOThread.cxx \
src/conf.c src/tokenizer.c src/utils.c src/string_util.c\
src/uri.c \
src/Song.cxx src/Tag.cxx src/TagNames.c src/TagPool.cxx src/TagSave.cxx \
@@ -1121,7 +1121,7 @@ test_run_decoder_LDADD = \
$(GLIB_LIBS)
test_run_decoder_SOURCES = test/run_decoder.cxx \
test/stdbin.h \
- src/io_thread.c src/io_thread.h \
+ src/IOThread.cxx \
src/conf.c src/tokenizer.c src/utils.c src/string_util.c \
src/Tag.cxx src/TagNames.c src/TagPool.cxx src/tag_handler.c \
src/ReplayGainInfo.cxx \
@@ -1143,7 +1143,7 @@ test_read_tags_LDADD = \
libutil.a \
$(GLIB_LIBS)
test_read_tags_SOURCES = test/read_tags.cxx \
- src/io_thread.c src/io_thread.h \
+ src/IOThread.cxx \
src/conf.c src/tokenizer.c src/utils.c src/string_util.c \
src/Tag.cxx src/TagNames.c src/TagPool.cxx src/tag_handler.c \
src/ReplayGainInfo.cxx \
@@ -1268,7 +1268,7 @@ test_run_output_SOURCES = test/run_output.cxx \
test/FakeReplayGainConfig.cxx \
test/stdbin.h \
src/conf.c src/tokenizer.c src/utils.c src/string_util.c \
- src/io_thread.c src/io_thread.h \
+ src/IOThread.cxx \
src/audio_check.c \
src/audio_format.c \
src/audio_parser.c \
diff --git a/src/io_thread.c b/src/IOThread.cxx
index 7c080adcb..2ab2fe913 100644
--- a/src/io_thread.c
+++ b/src/IOThread.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,13 +17,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "io_thread.h"
+#include "IOThread.hxx"
+#include "thread/Mutex.hxx"
+#include "thread/Cond.hxx"
#include <assert.h>
static struct {
- GMutex *mutex;
- GCond *cond;
+ Mutex mutex;
+ Cond cond;
GMainContext *context;
GMainLoop *loop;
@@ -45,8 +47,8 @@ io_thread_func(G_GNUC_UNUSED gpointer arg)
{
/* lock+unlock to synchronize with io_thread_start(), to be
sure that io.thread is set */
- g_mutex_lock(io.mutex);
- g_mutex_unlock(io.mutex);
+ io.mutex.lock();
+ io.mutex.unlock();
io_thread_run();
return NULL;
@@ -59,8 +61,6 @@ io_thread_init(void)
assert(io.loop == NULL);
assert(io.thread == NULL);
- io.mutex = g_mutex_new();
- io.cond = g_cond_new();
io.context = g_main_context_new();
io.loop = g_main_loop_new(io.context, false);
}
@@ -72,9 +72,9 @@ io_thread_start(GError **error_r)
assert(io.loop != NULL);
assert(io.thread == NULL);
- g_mutex_lock(io.mutex);
+ io.mutex.lock();
io.thread = g_thread_create(io_thread_func, NULL, true, error_r);
- g_mutex_unlock(io.mutex);
+ io.mutex.unlock();
if (io.thread == NULL)
return false;
@@ -103,9 +103,6 @@ io_thread_deinit(void)
if (io.context != NULL)
g_main_context_unref(io.context);
-
- g_cond_free(io.cond);
- g_mutex_free(io.mutex);
}
GMainContext *
@@ -159,15 +156,15 @@ struct call_data {
static gboolean
io_thread_call_func(gpointer _data)
{
- struct call_data *data = _data;
+ struct call_data *data = (struct call_data *)_data;
gpointer result = data->function(data->data);
- g_mutex_lock(io.mutex);
+ io.mutex.lock();
data->done = true;
data->result = result;
- g_cond_broadcast(io.cond);
- g_mutex_unlock(io.mutex);
+ io.cond.broadcast();
+ io.mutex.unlock();
return false;
}
@@ -183,17 +180,18 @@ io_thread_call(GThreadFunc function, gpointer _data)
return function(_data);
struct call_data data = {
- .function = function,
- .data = _data,
- .done = false,
+ function,
+ _data,
+ false,
+ nullptr,
};
io_thread_idle_add(io_thread_call_func, &data);
- g_mutex_lock(io.mutex);
+ io.mutex.lock();
while (!data.done)
- g_cond_wait(io.cond, io.mutex);
- g_mutex_unlock(io.mutex);
+ io.cond.wait(io.mutex);
+ io.mutex.unlock();
return data.result;
}
diff --git a/src/io_thread.h b/src/IOThread.hxx
index 8ff5a71e5..8b0e687ab 100644
--- a/src/io_thread.h
+++ b/src/IOThread.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,11 +17,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_IO_THREAD_H
-#define MPD_IO_THREAD_H
+#ifndef MPD_IO_THREAD_HXX
+#define MPD_IO_THREAD_HXX
#include <glib.h>
-#include <stdbool.h>
void
io_thread_init(void);
diff --git a/src/Main.cxx b/src/Main.cxx
index d091b9641..1c58e0e40 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -45,10 +45,10 @@
#include "Log.hxx"
#include "GlobalEvents.hxx"
#include "InputInit.hxx"
+#include "IOThread.hxx"
extern "C" {
#include "daemon.h"
-#include "io_thread.h"
#include "path.h"
#include "stats.h"
#include "audio_config.h"
diff --git a/src/input/CurlInputPlugin.cxx b/src/input/CurlInputPlugin.cxx
index e2b3f11db..8210a8432 100644
--- a/src/input/CurlInputPlugin.cxx
+++ b/src/input/CurlInputPlugin.cxx
@@ -26,9 +26,9 @@
extern "C" {
#include "input_internal.h"
#include "icy_metadata.h"
-#include "io_thread.h"
}
+#include "IOThread.hxx"
#include "glib_compat.h"
#include <assert.h>
diff --git a/src/input/SoupInputPlugin.cxx b/src/input/SoupInputPlugin.cxx
index f3422d242..a591a292c 100644
--- a/src/input/SoupInputPlugin.cxx
+++ b/src/input/SoupInputPlugin.cxx
@@ -23,9 +23,9 @@
extern "C" {
#include "input_internal.h"
-#include "io_thread.h"
}
+#include "IOThread.hxx"
#include "conf.h"
extern "C" {
diff --git a/test/dump_playlist.cxx b/test/dump_playlist.cxx
index b3d03a85e..c95d4376e 100644
--- a/test/dump_playlist.cxx
+++ b/test/dump_playlist.cxx
@@ -25,9 +25,9 @@
#include "conf.h"
#include "decoder_api.h"
#include "InputInit.hxx"
+#include "IOThread.hxx"
extern "C" {
-#include "io_thread.h"
#include "decoder_list.h"
#include "playlist_list.h"
#include "playlist_plugin.h"
diff --git a/test/dump_text_file.cxx b/test/dump_text_file.cxx
index c0f1c86f8..60da1c31c 100644
--- a/test/dump_text_file.cxx
+++ b/test/dump_text_file.cxx
@@ -18,13 +18,13 @@
*/
#include "config.h"
+#include "IOThread.hxx"
#include "InputInit.hxx"
#include "input_stream.h"
#include "conf.h"
#include "stdbin.h"
extern "C" {
-#include "io_thread.h"
#include "text_input_stream.h"
#ifdef ENABLE_ARCHIVE
diff --git a/test/read_tags.cxx b/test/read_tags.cxx
index 9fabddc6b..f971c5ce1 100644
--- a/test/read_tags.cxx
+++ b/test/read_tags.cxx
@@ -18,8 +18,8 @@
*/
#include "config.h"
+#include "IOThread.hxx"
extern "C" {
-#include "io_thread.h"
#include "decoder_list.h"
}
#include "decoder_api.h"
diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx
index 776c11e87..b3e90844c 100644
--- a/test/run_decoder.cxx
+++ b/test/run_decoder.cxx
@@ -18,8 +18,8 @@
*/
#include "config.h"
+#include "IOThread.hxx"
extern "C" {
-#include "io_thread.h"
#include "decoder_list.h"
}
#include "decoder_api.h"
diff --git a/test/run_input.cxx b/test/run_input.cxx
index adf380f00..1508d0d94 100644
--- a/test/run_input.cxx
+++ b/test/run_input.cxx
@@ -24,10 +24,9 @@
#include "conf.h"
#include "input_stream.h"
#include "InputInit.hxx"
+#include "IOThread.hxx"
extern "C" {
-#include "io_thread.h"
-
#ifdef ENABLE_ARCHIVE
#include "archive_list.h"
#endif
diff --git a/test/run_output.cxx b/test/run_output.cxx
index 9964e47ed..29fb6462c 100644
--- a/test/run_output.cxx
+++ b/test/run_output.cxx
@@ -22,11 +22,11 @@
#include "conf.h"
#include "Idle.hxx"
#include "GlobalEvents.hxx"
+#include "IOThread.hxx"
extern "C" {
#include "output_plugin.h"
#include "output_internal.h"
-#include "io_thread.h"
#include "audio_parser.h"
#include "filter_registry.h"
#include "pcm_convert.h"