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
5347cca2
Commit
5347cca2
authored
Nov 02, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
music_pipe: no CamelCase
Rename all variables and struct members.
parent
8490c1b4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
29 deletions
+29
-29
crossfade.c
src/crossfade.c
+8
-8
pipe.c
src/pipe.c
+14
-14
pipe.h
src/pipe.h
+3
-3
player_thread.c
src/player_thread.c
+4
-4
No files found.
src/crossfade.c
View file @
5347cca2
...
...
@@ -58,9 +58,9 @@ void cross_fade_apply(struct music_chunk *a, const struct music_chunk *b,
assert
(
current_chunk
<=
num_chunks
);
size
=
b
->
chunkSize
>
a
->
chunkSize
?
a
->
chunkSize
:
b
->
chunkSize
;
size
=
b
->
length
>
a
->
length
?
a
->
length
:
b
->
length
;
pcm_mix
(
a
->
data
,
b
->
data
,
...
...
@@ -68,14 +68,14 @@ void cross_fade_apply(struct music_chunk *a, const struct music_chunk *b,
format
,
((
float
)
current_chunk
)
/
num_chunks
);
if
(
b
->
chunkSize
>
a
->
chunkSize
)
{
if
(
b
->
length
>
a
->
length
)
{
/* the second buffer is larger than the first one:
there is unmixed rest at the end. Copy it over.
The output buffer API guarantees that there is
enough room in a->data. */
memcpy
(
a
->
data
+
a
->
chunkSize
,
b
->
data
+
a
->
chunkSize
,
b
->
chunkSize
-
a
->
chunkSize
);
a
->
chunkSize
=
b
->
chunkSize
;
memcpy
(
a
->
data
+
a
->
length
,
b
->
data
+
a
->
length
,
b
->
length
-
a
->
length
);
a
->
length
=
b
->
length
;
}
}
src/pipe.c
View file @
5347cca2
...
...
@@ -37,7 +37,7 @@ music_pipe_init(unsigned int size, struct notify *notify)
music_pipe
.
end
=
0
;
music_pipe
.
lazy
=
false
;
music_pipe
.
notify
=
notify
;
music_pipe
.
chunks
[
0
].
chunkSize
=
0
;
music_pipe
.
chunks
[
0
].
length
=
0
;
}
void
music_pipe_free
(
void
)
...
...
@@ -49,7 +49,7 @@ void music_pipe_free(void)
void
music_pipe_clear
(
void
)
{
music_pipe
.
end
=
music_pipe
.
begin
;
music_pipe
.
chunks
[
music_pipe
.
end
].
chunkSize
=
0
;
music_pipe
.
chunks
[
music_pipe
.
end
].
length
=
0
;
}
/** return the index of the chunk after i */
...
...
@@ -73,7 +73,7 @@ static void output_buffer_expand(unsigned i)
assert
(
i
!=
music_pipe
.
end
);
music_pipe
.
end
=
i
;
music_pipe
.
chunks
[
i
].
chunkSize
=
0
;
music_pipe
.
chunks
[
i
].
length
=
0
;
if
(
was_empty
)
/* if the buffer was empty, the player thread might be
waiting for us; wake it up now that another decoded
...
...
@@ -85,7 +85,7 @@ void music_pipe_flush(void)
{
struct
music_chunk
*
chunk
=
music_pipe_get_chunk
(
music_pipe
.
end
);
if
(
chunk
->
chunkSize
>
0
)
{
if
(
chunk
->
length
>
0
)
{
unsigned
int
next
=
successor
(
music_pipe
.
end
);
if
(
next
==
music_pipe
.
begin
)
/* all buffers are full; we have to wait for
...
...
@@ -161,8 +161,8 @@ tail_chunk(size_t frame_size)
struct
music_chunk
*
chunk
;
chunk
=
music_pipe_get_chunk
(
music_pipe
.
end
);
assert
(
chunk
->
chunkSize
<=
sizeof
(
chunk
->
data
));
if
(
chunk
->
chunkSize
+
frame_size
>
sizeof
(
chunk
->
data
))
{
assert
(
chunk
->
length
<=
sizeof
(
chunk
->
data
));
if
(
chunk
->
length
+
frame_size
>
sizeof
(
chunk
->
data
))
{
/* this chunk is full; allocate a new chunk */
next
=
successor
(
music_pipe
.
end
);
if
(
music_pipe
.
begin
==
next
)
...
...
@@ -171,7 +171,7 @@ tail_chunk(size_t frame_size)
output_buffer_expand
(
next
);
chunk
=
music_pipe_get_chunk
(
next
);
assert
(
chunk
->
chunkSize
==
0
);
assert
(
chunk
->
length
==
0
);
}
return
chunk
;
...
...
@@ -181,7 +181,7 @@ static size_t
music_chunk_append
(
struct
music_chunk
*
chunk
,
const
void
*
data
,
size_t
length
,
size_t
frame_size
)
{
size_t
rest
=
sizeof
(
chunk
->
data
)
-
chunk
->
chunkSize
;
size_t
rest
=
sizeof
(
chunk
->
data
)
-
chunk
->
length
;
assert
(
rest
>=
frame_size
);
...
...
@@ -192,15 +192,15 @@ music_chunk_append(struct music_chunk *chunk, const void *data, size_t length,
length
/=
frame_size
;
length
*=
frame_size
;
memcpy
(
chunk
->
data
+
chunk
->
chunkSize
,
data
,
length
);
chunk
->
chunkSize
+=
length
;
memcpy
(
chunk
->
data
+
chunk
->
length
,
data
,
length
);
chunk
->
length
+=
length
;
return
length
;
}
size_t
music_pipe_append
(
const
void
*
data0
,
size_t
datalen
,
const
struct
audio_format
*
audio_format
,
float
data_time
,
uint16_t
bit
R
ate
)
float
data_time
,
uint16_t
bit
_r
ate
)
{
const
unsigned
char
*
data
=
data0
;
const
size_t
frame_size
=
audio_format_frame_size
(
audio_format
);
...
...
@@ -215,11 +215,11 @@ size_t music_pipe_append(const void *data0, size_t datalen,
if
(
chunk
==
NULL
)
return
ret
;
if
(
chunk
->
chunkSize
==
0
)
{
if
(
chunk
->
length
==
0
)
{
/* if the chunk is empty, nobody has set bitRate and
times yet */
chunk
->
bit
Rate
=
bitR
ate
;
chunk
->
bit
_rate
=
bit_r
ate
;
chunk
->
times
=
data_time
;
}
...
...
@@ -232,7 +232,7 @@ size_t music_pipe_append(const void *data0, size_t datalen,
ret
+=
nbytes
;
}
if
(
chunk
!=
NULL
&&
chunk
->
chunkSize
==
sizeof
(
chunk
->
data
))
if
(
chunk
!=
NULL
&&
chunk
->
length
==
sizeof
(
chunk
->
data
))
music_pipe_flush
();
return
ret
;
...
...
src/pipe.h
View file @
5347cca2
...
...
@@ -29,8 +29,8 @@
struct
audio_format
;
struct
music_chunk
{
uint16_t
chunkSize
;
uint16_t
bit
R
ate
;
uint16_t
length
;
uint16_t
bit
_r
ate
;
float
times
;
char
data
[
CHUNK_SIZE
];
};
...
...
@@ -136,7 +136,7 @@ music_pipe_peek(void)
*/
size_t
music_pipe_append
(
const
void
*
data
,
size_t
datalen
,
const
struct
audio_format
*
audio_format
,
float
data_time
,
uint16_t
bit
R
ate
);
float
data_time
,
uint16_t
bit
_r
ate
);
void
music_pipe_skip
(
unsigned
num
);
...
...
src/player_thread.c
View file @
5347cca2
...
...
@@ -211,15 +211,15 @@ playChunk(struct music_chunk *chunk, const struct audio_format *format,
double
sizeToTime
)
{
pc
.
elapsedTime
=
chunk
->
times
;
pc
.
bitRate
=
chunk
->
bit
R
ate
;
pc
.
bitRate
=
chunk
->
bit
_r
ate
;
pcm_volume
(
chunk
->
data
,
chunk
->
chunkSize
,
pcm_volume
(
chunk
->
data
,
chunk
->
length
,
format
,
pc
.
softwareVolume
);
if
(
!
playAudio
(
chunk
->
data
,
chunk
->
chunkSize
))
if
(
!
playAudio
(
chunk
->
data
,
chunk
->
length
))
return
-
1
;
pc
.
totalPlayTime
+=
sizeToTime
*
chunk
->
chunkSize
;
pc
.
totalPlayTime
+=
sizeToTime
*
chunk
->
length
;
return
0
;
}
...
...
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