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
d42c0f1d
Commit
d42c0f1d
authored
Oct 12, 2014
by
NanoTech
Committed by
Max Kellermann
Oct 31, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Main: run the OS X native event loop after forking
parent
6ad1e4d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
Main.cxx
src/Main.cxx
+27
-0
No files found.
src/Main.cxx
View file @
d42c0f1d
...
...
@@ -114,6 +114,10 @@
#include <ws2tcpip.h>
#endif
#ifdef __APPLE__
#include <dispatch/dispatch.h>
#endif
#include <limits.h>
static
constexpr
unsigned
DEFAULT_BUFFER_SIZE
=
4096
;
...
...
@@ -408,6 +412,8 @@ int main(int argc, char *argv[])
#endif
static
int
mpd_main_after_fork
(
struct
options
);
#ifdef ANDROID
static
inline
#endif
...
...
@@ -511,6 +517,27 @@ int mpd_main(int argc, char *argv[])
daemonize_begin
(
options
.
daemon
);
#endif
#ifdef __APPLE__
/* Runs the OS X native event loop in the main thread, and runs
the rest of mpd_main on a new thread. This lets CoreAudio receive
route change notifications (e.g. plugging or unplugging headphones).
All hardware output on OS X ultimately uses CoreAudio internally.
This must be run after forking; if dispatch is called before forking,
the child process will have a broken internal dispatch state. */
dispatch_async
(
dispatch_get_global_queue
(
DISPATCH_QUEUE_PRIORITY_DEFAULT
,
0
),
^
{
exit
(
mpd_main_after_fork
(
options
));
});
dispatch_main
();
return
EXIT_FAILURE
;
// unreachable, because dispatch_main never returns
#else
return
mpd_main_after_fork
(
options
);
#endif
}
static
int
mpd_main_after_fork
(
struct
options
options
)
{
Error
error
;
GlobalEvents
::
Initialize
(
*
instance
->
event_loop
);
GlobalEvents
::
Register
(
GlobalEvents
::
IDLE
,
idle_event_emitted
);
#ifdef WIN32
...
...
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