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
90f4e977
Commit
90f4e977
authored
Sep 21, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/Client: use std::chrono::duration<double> instead of raw `double`
parent
d1bcd98f
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
21 additions
and
20 deletions
+21
-20
Bridge.cxx
src/decoder/Bridge.cxx
+8
-8
Bridge.hxx
src/decoder/Bridge.hxx
+2
-2
Client.hxx
src/decoder/Client.hxx
+1
-1
Mpg123DecoderPlugin.cxx
src/decoder/plugins/Mpg123DecoderPlugin.cxx
+2
-1
OpusDecoderPlugin.cxx
src/decoder/plugins/OpusDecoderPlugin.cxx
+1
-1
SidplayDecoderPlugin.cxx
src/decoder/plugins/SidplayDecoderPlugin.cxx
+1
-1
VorbisDecoderPlugin.cxx
src/decoder/plugins/VorbisDecoderPlugin.cxx
+1
-1
Time.hxx
src/lib/ffmpeg/Time.hxx
+3
-3
DumpDecoderClient.cxx
test/DumpDecoderClient.cxx
+1
-1
DumpDecoderClient.hxx
test/DumpDecoderClient.hxx
+1
-1
No files found.
src/decoder/Bridge.cxx
View file @
90f4e977
...
...
@@ -290,7 +290,7 @@ DecoderBridge::CommandFinished()
assert
(
dc
.
pipe
->
IsEmpty
());
initial_seek_running
=
false
;
timestamp
=
dc
.
start_time
.
ToDoubleS
(
);
timestamp
=
std
::
chrono
::
duration_cast
<
FloatDuration
>
(
dc
.
start_time
);
absolute_frame
=
dc
.
start_time
.
ToScale
<
uint64_t
>
(
dc
.
in_audio_format
.
sample_rate
);
return
;
}
...
...
@@ -307,7 +307,7 @@ DecoderBridge::CommandFinished()
if
(
convert
!=
nullptr
)
convert
->
Reset
();
timestamp
=
dc
.
seek_time
.
ToDoubleS
(
);
timestamp
=
std
::
chrono
::
duration_cast
<
FloatDuration
>
(
dc
.
seek_time
);
absolute_frame
=
dc
.
seek_time
.
ToScale
<
uint64_t
>
(
dc
.
in_audio_format
.
sample_rate
);
}
...
...
@@ -413,12 +413,12 @@ try {
}
void
DecoderBridge
::
SubmitTimestamp
(
double
t
)
DecoderBridge
::
SubmitTimestamp
(
FloatDuration
t
)
{
assert
(
t
>=
0
);
assert
(
t
.
count
()
>=
0
);
timestamp
=
t
;
absolute_frame
=
uint64_t
(
t
*
dc
.
in_audio_format
.
sample_rate
);
absolute_frame
=
uint64_t
(
t
.
count
()
*
dc
.
in_audio_format
.
sample_rate
);
}
DecoderCommand
...
...
@@ -506,7 +506,7 @@ DecoderBridge::SubmitData(InputStream *is,
const
auto
dest
=
chunk
->
Write
(
dc
.
out_audio_format
,
SongTime
::
FromS
(
timestamp
)
-
SongTime
::
Cast
(
timestamp
)
-
dc
.
song
->
GetStartTime
(),
kbit_rate
);
if
(
dest
.
empty
())
{
...
...
@@ -532,8 +532,8 @@ DecoderBridge::SubmitData(InputStream *is,
data
=
(
const
uint8_t
*
)
data
+
nbytes
;
length
-=
nbytes
;
timestamp
+=
(
double
)
nbytes
/
dc
.
out_audio_format
.
GetTimeToSize
(
);
timestamp
+=
FloatDuration
(
(
double
)
nbytes
/
dc
.
out_audio_format
.
GetTimeToSize
()
);
}
absolute_frame
+=
data_frames
;
...
...
src/decoder/Bridge.hxx
View file @
90f4e977
...
...
@@ -49,7 +49,7 @@ public:
/**
* The time stamp of the next data chunk, in seconds.
*/
double
timestamp
=
0
;
FloatDuration
timestamp
=
FloatDuration
::
zero
()
;
/**
* The time stamp of the next data chunk, in PCM frames.
...
...
@@ -148,7 +148,7 @@ public:
void
SeekError
()
override
;
InputStreamPtr
OpenUri
(
const
char
*
uri
)
override
;
size_t
Read
(
InputStream
&
is
,
void
*
buffer
,
size_t
length
)
override
;
void
SubmitTimestamp
(
double
t
)
override
;
void
SubmitTimestamp
(
FloatDuration
t
)
override
;
DecoderCommand
SubmitData
(
InputStream
*
is
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
)
override
;
...
...
src/decoder/Client.hxx
View file @
90f4e977
...
...
@@ -115,7 +115,7 @@ public:
* use this function if it thinks that adding to the time stamp based
* on the buffer size won't work.
*/
virtual
void
SubmitTimestamp
(
double
t
)
=
0
;
virtual
void
SubmitTimestamp
(
FloatDuration
t
)
=
0
;
/**
* This function is called by the decoder plugin when it has
...
...
src/decoder/plugins/Mpg123DecoderPlugin.cxx
View file @
90f4e977
...
...
@@ -264,7 +264,8 @@ mpd_mpg123_file_decode(DecoderClient &client, Path path_fs)
client
.
SeekError
();
else
{
client
.
CommandFinished
();
client
.
SubmitTimestamp
(
c
/
(
double
)
audio_format
.
sample_rate
);
client
.
SubmitTimestamp
(
FloatDuration
(
c
)
/
audio_format
.
sample_rate
);
}
cmd
=
DecoderCommand
::
NONE
;
...
...
src/decoder/plugins/OpusDecoderPlugin.cxx
View file @
90f4e977
...
...
@@ -243,7 +243,7 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
throw
cmd
;
if
(
packet
.
granulepos
>
0
)
client
.
SubmitTimestamp
(
double
(
packet
.
granulepos
)
client
.
SubmitTimestamp
(
FloatDuration
(
packet
.
granulepos
)
/
opus_sample_rate
);
}
}
...
...
src/decoder/plugins/SidplayDecoderPlugin.cxx
View file @
90f4e977
...
...
@@ -403,7 +403,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
const
size_t
nbytes
=
result
;
#endif
client
.
SubmitTimestamp
(
(
double
)
player
.
time
(
)
/
timebase
);
client
.
SubmitTimestamp
(
FloatDuration
(
player
.
time
()
)
/
timebase
);
cmd
=
client
.
SubmitData
(
nullptr
,
buffer
,
nbytes
,
0
);
...
...
src/decoder/plugins/VorbisDecoderPlugin.cxx
View file @
90f4e977
...
...
@@ -298,7 +298,7 @@ VorbisDecoder::OnOggPacket(const ogg_packet &_packet)
#ifndef HAVE_TREMOR
if
(
packet
.
granulepos
>
0
)
client
.
SubmitTimestamp
(
vorbis_granule_time
(
&
dsp
,
packet
.
granulepos
));
client
.
SubmitTimestamp
(
FloatDuration
(
vorbis_granule_time
(
&
dsp
,
packet
.
granulepos
)
));
#endif
}
}
...
...
src/lib/ffmpeg/Time.hxx
View file @
90f4e977
...
...
@@ -40,13 +40,13 @@ extern "C" {
* Convert a FFmpeg time stamp to a floating point value (in seconds).
*/
gcc_const
static
inline
double
static
inline
FloatDuration
FfmpegTimeToDouble
(
int64_t
t
,
const
AVRational
time_base
)
noexcept
{
assert
(
t
!=
(
int64_t
)
AV_NOPTS_VALUE
);
return
(
double
)
av_rescale_q
(
t
,
time_base
,
(
AVRational
){
1
,
1024
}
)
/
(
double
)
1024
;
return
FloatDuration
(
av_rescale_q
(
t
,
time_base
,
(
AVRational
){
1
,
1024
})
)
/
1024
;
}
/**
...
...
test/DumpDecoderClient.cxx
View file @
90f4e977
...
...
@@ -87,7 +87,7 @@ DumpDecoderClient::Read(InputStream &is, void *buffer, size_t length)
}
void
DumpDecoderClient
::
SubmitTimestamp
(
gcc_unused
double
t
)
DumpDecoderClient
::
SubmitTimestamp
(
gcc_unused
FloatDuration
t
)
{
}
...
...
test/DumpDecoderClient.hxx
View file @
90f4e977
...
...
@@ -50,7 +50,7 @@ public:
void
SeekError
()
override
;
InputStreamPtr
OpenUri
(
const
char
*
uri
)
override
;
size_t
Read
(
InputStream
&
is
,
void
*
buffer
,
size_t
length
)
override
;
void
SubmitTimestamp
(
double
t
)
override
;
void
SubmitTimestamp
(
FloatDuration
t
)
override
;
DecoderCommand
SubmitData
(
InputStream
*
is
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
)
override
;
...
...
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