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
e753c924
Commit
e753c924
authored
Oct 27, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/Thread: merge the cross_fading flag into enum CrossFadeState
parent
9dc7b5a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
22 deletions
+25
-22
Thread.cxx
src/player/Thread.cxx
+25
-22
No files found.
src/player/Thread.cxx
View file @
e753c924
...
@@ -111,12 +111,12 @@ class Player {
...
@@ -111,12 +111,12 @@ class Player {
* song.
* song.
*/
*/
ENABLED
,
ENABLED
,
}
xfade_state
;
/**
/**
* has cross-fading begun?
* Currently cross-fading to the next song.
*/
*/
bool
cross_fading
;
ACTIVE
,
}
xfade_state
;
/**
/**
* The number of chunks used for crossfading.
* The number of chunks used for crossfading.
...
@@ -156,7 +156,6 @@ public:
...
@@ -156,7 +156,6 @@ public:
output_open
(
false
),
output_open
(
false
),
song
(
nullptr
),
song
(
nullptr
),
xfade_state
(
CrossFadeState
::
UNKNOWN
),
xfade_state
(
CrossFadeState
::
UNKNOWN
),
cross_fading
(
false
),
cross_fade_chunks
(
0
),
cross_fade_chunks
(
0
),
cross_fade_tag
(
nullptr
),
cross_fade_tag
(
nullptr
),
elapsed_time
(
SongTime
::
zero
())
{}
elapsed_time
(
SongTime
::
zero
())
{}
...
@@ -784,22 +783,27 @@ Player::PlayNextChunk()
...
@@ -784,22 +783,27 @@ Player::PlayNextChunk()
another chunk */
another chunk */
return
true
;
return
true
;
unsigned
cross_fade_position
;
/* activate cross-fading? */
if
(
xfade_state
==
CrossFadeState
::
ENABLED
&&
IsDecoderAtNextSong
()
&&
pipe
->
GetSize
()
<=
cross_fade_chunks
)
{
/* beginning of the cross fade - adjust
cross_fade_chunks which might be bigger than the
remaining number of chunks in the old song */
cross_fade_chunks
=
pipe
->
GetSize
();
xfade_state
=
CrossFadeState
::
ACTIVE
;
}
MusicChunk
*
chunk
=
nullptr
;
MusicChunk
*
chunk
=
nullptr
;
if
(
xfade_state
==
CrossFadeState
::
ENABLED
&&
IsDecoderAtNextSong
()
&&
if
(
xfade_state
==
CrossFadeState
::
ACTIVE
)
{
(
cross_fade_position
=
pipe
->
GetSize
())
<=
cross_fade_chunks
)
{
/* perform cross fade */
/* perform cross fade */
MusicChunk
*
other_chunk
=
dc
.
pipe
->
Shift
();
if
(
!
cross_fading
)
{
assert
(
IsDecoderAtNextSong
());
/* beginning of the cross fade - adjust
crossFadeChunks which might be bigger than
unsigned
cross_fade_position
=
pipe
->
GetSize
();
the remaining number of chunks in the old
assert
(
cross_fade_position
<=
cross_fade_chunks
);
song */
cross_fade_chunks
=
cross_fade_position
;
cross_fading
=
true
;
}
MusicChunk
*
other_chunk
=
dc
.
pipe
->
Shift
();
if
(
other_chunk
!=
nullptr
)
{
if
(
other_chunk
!=
nullptr
)
{
chunk
=
pipe
->
Shift
();
chunk
=
pipe
->
Shift
();
assert
(
chunk
!=
nullptr
);
assert
(
chunk
!=
nullptr
);
...
@@ -862,7 +866,7 @@ Player::PlayNextChunk()
...
@@ -862,7 +866,7 @@ Player::PlayNextChunk()
/* insert the postponed tag if cross-fading is finished */
/* insert the postponed tag if cross-fading is finished */
if
(
xfade_state
!=
CrossFadeState
::
ENABLED
&&
cross_fade_tag
!=
nullptr
)
{
if
(
xfade_state
!=
CrossFadeState
::
ACTIVE
&&
cross_fade_tag
!=
nullptr
)
{
chunk
->
tag
=
Tag
::
MergeReplace
(
chunk
->
tag
,
cross_fade_tag
);
chunk
->
tag
=
Tag
::
MergeReplace
(
chunk
->
tag
,
cross_fade_tag
);
cross_fade_tag
=
nullptr
;
cross_fade_tag
=
nullptr
;
}
}
...
@@ -1042,10 +1046,9 @@ Player::Run()
...
@@ -1042,10 +1046,9 @@ Player::Run()
play_audio_format
,
play_audio_format
,
buffer
.
GetSize
()
-
buffer
.
GetSize
()
-
pc
.
buffered_before_play
);
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
;
else
}
else
/* cross fading is disabled or the
/* cross fading is disabled or the
next song is too short */
next song is too short */
xfade_state
=
CrossFadeState
::
DISABLED
;
xfade_state
=
CrossFadeState
::
DISABLED
;
...
...
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