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
25fa3cca
Commit
25fa3cca
authored
7 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MusicChunk, player/Thread: use std::unique_ptr<Tag>
parent
c6a95395
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
30 deletions
+21
-30
MusicChunk.cxx
src/MusicChunk.cxx
+2
-4
MusicChunk.hxx
src/MusicChunk.hxx
+6
-8
Bridge.cxx
src/decoder/Bridge.cxx
+1
-1
Source.cxx
src/output/Source.cxx
+1
-1
Thread.cxx
src/player/Thread.cxx
+6
-7
Tag.cxx
src/tag/Tag.cxx
+3
-7
Tag.hxx
src/tag/Tag.hxx
+2
-2
No files found.
src/MusicChunk.cxx
View file @
25fa3cca
...
@@ -24,10 +24,8 @@
...
@@ -24,10 +24,8 @@
#include <assert.h>
#include <assert.h>
MusicChunk
::~
MusicChunk
()
MusicChunk
::
MusicChunk
()
noexcept
=
default
;
{
MusicChunk
::~
MusicChunk
()
noexcept
=
default
;
delete
tag
;
}
#ifndef NDEBUG
#ifndef NDEBUG
bool
bool
...
...
This diff is collapsed.
Click to expand it.
src/MusicChunk.hxx
View file @
25fa3cca
...
@@ -28,6 +28,8 @@
...
@@ -28,6 +28,8 @@
#include "AudioFormat.hxx"
#include "AudioFormat.hxx"
#endif
#endif
#include <memory>
#include <stdint.h>
#include <stdint.h>
#include <stddef.h>
#include <stddef.h>
...
@@ -67,11 +69,9 @@ struct MusicChunk {
...
@@ -67,11 +69,9 @@ struct MusicChunk {
/**
/**
* An optional tag associated with this chunk (and the
* An optional tag associated with this chunk (and the
* following chunks); appears at song boundaries. The tag
* following chunks); appears at song boundaries.
* object is owned by this chunk, and must be freed when this
* chunk is deinitialized.
*/
*/
Tag
*
tag
=
nullptr
;
std
::
unique_ptr
<
Tag
>
tag
;
/**
/**
* Replay gain information associated with this chunk.
* Replay gain information associated with this chunk.
...
@@ -101,12 +101,10 @@ struct MusicChunk {
...
@@ -101,12 +101,10 @@ struct MusicChunk {
AudioFormat
audio_format
;
AudioFormat
audio_format
;
#endif
#endif
MusicChunk
()
=
default
;
MusicChunk
()
noexcept
;
~
MusicChunk
()
noexcept
;
MusicChunk
(
const
MusicChunk
&
)
=
delete
;
MusicChunk
(
const
MusicChunk
&
)
=
delete
;
~
MusicChunk
();
MusicChunk
&
operator
=
(
const
MusicChunk
&
)
=
delete
;
MusicChunk
&
operator
=
(
const
MusicChunk
&
)
=
delete
;
bool
IsEmpty
()
const
{
bool
IsEmpty
()
const
{
...
...
This diff is collapsed.
Click to expand it.
src/decoder/Bridge.cxx
View file @
25fa3cca
...
@@ -215,7 +215,7 @@ DecoderBridge::DoSendTag(const Tag &tag)
...
@@ -215,7 +215,7 @@ DecoderBridge::DoSendTag(const Tag &tag)
return
dc
.
command
;
return
dc
.
command
;
}
}
chunk
->
tag
=
new
Tag
(
tag
);
chunk
->
tag
=
std
::
make_unique
<
Tag
>
(
tag
);
return
DecoderCommand
::
NONE
;
return
DecoderCommand
::
NONE
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/output/Source.cxx
View file @
25fa3cca
...
@@ -222,7 +222,7 @@ AudioOutputSource::Fill(Mutex &mutex)
...
@@ -222,7 +222,7 @@ AudioOutputSource::Fill(Mutex &mutex)
if
(
current_chunk
==
nullptr
)
if
(
current_chunk
==
nullptr
)
return
false
;
return
false
;
pending_tag
=
current_chunk
->
tag
;
pending_tag
=
current_chunk
->
tag
.
get
()
;
try
{
try
{
/* release the mutex while the filter runs, because
/* release the mutex while the filter runs, because
...
...
This diff is collapsed.
Click to expand it.
src/player/Thread.cxx
View file @
25fa3cca
...
@@ -131,7 +131,7 @@ class Player {
...
@@ -131,7 +131,7 @@ class Player {
* postponed, and sent to the output thread when the new song
* postponed, and sent to the output thread when the new song
* really begins.
* really begins.
*/
*/
Tag
*
cross_fade_tag
=
nullptr
;
std
::
unique_ptr
<
Tag
>
cross_fade_tag
;
/**
/**
* The current audio format for the audio outputs.
* The current audio format for the audio outputs.
...
@@ -837,10 +837,8 @@ Player::PlayNextChunk() noexcept
...
@@ -837,10 +837,8 @@ Player::PlayNextChunk() noexcept
/* don't send the tags of the new song (which
/* don't send the tags of the new song (which
is being faded in) yet; postpone it until
is being faded in) yet; postpone it until
the current song is faded out */
the current song is faded out */
cross_fade_tag
=
cross_fade_tag
=
Tag
::
Merge
(
std
::
move
(
cross_fade_tag
),
Tag
::
MergeReplace
(
cross_fade_tag
,
std
::
move
(
other_chunk
->
tag
));
other_chunk
->
tag
);
other_chunk
->
tag
=
nullptr
;
if
(
pc
.
cross_fade
.
mixramp_delay
<=
0
)
{
if
(
pc
.
cross_fade
.
mixramp_delay
<=
0
)
{
chunk
->
mix_ratio
=
((
float
)
cross_fade_position
)
chunk
->
mix_ratio
=
((
float
)
cross_fade_position
)
...
@@ -889,7 +887,8 @@ Player::PlayNextChunk() noexcept
...
@@ -889,7 +887,8 @@ Player::PlayNextChunk() noexcept
/* insert the postponed tag if cross-fading is finished */
/* insert the postponed tag if cross-fading is finished */
if
(
xfade_state
!=
CrossFadeState
::
ACTIVE
&&
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
::
Merge
(
std
::
move
(
chunk
->
tag
),
std
::
move
(
cross_fade_tag
));
cross_fade_tag
=
nullptr
;
cross_fade_tag
=
nullptr
;
}
}
...
@@ -1114,7 +1113,7 @@ Player::Run() noexcept
...
@@ -1114,7 +1113,7 @@ Player::Run() noexcept
ClearAndDeletePipe
();
ClearAndDeletePipe
();
delete
cross_fade_tag
;
cross_fade_tag
.
reset
()
;
if
(
song
!=
nullptr
)
{
if
(
song
!=
nullptr
)
{
FormatDefault
(
player_domain
,
"played
\"
%s
\"
"
,
song
->
GetURI
());
FormatDefault
(
player_domain
,
"played
\"
%s
\"
"
,
song
->
GetURI
());
...
...
This diff is collapsed.
Click to expand it.
src/tag/Tag.cxx
View file @
25fa3cca
...
@@ -63,8 +63,8 @@ Tag::Merge(const Tag &base, const Tag &add) noexcept
...
@@ -63,8 +63,8 @@ Tag::Merge(const Tag &base, const Tag &add) noexcept
return
builder
.
CommitNew
();
return
builder
.
CommitNew
();
}
}
Tag
*
std
::
unique_ptr
<
Tag
>
Tag
::
Merge
Replace
(
Tag
*
base
,
Tag
*
add
)
Tag
::
Merge
(
std
::
unique_ptr
<
Tag
>
base
,
std
::
unique_ptr
<
Tag
>
add
)
{
{
if
(
add
==
nullptr
)
if
(
add
==
nullptr
)
return
base
;
return
base
;
...
@@ -72,11 +72,7 @@ Tag::MergeReplace(Tag *base, Tag *add)
...
@@ -72,11 +72,7 @@ Tag::MergeReplace(Tag *base, Tag *add)
if
(
base
==
nullptr
)
if
(
base
==
nullptr
)
return
add
;
return
add
;
Tag
*
tag
=
Merge
(
*
base
,
*
add
).
release
();
return
Merge
(
*
base
,
*
add
);
delete
base
;
delete
add
;
return
tag
;
}
}
const
char
*
const
char
*
...
...
This diff is collapsed.
Click to expand it.
src/tag/Tag.hxx
View file @
25fa3cca
...
@@ -126,8 +126,8 @@ struct Tag {
...
@@ -126,8 +126,8 @@ struct Tag {
*
*
* @return a newly allocated tag
* @return a newly allocated tag
*/
*/
gcc_malloc
gcc_returns_nonnull
static
std
::
unique_ptr
<
Tag
>
Merge
(
std
::
unique_ptr
<
Tag
>
base
,
static
Tag
*
MergeReplace
(
Tag
*
base
,
Tag
*
add
);
std
::
unique_ptr
<
Tag
>
add
);
/**
/**
* Returns the first value of the specified tag type, or
* Returns the first value of the specified tag type, or
...
...
This diff is collapsed.
Click to expand it.
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