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
d5e42297
Commit
d5e42297
authored
Dec 28, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/Plugin: delay() returns std::chrono::steady_clock::duration
parent
871ba5a4
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
49 additions
and
42 deletions
+49
-42
OutputPlugin.cxx
src/output/OutputPlugin.cxx
+2
-2
OutputPlugin.hxx
src/output/OutputPlugin.hxx
+5
-3
OutputThread.cxx
src/output/OutputThread.cxx
+2
-2
Wrapper.hxx
src/output/Wrapper.hxx
+3
-1
FifoOutputPlugin.cxx
src/output/plugins/FifoOutputPlugin.cxx
+4
-4
HaikuOutputPlugin.cxx
src/output/plugins/HaikuOutputPlugin.cxx
+3
-3
JackOutputPlugin.cxx
src/output/plugins/JackOutputPlugin.cxx
+3
-3
NullOutputPlugin.cxx
src/output/plugins/NullOutputPlugin.cxx
+3
-3
OSXOutputPlugin.cxx
src/output/plugins/OSXOutputPlugin.cxx
+4
-2
OpenALOutputPlugin.cxx
src/output/plugins/OpenALOutputPlugin.cxx
+3
-3
PulseOutputPlugin.cxx
src/output/plugins/PulseOutputPlugin.cxx
+4
-4
ShoutOutputPlugin.cxx
src/output/plugins/ShoutOutputPlugin.cxx
+3
-3
SndioOutputPlugin.cxx
src/output/plugins/SndioOutputPlugin.cxx
+0
-1
HttpdInternal.hxx
src/output/plugins/httpd/HttpdInternal.hxx
+1
-1
HttpdOutputPlugin.cxx
src/output/plugins/httpd/HttpdOutputPlugin.cxx
+5
-5
SlesOutputPlugin.cxx
src/output/plugins/sles/SlesOutputPlugin.cxx
+4
-2
No files found.
src/output/OutputPlugin.cxx
View file @
d5e42297
...
...
@@ -63,12 +63,12 @@ ao_plugin_close(AudioOutput *ao)
ao
->
plugin
.
close
(
ao
);
}
unsigned
std
::
chrono
::
steady_clock
::
duration
ao_plugin_delay
(
AudioOutput
*
ao
)
{
return
ao
->
plugin
.
delay
!=
nullptr
?
ao
->
plugin
.
delay
(
ao
)
:
0
;
:
std
::
chrono
::
steady_clock
::
duration
::
zero
()
;
}
void
...
...
src/output/OutputPlugin.hxx
View file @
d5e42297
...
...
@@ -22,6 +22,8 @@
#include "Compiler.h"
#include <chrono>
#include <stddef.h>
struct
ConfigBlock
;
...
...
@@ -97,9 +99,9 @@ struct AudioOutputPlugin {
* instead of doing a sleep inside the plugin, because this
* allows MPD to listen to commands meanwhile.
*
* @return the
number of milliseconds
to wait
* @return the
duration
to wait
*/
unsigned
(
*
delay
)(
AudioOutput
*
data
);
std
::
chrono
::
steady_clock
::
duration
(
*
delay
)(
AudioOutput
*
data
);
/**
* Display metadata for the next chunk. Optional method,
...
...
@@ -179,7 +181,7 @@ void
ao_plugin_close
(
AudioOutput
*
ao
);
gcc_pure
unsigned
std
::
chrono
::
steady_clock
::
duration
ao_plugin_delay
(
AudioOutput
*
ao
);
void
...
...
src/output/OutputThread.cxx
View file @
d5e42297
...
...
@@ -237,8 +237,8 @@ inline bool
AudioOutput
::
WaitForDelay
()
{
while
(
true
)
{
unsigned
delay
=
ao_plugin_delay
(
this
);
if
(
delay
==
0
)
const
auto
delay
=
ao_plugin_delay
(
this
);
if
(
delay
<=
std
::
chrono
::
steady_clock
::
duration
::
zero
()
)
return
true
;
(
void
)
cond
.
timed_wait
(
mutex
,
delay
);
...
...
src/output/Wrapper.hxx
View file @
d5e42297
...
...
@@ -22,6 +22,8 @@
#include "util/Cast.hxx"
#include <chrono>
struct
ConfigBlock
;
template
<
class
T
>
...
...
@@ -61,7 +63,7 @@ struct AudioOutputWrapper {
}
gcc_pure
static
unsigned
Delay
(
AudioOutput
*
ao
)
{
static
std
::
chrono
::
steady_clock
::
duration
Delay
(
AudioOutput
*
ao
)
{
T
&
t
=
Cast
(
*
ao
);
return
t
.
Delay
();
}
...
...
src/output/plugins/FifoOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -66,7 +66,7 @@ public:
void
Open
(
AudioFormat
&
audio_format
);
void
Close
();
unsigned
Delay
()
const
;
std
::
chrono
::
steady_clock
::
duration
Delay
()
const
;
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
void
Cancel
();
};
...
...
@@ -204,12 +204,12 @@ FifoOutput::Cancel()
}
}
inline
unsigned
inline
std
::
chrono
::
steady_clock
::
duration
FifoOutput
::
Delay
()
const
{
return
timer
->
IsStarted
()
?
timer
->
GetDelay
(
)
:
0
;
?
std
::
chrono
::
milliseconds
(
timer
->
GetDelay
()
)
:
std
::
chrono
::
steady_clock
::
duration
::
zero
()
;
}
inline
size_t
...
...
src/output/plugins/HaikuOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -79,7 +79,7 @@ public:
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
void
Cancel
();
s
ize_t
Delay
();
s
td
::
chrono
::
steady_clock
::
duration
Delay
();
void
FillBuffer
(
void
*
_buffer
,
size_t
size
,
gcc_unused
const
media_raw_audio_format
&
_format
);
...
...
@@ -308,7 +308,7 @@ HaikuOutput::Play(const void *chunk, size_t size)
return
size
;
}
inline
s
ize_t
inline
s
td
::
chrono
::
steady_clock
::
duration
HaikuOutput
::
Delay
()
{
unsigned
delay
=
buffer_filled
?
0
:
buffer_delay
;
...
...
@@ -319,7 +319,7 @@ HaikuOutput::Delay()
//return (delay / 2) ? 1 : 0;
(
void
)
delay
;
return
0
;
return
std
::
chrono
::
steady_clock
::
duration
::
zero
()
;
}
inline
void
...
...
src/output/plugins/JackOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -128,10 +128,10 @@ struct JackOutput {
*/
size_t
WriteSamples
(
const
float
*
src
,
size_t
n_frames
);
unsigned
Delay
()
const
{
std
::
chrono
::
steady_clock
::
duration
Delay
()
const
{
return
base
.
pause
&&
pause
&&
!
shutdown
?
1000
:
0
;
?
std
::
chrono
::
seconds
(
1
)
:
std
::
chrono
::
steady_clock
::
duration
::
zero
()
;
}
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
...
...
src/output/plugins/NullOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -49,10 +49,10 @@ public:
delete
timer
;
}
unsigned
Delay
()
const
{
std
::
chrono
::
steady_clock
::
duration
Delay
()
const
{
return
sync
&&
timer
->
IsStarted
()
?
timer
->
GetDelay
(
)
:
0
;
?
std
::
chrono
::
milliseconds
(
timer
->
GetDelay
()
)
:
std
::
chrono
::
steady_clock
::
duration
::
zero
()
;
}
size_t
Play
(
gcc_unused
const
void
*
chunk
,
size_t
size
)
{
...
...
src/output/plugins/OSXOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -669,11 +669,13 @@ osx_output_play(AudioOutput *ao, const void *chunk, size_t size)
return
od
->
ring_buffer
->
push
((
uint8_t
*
)
chunk
,
size
);
}
static
unsigned
static
std
::
chrono
::
steady_clock
::
duration
osx_output_delay
(
AudioOutput
*
ao
)
{
OSXOutput
*
od
=
(
OSXOutput
*
)
ao
;
return
od
->
ring_buffer
->
write_available
()
?
0
:
25
;
return
od
->
ring_buffer
->
write_available
()
?
std
::
chrono
::
steady_clock
::
duration
::
zero
()
:
std
::
chrono
::
milliseconds
(
25
);
}
const
struct
AudioOutputPlugin
osx_output_plugin
=
{
...
...
src/output/plugins/OpenALOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -58,13 +58,13 @@ class OpenALOutput {
void
Close
();
gcc_pure
unsigned
Delay
()
const
{
std
::
chrono
::
steady_clock
::
duration
Delay
()
const
{
return
filled
<
NUM_BUFFERS
||
HasProcessed
()
?
0
?
std
::
chrono
::
steady_clock
::
duration
::
zero
()
/* we don't know exactly how long we must wait
for the next buffer to finish, so this is a
random guess: */
:
50
;
:
std
::
chrono
::
milliseconds
(
50
)
;
}
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
...
...
src/output/plugins/PulseOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -101,7 +101,7 @@ public:
void
Open
(
AudioFormat
&
audio_format
);
void
Close
();
unsigned
Delay
();
std
::
chrono
::
steady_clock
::
duration
Delay
();
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
void
Cancel
();
bool
Pause
();
...
...
@@ -740,16 +740,16 @@ PulseOutput::StreamPause(bool pause)
"pa_stream_cork() has failed"
);
}
inline
unsigned
inline
std
::
chrono
::
steady_clock
::
duration
PulseOutput
::
Delay
()
{
Pulse
::
LockGuard
lock
(
mainloop
);
unsigned
result
=
0
;
auto
result
=
std
::
chrono
::
steady_clock
::
duration
::
zero
()
;
if
(
base
.
pause
&&
pa_stream_is_corked
(
stream
)
&&
pa_stream_get_state
(
stream
)
==
PA_STREAM_READY
)
/* idle while paused */
result
=
1000
;
result
=
std
::
chrono
::
seconds
(
1
)
;
return
result
;
}
...
...
src/output/plugins/ShoutOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -63,7 +63,7 @@ struct ShoutOutput final {
void
Open
(
AudioFormat
&
audio_format
);
void
Close
();
unsigned
Delay
()
const
;
std
::
chrono
::
steady_clock
::
duration
Delay
()
const
;
void
SendTag
(
const
Tag
&
tag
);
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
void
Cancel
();
...
...
@@ -360,14 +360,14 @@ ShoutOutput::Open(AudioFormat &audio_format)
}
}
unsigned
std
::
chrono
::
steady_clock
::
duration
ShoutOutput
::
Delay
()
const
{
int
delay
=
shout_delay
(
shout_conn
);
if
(
delay
<
0
)
delay
=
0
;
return
delay
;
return
std
::
chrono
::
milliseconds
(
delay
)
;
}
size_t
...
...
src/output/plugins/SndioOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -51,7 +51,6 @@ public:
void
Open
(
AudioFormat
&
audio_format
);
void
Close
();
unsigned
Delay
()
const
;
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
void
Cancel
();
};
...
...
src/output/plugins/httpd/HttpdInternal.hxx
View file @
d5e42297
...
...
@@ -218,7 +218,7 @@ public:
void
SendHeader
(
HttpdClient
&
client
)
const
;
gcc_pure
unsigned
Delay
()
const
;
std
::
chrono
::
steady_clock
::
duration
Delay
()
const
;
/**
* Reads data from the encoder (as much as available) and
...
...
src/output/plugins/httpd/HttpdOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -344,7 +344,7 @@ HttpdOutput::SendHeader(HttpdClient &client) const
client
.
PushPage
(
header
);
}
inline
unsigned
inline
std
::
chrono
::
steady_clock
::
duration
HttpdOutput
::
Delay
()
const
{
if
(
!
LockHasClients
()
&&
base
.
pause
)
{
...
...
@@ -357,15 +357,15 @@ HttpdOutput::Delay() const
/* some arbitrary delay that is long enough to avoid
consuming too much CPU, and short enough to notice
new clients quickly enough */
return
1000
;
return
std
::
chrono
::
seconds
(
1
)
;
}
return
timer
->
IsStarted
()
?
timer
->
GetDelay
(
)
:
0
;
?
std
::
chrono
::
milliseconds
(
timer
->
GetDelay
()
)
:
std
::
chrono
::
steady_clock
::
duration
::
zero
()
;
}
static
unsigned
static
std
::
chrono
::
steady_clock
::
duration
httpd_output_delay
(
AudioOutput
*
ao
)
{
HttpdOutput
*
httpd
=
HttpdOutput
::
Cast
(
ao
);
...
...
src/output/plugins/sles/SlesOutputPlugin.cxx
View file @
d5e42297
...
...
@@ -96,8 +96,10 @@ public:
void
Open
(
AudioFormat
&
audio_format
);
void
Close
();
unsigned
Delay
()
{
return
pause
&&
!
cancel
?
100
:
0
;
std
::
chrono
::
steady_clock
::
duration
Delay
()
{
return
pause
&&
!
cancel
?
std
::
chrono
::
milliseconds
(
100
)
:
std
::
chrono
::
steady_clock
::
duration
::
zero
();
}
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
...
...
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