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
e5d1ac0b
Commit
e5d1ac0b
authored
Sep 21, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/Thread: move functions into PlayerControl
parent
c0411fa4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
23 deletions
+33
-23
Control.hxx
src/player/Control.hxx
+18
-0
Thread.cxx
src/player/Thread.cxx
+15
-23
No files found.
src/player/Control.hxx
View file @
e5d1ac0b
...
...
@@ -29,12 +29,14 @@
#include "Chrono.hxx"
#include "ReplayGainConfig.hxx"
#include "ReplayGainMode.hxx"
#include "MusicChunkPtr.hxx"
#include <exception>
#include <memory>
#include <stdint.h>
struct
Tag
;
class
PlayerListener
;
class
PlayerOutputs
;
class
DetachedSong
;
...
...
@@ -556,6 +558,22 @@ public:
return
total_play_time
;
}
void
LockUpdateSongTag
(
DetachedSong
&
song
,
const
Tag
&
new_tag
)
noexcept
;
/**
* Plays a #MusicChunk object (after applying software
* volume). If it contains a (stream) tag, copy it to the
* current song, so MPD's playlist reflects the new stream
* tag.
*
* Player lock is not held.
*
* Throws on error.
*/
void
PlayChunk
(
DetachedSong
&
song
,
MusicChunkPtr
chunk
,
const
AudioFormat
&
format
);
/* virtual methods from AudioOutputClient */
void
ChunksConsumed
()
override
{
LockSignal
();
...
...
src/player/Thread.cxx
View file @
e5d1ac0b
...
...
@@ -726,9 +726,9 @@ Player::ProcessCommand() noexcept
return
true
;
}
static
void
update_song_tag
(
PlayerControl
&
pc
,
DetachedSong
&
song
,
const
Tag
&
new_tag
)
noexcept
inline
void
PlayerControl
::
LockUpdateSongTag
(
DetachedSong
&
song
,
const
Tag
&
new_tag
)
noexcept
{
if
(
song
.
IsFile
())
/* don't update tags of local files, only remote
...
...
@@ -737,48 +737,40 @@ update_song_tag(PlayerControl &pc, DetachedSong &song,
song
.
SetTag
(
new_tag
);
pc
.
LockSetTaggedSong
(
song
);
LockSetTaggedSong
(
song
);
/* the main thread will update the playlist version when he
receives this event */
pc
.
listener
.
OnPlayerTagModified
();
listener
.
OnPlayerTagModified
();
/* notify all clients that the tag of the current song has
changed */
idle_add
(
IDLE_PLAYER
);
}
/**
* Plays a #MusicChunk object (after applying software volume). If
* it contains a (stream) tag, copy it to the current song, so MPD's
* playlist reflects the new stream tag.
*
* Player lock is not held.
*/
static
void
play_chunk
(
PlayerControl
&
pc
,
DetachedSong
&
song
,
MusicChunkPtr
chunk
,
const
AudioFormat
format
)
inline
void
PlayerControl
::
PlayChunk
(
DetachedSong
&
song
,
MusicChunkPtr
chunk
,
const
AudioFormat
&
format
)
{
assert
(
chunk
->
CheckFormat
(
format
));
if
(
chunk
->
tag
!=
nullptr
)
update_song_tag
(
pc
,
song
,
*
chunk
->
tag
);
LockUpdateSongTag
(
song
,
*
chunk
->
tag
);
if
(
chunk
->
IsEmpty
())
return
;
{
const
std
::
lock_guard
<
Mutex
>
lock
(
pc
.
mutex
);
pc
.
bit_rate
=
chunk
->
bit_rate
;
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
bit_rate
=
chunk
->
bit_rate
;
}
/* send the chunk to the audio outputs */
const
double
chunk_length
(
chunk
->
length
);
pc
.
outputs
.
Play
(
std
::
move
(
chunk
));
pc
.
total_play_time
+=
chunk_length
/
format
.
GetTimeToSize
();
outputs
.
Play
(
std
::
move
(
chunk
));
total_play_time
+=
chunk_length
/
format
.
GetTimeToSize
();
}
inline
bool
...
...
@@ -875,8 +867,8 @@ Player::PlayNextChunk() noexcept
/* play the current chunk */
try
{
p
lay_chunk
(
pc
,
*
song
,
std
::
move
(
chunk
),
play_audio_format
);
p
c
.
PlayChunk
(
*
song
,
std
::
move
(
chunk
),
play_audio_format
);
}
catch
(...)
{
LogError
(
std
::
current_exception
());
...
...
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