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
fd0f195b
Commit
fd0f195b
authored
Nov 02, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
music_pipe: renamed ob_* functions to music_pipe_*
Rename all functions to the new prefix.
parent
8964c69a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
55 deletions
+56
-55
decoder_api.c
src/decoder_api.c
+2
-2
decoder_thread.c
src/decoder_thread.c
+1
-1
main.c
src/main.c
+2
-2
pipe.c
src/pipe.c
+20
-20
pipe.h
src/pipe.h
+14
-14
player_thread.c
src/player_thread.c
+17
-16
No files found.
src/decoder_api.c
View file @
fd0f195b
...
...
@@ -66,7 +66,7 @@ void decoder_command_finished(mpd_unused struct decoder * decoder)
if
(
dc
.
command
==
DECODE_COMMAND_SEEK
)
/* delete frames from the old song position */
ob
_clear
();
music_pipe
_clear
();
dc
.
command
=
DECODE_COMMAND_NONE
;
notify_signal
(
&
pc
.
notify
);
...
...
@@ -181,7 +181,7 @@ decoder_data(struct decoder *decoder,
normalizeData
(
data
,
datalen
,
&
ob
.
audioFormat
);
while
(
datalen
>
0
)
{
nbytes
=
ob
_append
(
data
,
datalen
,
data_time
,
bitRate
);
nbytes
=
music_pipe
_append
(
data
,
datalen
,
data_time
,
bitRate
);
datalen
-=
nbytes
;
data
+=
nbytes
;
...
...
src/decoder_thread.c
View file @
fd0f195b
...
...
@@ -158,7 +158,7 @@ static void decodeStart(void)
}
}
ob
_flush
();
music_pipe
_flush
();
if
(
!
ret
)
{
dc
.
error
=
plugin
==
NULL
...
...
src/main.c
View file @
fd0f195b
...
...
@@ -424,7 +424,7 @@ int main(int argc, char *argv[])
command_init
();
initPlayerData
();
pc_init
(
buffered_before_play
);
ob
_init
(
buffered_chunks
,
&
pc
.
notify
);
music_pipe
_init
(
buffered_chunks
,
&
pc
.
notify
);
dc_init
();
initAudioConfig
();
initAudioDriver
();
...
...
@@ -488,7 +488,7 @@ int main(int argc, char *argv[])
pc_deinit
();
command_finish
();
decoder_plugin_deinit_all
();
ob
_free
();
music_pipe
_free
();
cleanUpPidFile
();
finishConf
();
...
...
src/pipe.c
View file @
fd0f195b
...
...
@@ -26,7 +26,7 @@
struct
music_pipe
ob
;
void
ob
_init
(
unsigned
int
size
,
struct
notify
*
notify
)
music_pipe
_init
(
unsigned
int
size
,
struct
notify
*
notify
)
{
assert
(
size
>
0
);
...
...
@@ -39,13 +39,13 @@ ob_init(unsigned int size, struct notify *notify)
ob
.
chunks
[
0
].
chunkSize
=
0
;
}
void
ob
_free
(
void
)
void
music_pipe
_free
(
void
)
{
assert
(
ob
.
chunks
!=
NULL
);
free
(
ob
.
chunks
);
}
void
ob
_clear
(
void
)
void
music_pipe
_clear
(
void
)
{
ob
.
end
=
ob
.
begin
;
ob
.
chunks
[
ob
.
end
].
chunkSize
=
0
;
...
...
@@ -66,7 +66,7 @@ static inline unsigned successor(unsigned i)
*/
static
void
output_buffer_expand
(
unsigned
i
)
{
int
was_empty
=
ob
.
notify
!=
NULL
&&
(
!
ob
.
lazy
||
ob
_is_empty
());
int
was_empty
=
ob
.
notify
!=
NULL
&&
(
!
ob
.
lazy
||
music_pipe
_is_empty
());
assert
(
i
==
(
ob
.
end
+
1
)
%
ob
.
size
);
assert
(
i
!=
ob
.
end
);
...
...
@@ -80,9 +80,9 @@ static void output_buffer_expand(unsigned i)
notify_signal
(
ob
.
notify
);
}
void
ob
_flush
(
void
)
void
music_pipe
_flush
(
void
)
{
struct
music_chunk
*
chunk
=
ob
_get_chunk
(
ob
.
end
);
struct
music_chunk
*
chunk
=
music_pipe
_get_chunk
(
ob
.
end
);
if
(
chunk
->
chunkSize
>
0
)
{
unsigned
int
next
=
successor
(
ob
.
end
);
...
...
@@ -96,12 +96,12 @@ void ob_flush(void)
}
}
void
ob
_set_lazy
(
bool
lazy
)
void
music_pipe
_set_lazy
(
bool
lazy
)
{
ob
.
lazy
=
lazy
;
}
void
ob
_shift
(
void
)
void
music_pipe
_shift
(
void
)
{
assert
(
ob
.
begin
!=
ob
.
end
);
assert
(
ob
.
begin
<
ob
.
size
);
...
...
@@ -109,7 +109,7 @@ void ob_shift(void)
ob
.
begin
=
successor
(
ob
.
begin
);
}
unsigned
int
ob
_relative
(
const
unsigned
i
)
unsigned
int
music_pipe
_relative
(
const
unsigned
i
)
{
if
(
i
>=
ob
.
begin
)
return
i
-
ob
.
begin
;
...
...
@@ -117,12 +117,12 @@ unsigned int ob_relative(const unsigned i)
return
i
+
ob
.
size
-
ob
.
begin
;
}
unsigned
ob
_available
(
void
)
unsigned
music_pipe
_available
(
void
)
{
return
ob
_relative
(
ob
.
end
);
return
music_pipe
_relative
(
ob
.
end
);
}
int
ob
_absolute
(
const
unsigned
relative
)
int
music_pipe
_absolute
(
const
unsigned
relative
)
{
unsigned
i
,
max
;
...
...
@@ -140,7 +140,7 @@ int ob_absolute(const unsigned relative)
}
struct
music_chunk
*
ob
_get_chunk
(
const
unsigned
i
)
music_pipe
_get_chunk
(
const
unsigned
i
)
{
assert
(
i
<
ob
.
size
);
...
...
@@ -160,7 +160,7 @@ tail_chunk(float data_time, uint16_t bitRate)
unsigned
int
next
;
struct
music_chunk
*
chunk
;
chunk
=
ob
_get_chunk
(
ob
.
end
);
chunk
=
music_pipe
_get_chunk
(
ob
.
end
);
assert
(
chunk
->
chunkSize
<=
sizeof
(
chunk
->
data
));
if
(
chunk
->
chunkSize
+
frame_size
>
sizeof
(
chunk
->
data
))
{
/* this chunk is full; allocate a new chunk */
...
...
@@ -170,7 +170,7 @@ tail_chunk(float data_time, uint16_t bitRate)
return
NULL
;
output_buffer_expand
(
next
);
chunk
=
ob
_get_chunk
(
next
);
chunk
=
music_pipe
_get_chunk
(
next
);
assert
(
chunk
->
chunkSize
==
0
);
}
...
...
@@ -185,8 +185,8 @@ tail_chunk(float data_time, uint16_t bitRate)
return
chunk
;
}
size_t
ob
_append
(
const
void
*
data0
,
size_t
datalen
,
float
data_time
,
uint16_t
bitRate
)
size_t
music_pipe
_append
(
const
void
*
data0
,
size_t
datalen
,
float
data_time
,
uint16_t
bitRate
)
{
const
unsigned
char
*
data
=
data0
;
const
size_t
frame_size
=
audio_format_frame_size
(
&
ob
.
audioFormat
);
...
...
@@ -217,14 +217,14 @@ size_t ob_append(const void *data0, size_t datalen,
}
if
(
chunk
!=
NULL
&&
chunk
->
chunkSize
==
sizeof
(
chunk
->
data
))
ob
_flush
();
music_pipe
_flush
();
return
ret
;
}
void
ob
_skip
(
unsigned
num
)
void
music_pipe
_skip
(
unsigned
num
)
{
int
i
=
ob
_absolute
(
num
);
int
i
=
music_pipe
_absolute
(
num
);
if
(
i
>=
0
)
ob
.
begin
=
i
;
}
src/pipe.h
View file @
fd0f195b
...
...
@@ -61,13 +61,13 @@ struct music_pipe {
extern
struct
music_pipe
ob
;
void
ob
_init
(
unsigned
int
size
,
struct
notify
*
notify
);
music_pipe
_init
(
unsigned
int
size
,
struct
notify
*
notify
);
void
ob
_free
(
void
);
void
music_pipe
_free
(
void
);
void
ob
_clear
(
void
);
void
music_pipe
_clear
(
void
);
void
ob
_flush
(
void
);
void
music_pipe
_flush
(
void
);
/**
* When a chunk is decoded, we wake up the player thread to tell him
...
...
@@ -75,42 +75,42 @@ void ob_flush(void);
* previously empty, i.e. when the player thread has really been
* waiting for us.
*/
void
ob
_set_lazy
(
bool
lazy
);
void
music_pipe
_set_lazy
(
bool
lazy
);
/** is the buffer empty? */
static
inline
bool
ob
_is_empty
(
void
)
static
inline
bool
music_pipe
_is_empty
(
void
)
{
return
ob
.
begin
==
ob
.
end
;
}
void
ob
_shift
(
void
);
void
music_pipe
_shift
(
void
);
/**
* what is the position of the specified chunk number, relative to
* the first chunk in use?
*/
unsigned
int
ob
_relative
(
const
unsigned
i
);
unsigned
int
music_pipe
_relative
(
const
unsigned
i
);
/** determine the number of decoded chunks */
unsigned
ob
_available
(
void
);
unsigned
music_pipe
_available
(
void
);
/**
* Get the absolute index of the nth used chunk after the first one.
* Returns -1 if there is no such chunk.
*/
int
ob
_absolute
(
const
unsigned
relative
);
int
music_pipe
_absolute
(
const
unsigned
relative
);
struct
music_chunk
*
ob
_get_chunk
(
const
unsigned
i
);
music_pipe
_get_chunk
(
const
unsigned
i
);
/**
* Append a data block to the buffer.
*
* @return the number of bytes actually written
*/
size_t
ob
_append
(
const
void
*
data
,
size_t
datalen
,
float
data_time
,
uint16_t
bitRate
);
size_t
music_pipe
_append
(
const
void
*
data
,
size_t
datalen
,
float
data_time
,
uint16_t
bitRate
);
void
ob
_skip
(
unsigned
num
);
void
music_pipe
_skip
(
unsigned
num
);
#endif
src/player_thread.c
View file @
fd0f195b
...
...
@@ -114,7 +114,7 @@ static bool decodeSeek(struct player *player)
if
(
decoder_current_song
()
!=
pc
.
next_song
)
{
dc_stop
(
&
pc
.
notify
);
player
->
next_song_chunk
=
-
1
;
ob
_clear
();
music_pipe
_clear
();
dc_start_async
(
pc
.
next_song
);
waitOnDecode
(
player
);
}
...
...
@@ -241,8 +241,8 @@ static void do_play(void)
struct
audio_format
play_audio_format
;
double
sizeToTime
=
0
.
0
;
ob
_clear
();
ob
_set_lazy
(
false
);
music_pipe
_clear
();
music_pipe
_set_lazy
(
false
);
dc_start
(
&
pc
.
notify
,
pc
.
next_song
);
if
(
waitOnDecode
(
&
player
)
<
0
)
{
...
...
@@ -265,7 +265,7 @@ static void do_play(void)
}
if
(
player
.
buffering
)
{
if
(
ob
_available
()
<
pc
.
buffered_before_play
&&
if
(
music_pipe
_available
()
<
pc
.
buffered_before_play
&&
!
decoder_is_idle
())
{
/* not enough decoded buffer space yet */
notify_wait
(
&
pc
.
notify
);
...
...
@@ -273,7 +273,7 @@ static void do_play(void)
}
else
{
/* buffering is complete */
player
.
buffering
=
false
;
ob
_set_lazy
(
true
);
music_pipe
_set_lazy
(
true
);
}
}
...
...
@@ -355,13 +355,14 @@ static void do_play(void)
if
(
player
.
paused
)
notify_wait
(
&
pc
.
notify
);
else
if
(
!
ob
_is_empty
()
&&
else
if
(
!
music_pipe
_is_empty
()
&&
(
int
)
ob
.
begin
!=
player
.
next_song_chunk
)
{
struct
music_chunk
*
beginChunk
=
ob_get_chunk
(
ob
.
begin
);
struct
music_chunk
*
beginChunk
=
music_pipe_get_chunk
(
ob
.
begin
);
unsigned
int
fadePosition
;
if
(
player
.
xfade
==
XFADE_ENABLED
&&
player
.
next_song_chunk
>=
0
&&
(
fadePosition
=
ob
_relative
(
player
.
next_song_chunk
))
(
fadePosition
=
music_pipe
_relative
(
player
.
next_song_chunk
))
<=
crossFadeChunks
)
{
/* perform cross fade */
if
(
nextChunk
<
0
)
{
...
...
@@ -372,11 +373,11 @@ static void do_play(void)
chunks in the old song */
crossFadeChunks
=
fadePosition
;
}
nextChunk
=
ob
_absolute
(
crossFadeChunks
);
nextChunk
=
music_pipe
_absolute
(
crossFadeChunks
);
if
(
nextChunk
>=
0
)
{
ob
_set_lazy
(
true
);
music_pipe
_set_lazy
(
true
);
cross_fade_apply
(
beginChunk
,
ob
_get_chunk
(
nextChunk
),
music_pipe
_get_chunk
(
nextChunk
),
&
(
ob
.
audioFormat
),
fadePosition
,
crossFadeChunks
);
...
...
@@ -391,7 +392,7 @@ static void do_play(void)
}
else
{
/* wait for the
decoder */
ob
_set_lazy
(
false
);
music_pipe
_set_lazy
(
false
);
notify_wait
(
&
pc
.
notify
);
continue
;
}
...
...
@@ -402,15 +403,15 @@ static void do_play(void)
if
(
playChunk
(
beginChunk
,
&
play_audio_format
,
sizeToTime
)
<
0
)
break
;
ob
_shift
();
music_pipe
_shift
();
/* this formula should prevent that the
decoder gets woken up with each chunk; it
is more efficient to make it decode a
larger block at a time */
if
(
ob
_available
()
<=
(
pc
.
buffered_before_play
+
ob
.
size
*
3
)
/
4
)
if
(
music_pipe
_available
()
<=
(
pc
.
buffered_before_play
+
ob
.
size
*
3
)
/
4
)
notify_signal
(
&
dc
.
notify
);
}
else
if
(
!
ob
_is_empty
()
&&
}
else
if
(
!
music_pipe
_is_empty
()
&&
(
int
)
ob
.
begin
==
player
.
next_song_chunk
)
{
/* at the beginning of a new song */
...
...
@@ -418,7 +419,7 @@ static void do_play(void)
/* the cross-fade is finished; skip
the section which was cross-faded
(and thus already played) */
ob
_skip
(
crossFadeChunks
);
music_pipe
_skip
(
crossFadeChunks
);
}
player
.
xfade
=
XFADE_UNKNOWN
;
...
...
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