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
03747ba9
Commit
03747ba9
authored
Oct 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlayerControl: move attributes to struct CrossFadeSettings
parent
095c390d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
63 deletions
+73
-63
CrossFade.cxx
src/CrossFade.cxx
+6
-7
CrossFade.hxx
src/CrossFade.hxx
+47
-26
PlayerControl.cxx
src/PlayerControl.cxx
+3
-12
PlayerControl.hxx
src/PlayerControl.hxx
+7
-6
PlayerThread.cxx
src/PlayerThread.cxx
+10
-12
No files found.
src/CrossFade.cxx
View file @
03747ba9
...
@@ -87,13 +87,12 @@ mixramp_interpolate(const char *ramp_list, float required_db)
...
@@ -87,13 +87,12 @@ mixramp_interpolate(const char *ramp_list, float required_db)
}
}
unsigned
unsigned
cross_fade_calc
(
float
duration
,
float
total_time
,
CrossFadeSettings
::
Calculate
(
float
total_time
,
float
mixramp_db
,
float
mixramp_delay
,
float
replay_gain_db
,
float
replay_gain_prev_db
,
float
replay_gain_db
,
float
replay_gain_prev_db
,
const
char
*
mixramp_start
,
const
char
*
mixramp_prev_end
,
const
char
*
mixramp_start
,
const
char
*
mixramp_prev_end
,
const
AudioFormat
af
,
const
AudioFormat
af
,
const
AudioFormat
old_format
,
const
AudioFormat
old_format
,
unsigned
max_chunks
)
const
unsigned
max_chunks
)
{
{
unsigned
int
chunks
=
0
;
unsigned
int
chunks
=
0
;
float
chunks_f
;
float
chunks_f
;
...
...
src/CrossFade.hxx
View file @
03747ba9
...
@@ -22,33 +22,54 @@
...
@@ -22,33 +22,54 @@
#include "Compiler.h"
#include "Compiler.h"
#include <cmath>
struct
AudioFormat
;
struct
AudioFormat
;
struct
music_chunk
;
/**
struct
CrossFadeSettings
{
* Calculate how many music pipe chunks should be used for crossfading.
/**
*
* The configured cross fade duration [s].
* @param duration the requested crossfade duration
*/
* @param total_time total_time the duration of the new song
float
duration
;
* @param mixramp_db the current mixramp_db setting
* @param mixramp_delay the current mixramp_delay setting
float
mixramp_db
;
* @param replay_gain_db the ReplayGain adjustment used for this song
* @param replay_gain_prev_db the ReplayGain adjustment used on the last song
/**
* @param mixramp_start the next songs mixramp_start tag
* The configured MixRapm delay [s].
* @param mixramp_prev_end the last songs mixramp_end setting
*/
* @param af the audio format of the new song
float
mixramp_delay
;
* @param old_format the audio format of the current song
* @param max_chunks the maximum number of chunks
CrossFadeSettings
()
* @return the number of chunks for crossfading, or 0 if cross fading
:
duration
(
0
),
* should be disabled for this song change
mixramp_db
(
0
),
*/
mixramp_delay
(
std
::
nanf
(
""
))
gcc_pure
{}
unsigned
cross_fade_calc
(
float
duration
,
float
total_time
,
float
mixramp_db
,
float
mixramp_delay
,
/**
float
replay_gain_db
,
float
replay_gain_prev_db
,
* Calculate how many music pipe chunks should be used for crossfading.
const
char
*
mixramp_start
,
const
char
*
mixramp_prev_end
,
*
AudioFormat
af
,
AudioFormat
old_format
,
* @param duration the requested crossfade duration
unsigned
max_chunks
);
* @param total_time total_time the duration of the new song
* @param mixramp_db the current mixramp_db setting
* @param mixramp_delay the current mixramp_delay setting
* @param replay_gain_db the ReplayGain adjustment used for this song
* @param replay_gain_prev_db the ReplayGain adjustment used on the last song
* @param mixramp_start the next songs mixramp_start tag
* @param mixramp_prev_end the last songs mixramp_end setting
* @param af the audio format of the new song
* @param old_format the audio format of the current song
* @param max_chunks the maximum number of chunks
* @return the number of chunks for crossfading, or 0 if cross fading
* should be disabled for this song change
*/
gcc_pure
unsigned
Calculate
(
float
total_time
,
float
replay_gain_db
,
float
replay_gain_prev_db
,
const
char
*
mixramp_start
,
const
char
*
mixramp_prev_end
,
AudioFormat
af
,
AudioFormat
old_format
,
unsigned
max_chunks
)
const
;
};
#endif
#endif
src/PlayerControl.cxx
View file @
03747ba9
...
@@ -36,15 +36,6 @@ PlayerControl::PlayerControl(unsigned _buffer_chunks,
...
@@ -36,15 +36,6 @@ PlayerControl::PlayerControl(unsigned _buffer_chunks,
error_type
(
PlayerError
::
NONE
),
error_type
(
PlayerError
::
NONE
),
tagged_song
(
nullptr
),
tagged_song
(
nullptr
),
next_song
(
nullptr
),
next_song
(
nullptr
),
cross_fade_seconds
(
0
),
mixramp_db
(
0
),
#if defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_C99_MATH_TR1)
/* workaround: on MacPorts, this option is disabled on gcc47,
and therefore std::nanf() is not available */
mixramp_delay_seconds
(
nanf
(
""
)),
#else
mixramp_delay_seconds
(
std
::
nanf
(
""
)),
#endif
total_play_time
(
0
),
total_play_time
(
0
),
border_pause
(
false
)
border_pause
(
false
)
{
{
...
@@ -260,7 +251,7 @@ PlayerControl::SetCrossFade(float _cross_fade_seconds)
...
@@ -260,7 +251,7 @@ PlayerControl::SetCrossFade(float _cross_fade_seconds)
{
{
if
(
_cross_fade_seconds
<
0
)
if
(
_cross_fade_seconds
<
0
)
_cross_fade_seconds
=
0
;
_cross_fade_seconds
=
0
;
cross_fade
_seconds
=
_cross_fade_seconds
;
cross_fade
.
duration
=
_cross_fade_seconds
;
idle_add
(
IDLE_OPTIONS
);
idle_add
(
IDLE_OPTIONS
);
}
}
...
@@ -268,7 +259,7 @@ PlayerControl::SetCrossFade(float _cross_fade_seconds)
...
@@ -268,7 +259,7 @@ PlayerControl::SetCrossFade(float _cross_fade_seconds)
void
void
PlayerControl
::
SetMixRampDb
(
float
_mixramp_db
)
PlayerControl
::
SetMixRampDb
(
float
_mixramp_db
)
{
{
mixramp_db
=
_mixramp_db
;
cross_fade
.
mixramp_db
=
_mixramp_db
;
idle_add
(
IDLE_OPTIONS
);
idle_add
(
IDLE_OPTIONS
);
}
}
...
@@ -276,7 +267,7 @@ PlayerControl::SetMixRampDb(float _mixramp_db)
...
@@ -276,7 +267,7 @@ PlayerControl::SetMixRampDb(float _mixramp_db)
void
void
PlayerControl
::
SetMixRampDelay
(
float
_mixramp_delay_seconds
)
PlayerControl
::
SetMixRampDelay
(
float
_mixramp_delay_seconds
)
{
{
mixramp_delay_seconds
=
_mixramp_delay_seconds
;
cross_fade
.
mixramp_delay
=
_mixramp_delay_seconds
;
idle_add
(
IDLE_OPTIONS
);
idle_add
(
IDLE_OPTIONS
);
}
}
src/PlayerControl.hxx
View file @
03747ba9
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "thread/Cond.hxx"
#include "thread/Cond.hxx"
#include "thread/Thread.hxx"
#include "thread/Thread.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "CrossFade.hxx"
#include <stdint.h>
#include <stdint.h>
...
@@ -155,9 +156,9 @@ struct PlayerControl {
...
@@ -155,9 +156,9 @@ struct PlayerControl {
Song
*
next_song
;
Song
*
next_song
;
double
seek_where
;
double
seek_where
;
float
cross_fade_seconds
;
float
mixramp_db
;
CrossFadeSettings
cross_fade
;
float
mixramp_delay_seconds
;
double
total_play_time
;
double
total_play_time
;
/**
/**
...
@@ -430,19 +431,19 @@ public:
...
@@ -430,19 +431,19 @@ public:
void
SetCrossFade
(
float
cross_fade_seconds
);
void
SetCrossFade
(
float
cross_fade_seconds
);
float
GetCrossFade
()
const
{
float
GetCrossFade
()
const
{
return
cross_fade
_seconds
;
return
cross_fade
.
duration
;
}
}
void
SetMixRampDb
(
float
mixramp_db
);
void
SetMixRampDb
(
float
mixramp_db
);
float
GetMixRampDb
()
const
{
float
GetMixRampDb
()
const
{
return
mixramp_db
;
return
cross_fade
.
mixramp_db
;
}
}
void
SetMixRampDelay
(
float
mixramp_delay_seconds
);
void
SetMixRampDelay
(
float
mixramp_delay_seconds
);
float
GetMixRampDelay
()
const
{
float
GetMixRampDelay
()
const
{
return
mixramp_delay_seconds
;
return
cross_fade
.
mixramp_delay
;
}
}
double
GetTotalPlayTime
()
const
{
double
GetTotalPlayTime
()
const
{
...
...
src/PlayerThread.cxx
View file @
03747ba9
...
@@ -779,7 +779,7 @@ Player::PlayNextChunk()
...
@@ -779,7 +779,7 @@ Player::PlayNextChunk()
other_chunk
->
tag
);
other_chunk
->
tag
);
other_chunk
->
tag
=
nullptr
;
other_chunk
->
tag
=
nullptr
;
if
(
std
::
isnan
(
pc
.
mixramp_delay_seconds
))
{
if
(
std
::
isnan
(
pc
.
cross_fade
.
mixramp_delay
))
{
chunk
->
mix_ratio
=
((
float
)
cross_fade_position
)
chunk
->
mix_ratio
=
((
float
)
cross_fade_position
)
/
cross_fade_chunks
;
/
cross_fade_chunks
;
}
else
{
}
else
{
...
@@ -999,17 +999,15 @@ Player::Run()
...
@@ -999,17 +999,15 @@ Player::Run()
calculate how many chunks will be required
calculate how many chunks will be required
for it */
for it */
cross_fade_chunks
=
cross_fade_chunks
=
cross_fade_calc
(
pc
.
cross_fade_seconds
,
dc
.
total_time
,
pc
.
cross_fade
.
Calculate
(
dc
.
total_time
,
pc
.
mixramp_db
,
dc
.
replay_gain_db
,
pc
.
mixramp_delay_seconds
,
dc
.
replay_gain_prev_db
,
dc
.
replay_gain_db
,
dc
.
GetMixRampStart
(),
dc
.
replay_gain_prev_db
,
dc
.
GetMixRampPreviousEnd
(),
dc
.
GetMixRampStart
(),
dc
.
out_audio_format
,
dc
.
GetMixRampPreviousEnd
(),
play_audio_format
,
dc
.
out_audio_format
,
buffer
.
GetSize
()
-
play_audio_format
,
pc
.
buffered_before_play
);
buffer
.
GetSize
()
-
pc
.
buffered_before_play
);
if
(
cross_fade_chunks
>
0
)
{
if
(
cross_fade_chunks
>
0
)
{
xfade_state
=
CrossFadeState
::
ENABLED
;
xfade_state
=
CrossFadeState
::
ENABLED
;
cross_fading
=
false
;
cross_fading
=
false
;
...
...
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