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
b8cda53b
Commit
b8cda53b
authored
Jan 10, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notify: convert to C++
parent
e0a97a03
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
73 deletions
+52
-73
Makefile.am
Makefile.am
+1
-2
OutputAll.cxx
src/OutputAll.cxx
+2
-9
OutputControl.cxx
src/OutputControl.cxx
+2
-2
OutputThread.cxx
src/OutputThread.cxx
+2
-2
notify.cxx
src/notify.cxx
+17
-30
notify.hxx
src/notify.hxx
+28
-28
No files found.
Makefile.am
View file @
b8cda53b
...
...
@@ -46,7 +46,6 @@ src_mpd_LDADD = \
mpd_headers
=
\
src/check.h
\
src/notify.h
\
src/ack.h
\
src/ape.h
\
src/audio_format.h
\
...
...
@@ -166,7 +165,7 @@ src_mpd_SOURCES = \
src/thread/GLibCond.hxx
\
src/glib_socket.h
\
src/clock.c src/clock.h
\
src/notify.c
\
src/notify.c
xx src/notify.hxx
\
src/audio_config.c src/audio_config.h
\
src/audio_check.c
\
src/audio_format.c
\
...
...
src/OutputAll.cxx
View file @
b8cda53b
...
...
@@ -32,10 +32,7 @@ extern "C" {
#include "MusicChunk.hxx"
#include "mpd_error.h"
#include "conf.h"
extern
"C"
{
#include "notify.h"
}
#include "notify.hxx"
#include <assert.h>
#include <string.h>
...
...
@@ -113,8 +110,6 @@ audio_output_all_init(struct player_control *pc)
unsigned
int
i
;
GError
*
error
=
NULL
;
notify_init
(
&
audio_output_client_notify
);
num_audio_outputs
=
audio_output_config_count
();
audio_outputs
=
g_new
(
struct
audio_output
*
,
num_audio_outputs
);
...
...
@@ -161,8 +156,6 @@ audio_output_all_finish(void)
g_free
(
audio_outputs
);
audio_outputs
=
NULL
;
num_audio_outputs
=
0
;
notify_deinit
(
&
audio_output_client_notify
);
}
void
...
...
@@ -211,7 +204,7 @@ audio_output_all_finished(void)
static
void
audio_output_wait_all
(
void
)
{
while
(
!
audio_output_all_finished
())
notify_wait
(
&
audio_output_client_notify
);
audio_output_client_notify
.
Wait
(
);
}
/**
...
...
src/OutputControl.cxx
View file @
b8cda53b
...
...
@@ -26,9 +26,9 @@ extern "C" {
#include "output_internal.h"
#include "mixer_control.h"
#include "mixer_plugin.h"
#include "notify.h"
}
#include "notify.hxx"
#include "filter/ReplayGainFilterPlugin.hxx"
#include "filter_plugin.h"
...
...
@@ -52,7 +52,7 @@ static void ao_command_wait(struct audio_output *ao)
{
while
(
ao
->
command
!=
AO_COMMAND_NONE
)
{
g_mutex_unlock
(
ao
->
mutex
);
notify_wait
(
&
audio_output_client_notify
);
audio_output_client_notify
.
Wait
(
);
g_mutex_lock
(
ao
->
mutex
);
}
}
...
...
src/OutputThread.cxx
View file @
b8cda53b
...
...
@@ -26,9 +26,9 @@ extern "C" {
#include "pcm_mix.h"
#include "filter_plugin.h"
#include "filter/convert_filter_plugin.h"
#include "notify.h"
}
#include "notify.hxx"
#include "filter/ReplayGainFilterPlugin.hxx"
#include "PlayerControl.hxx"
#include "MusicPipe.hxx"
...
...
@@ -52,7 +52,7 @@ static void ao_command_finished(struct audio_output *ao)
ao
->
command
=
AO_COMMAND_NONE
;
g_mutex_unlock
(
ao
->
mutex
);
notify_signal
(
&
audio_output_client_notify
);
audio_output_client_notify
.
Signal
(
);
g_mutex_lock
(
ao
->
mutex
);
}
...
...
src/notify.c
→
src/notify.c
xx
View file @
b8cda53b
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,41 +18,28 @@
*/
#include "config.h"
#include "notify.h"
#include "notify.h
xx
"
void
notify_init
(
struct
notify
*
notify
)
void
notify
::
Wait
()
{
notify
->
mutex
=
g_mutex_new
();
notify
->
cond
=
g_cond_new
();
notify
->
pending
=
false
;
const
ScopeLock
protect
(
mutex
);
while
(
!
pending
)
cond
.
wait
(
mutex
);
pending
=
false
;
}
void
notify_deinit
(
struct
notify
*
notify
)
void
notify
::
Signal
()
{
g_mutex_free
(
notify
->
mutex
);
g_cond_free
(
notify
->
cond
);
const
ScopeLock
protect
(
mutex
);
pending
=
true
;
cond
.
signal
();
}
void
notify_wait
(
struct
notify
*
notify
)
void
notify
::
Clear
()
{
g_mutex_lock
(
notify
->
mutex
);
while
(
!
notify
->
pending
)
g_cond_wait
(
notify
->
cond
,
notify
->
mutex
);
notify
->
pending
=
false
;
g_mutex_unlock
(
notify
->
mutex
);
}
void
notify_signal
(
struct
notify
*
notify
)
{
g_mutex_lock
(
notify
->
mutex
);
notify
->
pending
=
true
;
g_cond_signal
(
notify
->
cond
);
g_mutex_unlock
(
notify
->
mutex
);
}
void
notify_clear
(
struct
notify
*
notify
)
{
g_mutex_lock
(
notify
->
mutex
);
notify
->
pending
=
false
;
g_mutex_unlock
(
notify
->
mutex
);
const
ScopeLock
protect
(
mutex
);
pending
=
false
;
}
src/notify.h
→
src/notify.h
xx
View file @
b8cda53b
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,37 +17,37 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_NOTIFY_H
#define MPD_NOTIFY_H
#ifndef MPD_NOTIFY_H
XX
#define MPD_NOTIFY_H
XX
#include <glib.h>
#include <stdbool.h>
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
struct
notify
{
GMutex
*
mutex
;
GCond
*
cond
;
Mutex
mutex
;
Cond
cond
;
bool
pending
;
};
void
notify_init
(
struct
notify
*
notify
);
void
notify_deinit
(
struct
notify
*
notify
);
/**
* Wait for a notification. Return immediately if we have already
* been notified since we last returned from notify_wait().
*/
void
notify_wait
(
struct
notify
*
notify
);
/**
* Notify the thread. This function never blocks.
*/
void
notify_signal
(
struct
notify
*
notify
);
/**
* Clears a pending notification.
*/
void
notify_clear
(
struct
notify
*
notify
);
#ifndef WIN32
constexpr
#endif
notify
()
:
pending
(
false
)
{}
/**
* Wait for a notification. Return immediately if we have already
* been notified since we last returned from notify_wait().
*/
void
Wait
();
/**
* Notify the thread. This function never blocks.
*/
void
Signal
();
/**
* Clears a pending notification.
*/
void
Clear
();
};
#endif
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