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
862bbc21
Commit
862bbc21
authored
Nov 03, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player: no CamelCase
Renamed variables and internal functions. Most of the player_control.h API remains in CamelCase for now.
parent
cfaf85e3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
45 deletions
+45
-45
player_control.c
src/player_control.c
+10
-10
player_control.h
src/player_control.h
+7
-7
player_thread.c
src/player_thread.c
+28
-28
No files found.
src/player_control.c
View file @
862bbc21
...
...
@@ -34,8 +34,8 @@ void pc_init(unsigned int buffered_before_play)
pc
.
command
=
PLAYER_COMMAND_NONE
;
pc
.
error
=
PLAYER_ERROR_NOERROR
;
pc
.
state
=
PLAYER_STATE_STOP
;
pc
.
cross
Fade
=
0
;
pc
.
software
V
olume
=
1000
;
pc
.
cross
_fade_seconds
=
0
;
pc
.
software
_v
olume
=
1000
;
}
void
pc_deinit
(
void
)
...
...
@@ -112,17 +112,17 @@ void playerSetPause(int pause_flag)
int
getPlayerElapsedTime
(
void
)
{
return
(
int
)(
pc
.
elapsed
T
ime
+
0
.
5
);
return
(
int
)(
pc
.
elapsed
_t
ime
+
0
.
5
);
}
unsigned
long
getPlayerBitRate
(
void
)
{
return
pc
.
bit
R
ate
;
return
pc
.
bit
_r
ate
;
}
int
getPlayerTotalTime
(
void
)
{
return
(
int
)(
pc
.
total
T
ime
+
0
.
5
);
return
(
int
)(
pc
.
total
_t
ime
+
0
.
5
);
}
enum
player_state
getPlayerState
(
void
)
...
...
@@ -192,7 +192,7 @@ playerSeek(struct song *song, float seek_time)
pc
.
next_song
=
song
;
if
(
pc
.
error
==
PLAYER_ERROR_NOERROR
)
{
pc
.
seek
W
here
=
seek_time
;
pc
.
seek
_w
here
=
seek_time
;
player_command
(
PLAYER_COMMAND_SEEK
);
idle_add
(
IDLE_PLAYER
);
...
...
@@ -203,14 +203,14 @@ playerSeek(struct song *song, float seek_time)
float
getPlayerCrossFade
(
void
)
{
return
pc
.
cross
Fade
;
return
pc
.
cross
_fade_seconds
;
}
void
setPlayerCrossFade
(
float
crossFadeInSeconds
)
{
if
(
crossFadeInSeconds
<
0
)
crossFadeInSeconds
=
0
;
pc
.
cross
Fade
=
crossFadeInSeconds
;
pc
.
cross
_fade_seconds
=
crossFadeInSeconds
;
idle_add
(
IDLE_OPTIONS
);
}
...
...
@@ -218,12 +218,12 @@ void setPlayerCrossFade(float crossFadeInSeconds)
void
setPlayerSoftwareVolume
(
int
volume
)
{
volume
=
(
volume
>
1000
)
?
1000
:
(
volume
<
0
?
0
:
volume
);
pc
.
software
V
olume
=
volume
;
pc
.
software
_v
olume
=
volume
;
}
double
getPlayerTotalPlayTime
(
void
)
{
return
pc
.
total
PlayT
ime
;
return
pc
.
total
_play_t
ime
;
}
/* this actually creates a dupe of the current metadata */
...
...
src/player_control.h
View file @
862bbc21
...
...
@@ -64,16 +64,16 @@ struct player_control {
volatile
enum
player_command
command
;
volatile
enum
player_state
state
;
volatile
int8_t
error
;
volatile
uint16_t
bit
R
ate
;
volatile
uint16_t
bit
_r
ate
;
struct
audio_format
audio_format
;
volatile
float
total
T
ime
;
volatile
float
elapsed
T
ime
;
volatile
float
total
_t
ime
;
volatile
float
elapsed
_t
ime
;
struct
song
*
volatile
next_song
;
struct
song
*
errored_song
;
volatile
double
seek
W
here
;
volatile
float
cross
Fade
;
volatile
uint16_t
software
V
olume
;
volatile
double
total
PlayT
ime
;
volatile
double
seek
_w
here
;
volatile
float
cross
_fade_seconds
;
volatile
uint16_t
software
_v
olume
;
volatile
double
total
_play_t
ime
;
};
extern
struct
player_control
pc
;
...
...
src/player_thread.c
View file @
862bbc21
...
...
@@ -82,14 +82,14 @@ static void player_command_finished(void)
wakeup_main_task
();
}
static
void
quitDecode
(
void
)
static
void
player_stop_decoder
(
void
)
{
dc_stop
(
&
pc
.
notify
);
pc
.
state
=
PLAYER_STATE_STOP
;
wakeup_main_task
();
}
static
int
waitOnDecode
(
struct
player
*
player
)
static
int
player_wait_for_decoder
(
struct
player
*
player
)
{
dc_command_wait
(
&
pc
.
notify
);
...
...
@@ -100,9 +100,9 @@ static int waitOnDecode(struct player *player)
return
-
1
;
}
pc
.
total
T
ime
=
pc
.
next_song
->
tag
!=
NULL
pc
.
total
_t
ime
=
pc
.
next_song
->
tag
!=
NULL
?
pc
.
next_song
->
tag
->
time
:
0
;
pc
.
bit
R
ate
=
0
;
pc
.
bit
_r
ate
=
0
;
audio_format_clear
(
&
pc
.
audio_format
);
player
->
song
=
pc
.
next_song
;
...
...
@@ -113,7 +113,7 @@ static int waitOnDecode(struct player *player)
return
0
;
}
static
bool
decodeSeek
(
struct
player
*
player
)
static
bool
player_seek_decoder
(
struct
player
*
player
)
{
double
where
;
bool
ret
;
...
...
@@ -123,25 +123,25 @@ static bool decodeSeek(struct player *player)
player
->
next_song_chunk
=
-
1
;
music_pipe_clear
();
dc_start_async
(
pc
.
next_song
);
waitOnDecode
(
player
);
player_wait_for_decoder
(
player
);
}
where
=
pc
.
seek
W
here
;
if
(
where
>
pc
.
total
T
ime
)
where
=
pc
.
total
T
ime
-
0
.
1
;
where
=
pc
.
seek
_w
here
;
if
(
where
>
pc
.
total
_t
ime
)
where
=
pc
.
total
_t
ime
-
0
.
1
;
if
(
where
<
0
.
0
)
where
=
0
.
0
;
ret
=
dc_seek
(
&
pc
.
notify
,
where
);
if
(
ret
)
pc
.
elapsed
T
ime
=
where
;
pc
.
elapsed
_t
ime
=
where
;
player_command_finished
();
return
ret
;
}
static
void
p
rocessDecodeInput
(
struct
player
*
player
)
static
void
p
layer_process_command
(
struct
player
*
player
)
{
switch
(
pc
.
command
)
{
case
PLAYER_COMMAND_NONE
:
...
...
@@ -181,7 +181,7 @@ static void processDecodeInput(struct player *player)
case
PLAYER_COMMAND_SEEK
:
dropBufferedAudio
();
if
(
decodeSeek
(
player
))
{
if
(
player_seek_decoder
(
player
))
{
player
->
xfade
=
XFADE_UNKNOWN
;
/* abort buffering when the user has requested
...
...
@@ -214,11 +214,11 @@ static void processDecodeInput(struct player *player)
}
static
int
play
C
hunk
(
struct
song
*
song
,
struct
music_chunk
*
chunk
,
const
struct
audio_format
*
format
,
double
sizeToTime
)
play
_c
hunk
(
struct
song
*
song
,
struct
music_chunk
*
chunk
,
const
struct
audio_format
*
format
,
double
sizeToTime
)
{
pc
.
elapsed
T
ime
=
chunk
->
times
;
pc
.
bit
R
ate
=
chunk
->
bit_rate
;
pc
.
elapsed
_t
ime
=
chunk
->
times
;
pc
.
bit
_r
ate
=
chunk
->
bit_rate
;
if
(
chunk
->
tag
!=
NULL
)
{
sendMetadataToAudioDevice
(
chunk
->
tag
);
...
...
@@ -240,12 +240,12 @@ playChunk(struct song *song, struct music_chunk *chunk,
return
0
;
pcm_volume
(
chunk
->
data
,
chunk
->
length
,
format
,
pc
.
software
V
olume
);
format
,
pc
.
software
_v
olume
);
if
(
!
playAudio
(
chunk
->
data
,
chunk
->
length
))
return
-
1
;
pc
.
total
PlayT
ime
+=
sizeToTime
*
chunk
->
length
;
pc
.
total
_play_t
ime
+=
sizeToTime
*
chunk
->
length
;
return
0
;
}
...
...
@@ -272,18 +272,18 @@ static void do_play(void)
music_pipe_set_lazy
(
false
);
dc_start
(
&
pc
.
notify
,
pc
.
next_song
);
if
(
waitOnDecode
(
&
player
)
<
0
)
{
quitDecode
();
if
(
player_wait_for_decoder
(
&
player
)
<
0
)
{
player_stop_decoder
();
player_command_finished
();
return
;
}
pc
.
elapsed
T
ime
=
0
;
pc
.
elapsed
_t
ime
=
0
;
pc
.
state
=
PLAYER_STATE_PLAY
;
player_command_finished
();
while
(
1
)
{
p
rocessDecodeInput
(
&
player
);
p
layer_process_command
(
&
player
);
if
(
pc
.
command
==
PLAYER_COMMAND_STOP
||
pc
.
command
==
PLAYER_COMMAND_EXIT
||
pc
.
command
==
PLAYER_COMMAND_CLOSE_AUDIO
)
{
...
...
@@ -329,7 +329,7 @@ static void do_play(void)
if
(
player
.
paused
)
closeAudioDevice
();
pc
.
total
T
ime
=
dc
.
total_time
;
pc
.
total
_t
ime
=
dc
.
total_time
;
pc
.
audio_format
=
dc
.
in_audio_format
;
play_audio_format
=
dc
.
out_audio_format
;
sizeToTime
=
audioFormatSizeToTime
(
&
dc
.
out_audio_format
);
...
...
@@ -367,7 +367,7 @@ static void do_play(void)
calculate how many chunks will be required
for it */
crossFadeChunks
=
cross_fade_calc
(
pc
.
cross
Fade
,
dc
.
total_time
,
cross_fade_calc
(
pc
.
cross
_fade_seconds
,
dc
.
total_time
,
&
dc
.
out_audio_format
,
music_pipe_size
()
-
pc
.
buffered_before_play
);
...
...
@@ -426,8 +426,8 @@ static void do_play(void)
}
/* play the current chunk */
if
(
play
C
hunk
(
player
.
song
,
beginChunk
,
&
play_audio_format
,
sizeToTime
)
<
0
)
if
(
play
_c
hunk
(
player
.
song
,
beginChunk
,
&
play_audio_format
,
sizeToTime
)
<
0
)
break
;
music_pipe_shift
();
...
...
@@ -450,7 +450,7 @@ static void do_play(void)
player
.
xfade
=
XFADE_UNKNOWN
;
player
.
next_song_chunk
=
-
1
;
if
(
waitOnDecode
(
&
player
)
<
0
)
if
(
player_wait_for_decoder
(
&
player
)
<
0
)
return
;
wakeup_main_task
();
...
...
@@ -469,7 +469,7 @@ static void do_play(void)
}
}
quitDecode
();
player_stop_decoder
();
}
static
void
*
player_task
(
mpd_unused
void
*
arg
)
...
...
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