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
86372254
Commit
86372254
authored
Sep 22, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/CrossFade, ...: use lround()
parent
d3d1d377
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
10 deletions
+19
-10
Stats.cxx
src/Stats.cxx
+2
-1
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+4
-2
FaadDecoderPlugin.cxx
src/decoder/plugins/FaadDecoderPlugin.cxx
+4
-3
HaikuOutputPlugin.cxx
src/output/plugins/HaikuOutputPlugin.cxx
+3
-1
PcmMix.cxx
src/pcm/PcmMix.cxx
+3
-2
CrossFade.cxx
src/player/CrossFade.cxx
+3
-1
No files found.
src/Stats.cxx
View file @
86372254
...
...
@@ -31,6 +31,7 @@
#include "util/ChronoUtil.hxx"
#include <chrono>
#include <cmath>
#ifndef _WIN32
/**
...
...
@@ -120,7 +121,7 @@ stats_print(Response &r, const Partition &partition)
#else
(
unsigned
)
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
std
::
chrono
::
steady_clock
::
now
()
-
start_time
).
count
(),
#endif
(
unsigned
long
)(
partition
.
pc
.
GetTotalPlayTime
().
count
()
+
0.5
));
std
::
lround
(
partition
.
pc
.
GetTotalPlayTime
().
count
()
));
#ifdef ENABLE_DATABASE
const
Database
*
db
=
partition
.
instance
.
database
;
...
...
src/command/PlayerCommands.cxx
View file @
86372254
...
...
@@ -39,6 +39,8 @@
#include "db/update/Service.hxx"
#endif
#include <cmath>
#define COMMAND_STATUS_STATE "state"
#define COMMAND_STATUS_REPEAT "repeat"
#define COMMAND_STATUS_SINGLE "single"
...
...
@@ -151,8 +153,8 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
state
);
if
(
pc
.
GetCrossFade
()
>
0
)
r
.
Format
(
COMMAND_STATUS_CROSSFADE
": %
i
\n
"
,
int
(
pc
.
GetCrossFade
()
+
0.5
));
r
.
Format
(
COMMAND_STATUS_CROSSFADE
": %
lu
\n
"
,
std
::
lround
(
pc
.
GetCrossFade
()
));
if
(
pc
.
GetMixRampDelay
()
>
0
)
r
.
Format
(
COMMAND_STATUS_MIXRAMPDELAY
": %f
\n
"
,
...
...
src/decoder/plugins/FaadDecoderPlugin.cxx
View file @
86372254
...
...
@@ -31,6 +31,7 @@
#include <neaacdec.h>
#include <cmath>
#include <exception>
#include <assert.h>
...
...
@@ -386,9 +387,9 @@ faad_stream_decode(DecoderClient &client, InputStream &is,
/* update bit rate and position */
if
(
frame_info
.
samples
>
0
)
{
bit_rate
=
frame_info
.
bytesconsumed
*
8.0
*
frame_info
.
channels
*
audio_format
.
sample_rate
/
frame_info
.
samples
/
1000
+
0.5
;
bit_rate
=
lround
(
frame_info
.
bytesconsumed
*
8.0
*
frame_info
.
channels
*
audio_format
.
sample_rate
/
frame_info
.
samples
/
1000
)
;
}
/* send PCM samples to MPD */
...
...
src/output/plugins/HaikuOutputPlugin.cxx
View file @
86372254
...
...
@@ -38,6 +38,8 @@
#include <StringList.h>
#include <SoundPlayer.h>
#include <cmath>
#include <string.h>
#define UTF8_PLAY "\xE2\x96\xB6"
...
...
@@ -439,7 +441,7 @@ haiku_output_get_volume(HaikuOutput &haiku)
if
(
soundPlayer
==
NULL
||
soundPlayer
->
InitCheck
()
!=
B_OK
)
return
0
;
return
(
int
)(
soundPlayer
->
Volume
()
*
100
+
0.5
);
return
lround
(
soundPlayer
->
Volume
()
*
100
);
}
bool
...
...
src/pcm/PcmMix.cxx
View file @
86372254
...
...
@@ -26,8 +26,9 @@
#include "PcmDither.cxx" // including the .cxx file to get inlined templates
#include <cmath>
#include <assert.h>
#include <math.h>
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>>
static
typename
Traits
::
value_type
...
...
@@ -225,7 +226,7 @@ pcm_mix(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
s
=
sin
(
M_PI_2
*
portion1
);
s
*=
s
;
int
vol1
=
s
*
PCM_VOLUME_1S
+
0.5
;
int
vol1
=
s
td
::
lround
(
s
*
PCM_VOLUME_1S
)
;
vol1
=
Clamp
<
int
>
(
vol1
,
0
,
PCM_VOLUME_1S
);
return
pcm_add_vol
(
dither
,
buffer1
,
buffer2
,
size
,
...
...
src/player/CrossFade.cxx
View file @
86372254
...
...
@@ -26,6 +26,8 @@
#include "util/Domain.hxx"
#include "Log.hxx"
#include <cmath>
#include <assert.h>
static
constexpr
Domain
cross_fade_domain
(
"cross_fade"
);
...
...
@@ -108,7 +110,7 @@ CrossFadeSettings::Calculate(SignedSongTime total_time,
chunks_f
=
(
float
)
af
.
GetTimeToSize
()
/
(
float
)
sizeof
(
MusicChunk
::
data
);
if
(
mixramp_delay
<=
0
||
!
mixramp_start
||
!
mixramp_prev_end
)
{
chunks
=
(
chunks_f
*
duration
+
0.5
);
chunks
=
std
::
lround
(
chunks_f
*
duration
);
}
else
{
/* Calculate mixramp overlap. */
const
float
mixramp_overlap_current
=
...
...
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