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
dc05dd7c
Commit
dc05dd7c
authored
8 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/Multiple: make chunk_is_consumed_in() an AudioOutput method
parent
57dd344f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
30 deletions
+62
-30
Makefile.am
Makefile.am
+1
-0
Internal.cxx
src/output/Internal.cxx
+45
-0
Internal.hxx
src/output/Internal.hxx
+14
-0
MultipleOutputs.cxx
src/output/MultipleOutputs.cxx
+2
-30
No files found.
Makefile.am
View file @
dc05dd7c
...
...
@@ -1328,6 +1328,7 @@ OUTPUT_LIBS = \
OUTPUT_API_SRC
=
\
src/output/OutputAPI.hxx
\
src/output/Internal.cxx
\
src/output/Internal.hxx
\
src/output/Wrapper.hxx
\
src/output/Registry.cxx src/output/Registry.hxx
\
...
...
This diff is collapsed.
Click to expand it.
src/output/Internal.cxx
0 → 100644
View file @
dc05dd7c
/*
* Copyright 2003-2016 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "Internal.hxx"
#include "MusicPipe.hxx"
#include "MusicChunk.hxx"
#include <assert.h>
bool
AudioOutput
::
IsChunkConsumed
(
const
MusicChunk
&
chunk
)
const
{
if
(
!
open
)
return
true
;
if
(
current_chunk
==
nullptr
)
return
false
;
assert
(
&
chunk
==
current_chunk
||
pipe
->
Contains
(
current_chunk
));
if
(
&
chunk
!=
current_chunk
)
{
assert
(
chunk
.
next
!=
nullptr
);
return
true
;
}
return
current_chunk_finished
&&
chunk
.
next
==
nullptr
;
}
This diff is collapsed.
Click to expand it.
src/output/Internal.hxx
View file @
dc05dd7c
...
...
@@ -394,6 +394,20 @@ public:
*/
void
LockAllowPlay
();
/**
* Did we already consumed this chunk?
*
* Caller must lock the mutex.
*/
gcc_pure
bool
IsChunkConsumed
(
const
MusicChunk
&
chunk
)
const
;
gcc_pure
bool
LockIsChunkConsumed
(
const
MusicChunk
&
chunk
)
{
const
ScopeLock
protect
(
mutex
);
return
IsChunkConsumed
(
chunk
);
}
private
:
void
CommandFinished
();
...
...
This diff is collapsed.
Click to expand it.
src/output/MultipleOutputs.cxx
View file @
dc05dd7c
...
...
@@ -251,40 +251,12 @@ MultipleOutputs::Open(const AudioFormat audio_format,
}
}
/**
* Has the specified audio output already consumed this chunk?
*/
gcc_pure
static
bool
chunk_is_consumed_in
(
const
AudioOutput
*
ao
,
gcc_unused
const
MusicPipe
*
pipe
,
const
MusicChunk
*
chunk
)
{
if
(
!
ao
->
open
)
return
true
;
if
(
ao
->
current_chunk
==
nullptr
)
return
false
;
assert
(
chunk
==
ao
->
current_chunk
||
pipe
->
Contains
(
ao
->
current_chunk
));
if
(
chunk
!=
ao
->
current_chunk
)
{
assert
(
chunk
->
next
!=
nullptr
);
return
true
;
}
return
ao
->
current_chunk_finished
&&
chunk
->
next
==
nullptr
;
}
bool
MultipleOutputs
::
IsChunkConsumed
(
const
MusicChunk
*
chunk
)
const
{
for
(
auto
ao
:
outputs
)
{
const
ScopeLock
protect
(
ao
->
mutex
);
if
(
!
chunk_is_consumed_in
(
ao
,
pipe
,
chunk
))
for
(
auto
ao
:
outputs
)
if
(
!
ao
->
LockIsChunkConsumed
(
*
chunk
))
return
false
;
}
return
true
;
}
...
...
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