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
64b0ba6d
Commit
64b0ba6d
authored
Oct 05, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder_control: add attributes start_ms, end_ms
Don't read song.start_ms and song.end_ms, let the player thread manage this logic instead.
parent
99d4ae0c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
6 deletions
+31
-6
decoder_api.c
src/decoder_api.c
+4
-4
decoder_control.c
src/decoder_control.c
+3
-0
decoder_control.h
src/decoder_control.h
+20
-0
decoder_thread.c
src/decoder_thread.c
+1
-1
player_thread.c
src/player_thread.c
+3
-1
No files found.
src/decoder_api.c
View file @
64b0ba6d
...
...
@@ -132,7 +132,7 @@ decoder_command_finished(struct decoder *decoder)
assert
(
music_pipe_empty
(
dc
->
pipe
));
decoder
->
initial_seek_running
=
false
;
decoder
->
timestamp
=
dc
->
s
ong
->
s
tart_ms
/
1000
.;
decoder
->
timestamp
=
dc
->
start_ms
/
1000
.;
decoder_unlock
(
dc
);
return
;
}
...
...
@@ -165,7 +165,7 @@ double decoder_seek_where(G_GNUC_UNUSED struct decoder * decoder)
assert
(
dc
->
pipe
!=
NULL
);
if
(
decoder
->
initial_seek_running
)
return
dc
->
s
ong
->
s
tart_ms
/
1000
.;
return
dc
->
start_ms
/
1000
.;
assert
(
dc
->
command
==
DECODE_COMMAND_SEEK
);
...
...
@@ -407,8 +407,8 @@ decoder_data(struct decoder *decoder,
decoder
->
timestamp
+=
(
double
)
nbytes
/
audio_format_time_to_size
(
&
dc
->
out_audio_format
);
if
(
dc
->
song
->
end_ms
>
0
&&
decoder
->
timestamp
>=
dc
->
song
->
end_ms
/
1000
.
0
)
if
(
dc
->
end_ms
>
0
&&
decoder
->
timestamp
>=
dc
->
end_ms
/
1000
.
0
)
/* the end of this range has been reached:
stop decoding */
return
DECODE_COMMAND_STOP
;
...
...
src/decoder_control.c
View file @
64b0ba6d
...
...
@@ -102,6 +102,7 @@ dc_command_async(struct decoder_control *dc, enum decoder_command cmd)
void
dc_start
(
struct
decoder_control
*
dc
,
struct
song
*
song
,
unsigned
start_ms
,
unsigned
end_ms
,
struct
music_buffer
*
buffer
,
struct
music_pipe
*
pipe
)
{
assert
(
song
!=
NULL
);
...
...
@@ -110,6 +111,8 @@ dc_start(struct decoder_control *dc, struct song *song,
assert
(
music_pipe_empty
(
pipe
));
dc
->
song
=
song
;
dc
->
start_ms
=
start_ms
;
dc
->
end_ms
=
end_ms
;
dc
->
buffer
=
buffer
;
dc
->
pipe
=
pipe
;
dc_command
(
dc
,
DECODE_COMMAND_START
);
...
...
src/decoder_control.h
View file @
64b0ba6d
...
...
@@ -79,6 +79,23 @@ struct decoder_control {
*/
const
struct
song
*
song
;
/**
* The initial seek position (in milliseconds), e.g. to the
* start of a sub-track described by a CUE file.
*
* This attribute is set by dc_start().
*/
unsigned
start_ms
;
/**
* The decoder will stop when it reaches this position (in
* milliseconds). 0 means don't stop before the end of the
* file.
*
* This attribute is set by dc_start().
*/
unsigned
end_ms
;
float
total_time
;
/** the #music_chunk allocator */
...
...
@@ -225,11 +242,14 @@ dc_command_wait(struct decoder_control *dc);
*
* @param the decoder
* @param song the song to be decoded
* @param start_ms see #decoder_control
* @param end_ms see #decoder_control
* @param pipe the pipe which receives the decoded chunks (owned by
* the caller)
*/
void
dc_start
(
struct
decoder_control
*
dc
,
struct
song
*
song
,
unsigned
start_ms
,
unsigned
end_ms
,
struct
music_buffer
*
buffer
,
struct
music_pipe
*
pipe
);
void
...
...
src/decoder_thread.c
View file @
64b0ba6d
...
...
@@ -369,7 +369,7 @@ decoder_run_song(struct decoder_control *dc,
{
struct
decoder
decoder
=
{
.
dc
=
dc
,
.
initial_seek_pending
=
song
->
start_ms
>
0
,
.
initial_seek_pending
=
dc
->
start_ms
>
0
,
.
initial_seek_running
=
false
,
};
int
ret
;
...
...
src/player_thread.c
View file @
64b0ba6d
...
...
@@ -145,7 +145,9 @@ player_dc_start(struct player *player, struct music_pipe *pipe)
assert
(
player
->
queued
||
pc
.
command
==
PLAYER_COMMAND_SEEK
);
assert
(
pc
.
next_song
!=
NULL
);
dc_start
(
dc
,
pc
.
next_song
,
player_buffer
,
pipe
);
dc_start
(
dc
,
pc
.
next_song
,
pc
.
next_song
->
start_ms
,
pc
.
next_song
->
end_ms
,
player_buffer
,
pipe
);
}
/**
...
...
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