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
7b540f02
Commit
7b540f02
authored
Jan 05, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/MultiSocketMonitor: add method ReplaceSocketList()
Move code from AlsaMixerPlugin.
parent
e29c22e6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
18 deletions
+43
-18
MultiSocketMonitor.cxx
src/event/MultiSocketMonitor.cxx
+30
-0
MultiSocketMonitor.hxx
src/event/MultiSocketMonitor.hxx
+12
-0
AlsaMixerPlugin.cxx
src/mixer/AlsaMixerPlugin.cxx
+1
-18
No files found.
src/event/MultiSocketMonitor.cxx
View file @
7b540f02
...
@@ -20,6 +20,10 @@
...
@@ -20,6 +20,10 @@
#include "config.h"
#include "config.h"
#include "MultiSocketMonitor.hxx"
#include "MultiSocketMonitor.hxx"
#ifndef WIN32
#include <poll.h>
#endif
MultiSocketMonitor
::
MultiSocketMonitor
(
EventLoop
&
_loop
)
MultiSocketMonitor
::
MultiSocketMonitor
(
EventLoop
&
_loop
)
:
IdleMonitor
(
_loop
),
TimeoutMonitor
(
_loop
),
ready
(
false
)
{
:
IdleMonitor
(
_loop
),
TimeoutMonitor
(
_loop
),
ready
(
false
)
{
}
}
...
@@ -29,6 +33,32 @@ MultiSocketMonitor::~MultiSocketMonitor()
...
@@ -29,6 +33,32 @@ MultiSocketMonitor::~MultiSocketMonitor()
// TODO
// TODO
}
}
#ifndef WIN32
void
MultiSocketMonitor
::
ReplaceSocketList
(
pollfd
*
pfds
,
unsigned
n
)
{
pollfd
*
const
end
=
pfds
+
n
;
UpdateSocketList
([
pfds
,
end
](
int
fd
)
->
unsigned
{
auto
i
=
std
::
find_if
(
pfds
,
end
,
[
fd
](
const
struct
pollfd
&
pfd
){
return
pfd
.
fd
==
fd
;
});
if
(
i
==
end
)
return
0
;
auto
events
=
i
->
events
;
i
->
events
=
0
;
return
events
;
});
for
(
auto
i
=
pfds
;
i
!=
end
;
++
i
)
if
(
i
->
events
!=
0
)
AddSocket
(
i
->
fd
,
i
->
events
);
}
#endif
void
void
MultiSocketMonitor
::
Prepare
()
MultiSocketMonitor
::
Prepare
()
{
{
...
...
src/event/MultiSocketMonitor.hxx
View file @
7b540f02
...
@@ -39,6 +39,10 @@
...
@@ -39,6 +39,10 @@
#endif
#endif
#endif
#endif
#ifndef WIN32
struct
pollfd
;
#endif
class
EventLoop
;
class
EventLoop
;
/**
/**
...
@@ -135,6 +139,14 @@ public:
...
@@ -135,6 +139,14 @@ public:
}
}
}
}
#ifndef WIN32
/**
* Replace the socket list with the given file descriptors.
* The given pollfd array will be modified by this method.
*/
void
ReplaceSocketList
(
pollfd
*
pfds
,
unsigned
n
);
#endif
protected
:
protected
:
/**
/**
* @return timeout [ms] or -1 for no timeout
* @return timeout [ms] or -1 for no timeout
...
...
src/mixer/AlsaMixerPlugin.cxx
View file @
7b540f02
...
@@ -104,24 +104,7 @@ AlsaMixerMonitor::PrepareSockets()
...
@@ -104,24 +104,7 @@ AlsaMixerMonitor::PrepareSockets()
if
(
count
<
0
)
if
(
count
<
0
)
count
=
0
;
count
=
0
;
struct
pollfd
*
end
=
pfds
+
count
;
ReplaceSocketList
(
pfds
,
count
);
UpdateSocketList
([
pfds
,
end
](
int
fd
)
->
unsigned
{
auto
i
=
std
::
find_if
(
pfds
,
end
,
[
fd
](
const
struct
pollfd
&
pfd
){
return
pfd
.
fd
==
fd
;
});
if
(
i
==
end
)
return
0
;
auto
events
=
i
->
events
;
i
->
events
=
0
;
return
events
;
});
for
(
auto
i
=
pfds
;
i
!=
end
;
++
i
)
if
(
i
->
events
!=
0
)
AddSocket
(
i
->
fd
,
i
->
events
);
return
-
1
;
return
-
1
;
}
}
...
...
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