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
39bf84aa
Commit
39bf84aa
authored
Nov 02, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
music_pipe: renamed "size" to "num_chunks"
The name "num_chunks" expresses the meaning of the variable better.
parent
5347cca2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
pipe.c
src/pipe.c
+10
-10
pipe.h
src/pipe.h
+2
-3
No files found.
src/pipe.c
View file @
39bf84aa
...
@@ -32,7 +32,7 @@ music_pipe_init(unsigned int size, struct notify *notify)
...
@@ -32,7 +32,7 @@ music_pipe_init(unsigned int size, struct notify *notify)
assert
(
size
>
0
);
assert
(
size
>
0
);
music_pipe
.
chunks
=
g_new
(
struct
music_chunk
,
size
);
music_pipe
.
chunks
=
g_new
(
struct
music_chunk
,
size
);
music_pipe
.
size
=
size
;
music_pipe
.
num_chunks
=
size
;
music_pipe
.
begin
=
0
;
music_pipe
.
begin
=
0
;
music_pipe
.
end
=
0
;
music_pipe
.
end
=
0
;
music_pipe
.
lazy
=
false
;
music_pipe
.
lazy
=
false
;
...
@@ -55,10 +55,10 @@ void music_pipe_clear(void)
...
@@ -55,10 +55,10 @@ void music_pipe_clear(void)
/** return the index of the chunk after i */
/** return the index of the chunk after i */
static
inline
unsigned
successor
(
unsigned
i
)
static
inline
unsigned
successor
(
unsigned
i
)
{
{
assert
(
i
<=
music_pipe
.
size
);
assert
(
i
<=
music_pipe
.
num_chunks
);
++
i
;
++
i
;
return
i
==
music_pipe
.
size
?
0
:
i
;
return
i
==
music_pipe
.
num_chunks
?
0
:
i
;
}
}
/**
/**
...
@@ -69,7 +69,7 @@ static void output_buffer_expand(unsigned i)
...
@@ -69,7 +69,7 @@ static void output_buffer_expand(unsigned i)
{
{
int
was_empty
=
music_pipe
.
notify
!=
NULL
&&
(
!
music_pipe
.
lazy
||
music_pipe_is_empty
());
int
was_empty
=
music_pipe
.
notify
!=
NULL
&&
(
!
music_pipe
.
lazy
||
music_pipe_is_empty
());
assert
(
i
==
(
music_pipe
.
end
+
1
)
%
music_pipe
.
size
);
assert
(
i
==
(
music_pipe
.
end
+
1
)
%
music_pipe
.
num_chunks
);
assert
(
i
!=
music_pipe
.
end
);
assert
(
i
!=
music_pipe
.
end
);
music_pipe
.
end
=
i
;
music_pipe
.
end
=
i
;
...
@@ -105,7 +105,7 @@ void music_pipe_set_lazy(bool lazy)
...
@@ -105,7 +105,7 @@ void music_pipe_set_lazy(bool lazy)
void
music_pipe_shift
(
void
)
void
music_pipe_shift
(
void
)
{
{
assert
(
music_pipe
.
begin
!=
music_pipe
.
end
);
assert
(
music_pipe
.
begin
!=
music_pipe
.
end
);
assert
(
music_pipe
.
begin
<
music_pipe
.
size
);
assert
(
music_pipe
.
begin
<
music_pipe
.
num_chunks
);
music_pipe
.
begin
=
successor
(
music_pipe
.
begin
);
music_pipe
.
begin
=
successor
(
music_pipe
.
begin
);
}
}
...
@@ -115,7 +115,7 @@ unsigned int music_pipe_relative(const unsigned i)
...
@@ -115,7 +115,7 @@ unsigned int music_pipe_relative(const unsigned i)
if
(
i
>=
music_pipe
.
begin
)
if
(
i
>=
music_pipe
.
begin
)
return
i
-
music_pipe
.
begin
;
return
i
-
music_pipe
.
begin
;
else
else
return
i
+
music_pipe
.
size
-
music_pipe
.
begin
;
return
i
+
music_pipe
.
num_chunks
-
music_pipe
.
begin
;
}
}
unsigned
music_pipe_available
(
void
)
unsigned
music_pipe_available
(
void
)
...
@@ -129,13 +129,13 @@ int music_pipe_absolute(const unsigned relative)
...
@@ -129,13 +129,13 @@ int music_pipe_absolute(const unsigned relative)
max
=
music_pipe
.
end
;
max
=
music_pipe
.
end
;
if
(
max
<
music_pipe
.
begin
)
if
(
max
<
music_pipe
.
begin
)
max
+=
music_pipe
.
size
;
max
+=
music_pipe
.
num_chunks
;
i
=
(
unsigned
)
music_pipe
.
begin
+
relative
;
i
=
(
unsigned
)
music_pipe
.
begin
+
relative
;
if
(
i
>=
max
)
if
(
i
>=
max
)
return
-
1
;
return
-
1
;
if
(
i
>=
music_pipe
.
size
)
if
(
i
>=
music_pipe
.
num_chunks
)
i
-=
music_pipe
.
size
;
i
-=
music_pipe
.
num_chunks
;
return
(
int
)
i
;
return
(
int
)
i
;
}
}
...
@@ -143,7 +143,7 @@ int music_pipe_absolute(const unsigned relative)
...
@@ -143,7 +143,7 @@ int music_pipe_absolute(const unsigned relative)
struct
music_chunk
*
struct
music_chunk
*
music_pipe_get_chunk
(
const
unsigned
i
)
music_pipe_get_chunk
(
const
unsigned
i
)
{
{
assert
(
i
<
music_pipe
.
size
);
assert
(
i
<
music_pipe
.
num_chunks
);
return
&
music_pipe
.
chunks
[
i
];
return
&
music_pipe
.
chunks
[
i
];
}
}
...
...
src/pipe.h
View file @
39bf84aa
...
@@ -41,8 +41,7 @@ struct music_chunk {
...
@@ -41,8 +41,7 @@ struct music_chunk {
*/
*/
struct
music_pipe
{
struct
music_pipe
{
struct
music_chunk
*
chunks
;
struct
music_chunk
*
chunks
;
unsigned
num_chunks
;
unsigned
int
size
;
/** the index of the first decoded chunk */
/** the index of the first decoded chunk */
unsigned
int
volatile
begin
;
unsigned
int
volatile
begin
;
...
@@ -79,7 +78,7 @@ void music_pipe_set_lazy(bool lazy);
...
@@ -79,7 +78,7 @@ void music_pipe_set_lazy(bool lazy);
static
inline
unsigned
static
inline
unsigned
music_pipe_size
(
void
)
music_pipe_size
(
void
)
{
{
return
music_pipe
.
size
;
return
music_pipe
.
num_chunks
;
}
}
/** is the buffer empty? */
/** is the buffer empty? */
...
...
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