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
e9e9d2bc
Commit
e9e9d2bc
authored
Nov 02, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
music_pipe: renamed "ob" to "music_pipe"
Last music_pipe rename patch: renamed the global variable (singleton).
parent
d430b1dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
49 deletions
+49
-49
pipe.c
src/pipe.c
+43
-43
pipe.h
src/pipe.h
+6
-6
No files found.
src/pipe.c
View file @
e9e9d2bc
...
...
@@ -24,41 +24,41 @@
#include <assert.h>
#include <string.h>
struct
music_pipe
ob
;
struct
music_pipe
music_pipe
;
void
music_pipe_init
(
unsigned
int
size
,
struct
notify
*
notify
)
{
assert
(
size
>
0
);
ob
.
chunks
=
g_new
(
struct
music_chunk
,
size
);
ob
.
size
=
size
;
ob
.
begin
=
0
;
ob
.
end
=
0
;
ob
.
lazy
=
false
;
ob
.
notify
=
notify
;
ob
.
chunks
[
0
].
chunkSize
=
0
;
music_pipe
.
chunks
=
g_new
(
struct
music_chunk
,
size
);
music_pipe
.
size
=
size
;
music_pipe
.
begin
=
0
;
music_pipe
.
end
=
0
;
music_pipe
.
lazy
=
false
;
music_pipe
.
notify
=
notify
;
music_pipe
.
chunks
[
0
].
chunkSize
=
0
;
}
void
music_pipe_free
(
void
)
{
assert
(
ob
.
chunks
!=
NULL
);
g_free
(
ob
.
chunks
);
assert
(
music_pipe
.
chunks
!=
NULL
);
g_free
(
music_pipe
.
chunks
);
}
void
music_pipe_clear
(
void
)
{
ob
.
end
=
ob
.
begin
;
ob
.
chunks
[
ob
.
end
].
chunkSize
=
0
;
music_pipe
.
end
=
music_pipe
.
begin
;
music_pipe
.
chunks
[
music_pipe
.
end
].
chunkSize
=
0
;
}
/** return the index of the chunk after i */
static
inline
unsigned
successor
(
unsigned
i
)
{
assert
(
i
<=
ob
.
size
);
assert
(
i
<=
music_pipe
.
size
);
++
i
;
return
i
==
ob
.
size
?
0
:
i
;
return
i
==
music_pipe
.
size
?
0
:
i
;
}
/**
...
...
@@ -67,27 +67,27 @@ static inline unsigned successor(unsigned i)
*/
static
void
output_buffer_expand
(
unsigned
i
)
{
int
was_empty
=
ob
.
notify
!=
NULL
&&
(
!
ob
.
lazy
||
music_pipe_is_empty
());
int
was_empty
=
music_pipe
.
notify
!=
NULL
&&
(
!
music_pipe
.
lazy
||
music_pipe_is_empty
());
assert
(
i
==
(
ob
.
end
+
1
)
%
ob
.
size
);
assert
(
i
!=
ob
.
end
);
assert
(
i
==
(
music_pipe
.
end
+
1
)
%
music_pipe
.
size
);
assert
(
i
!=
music_pipe
.
end
);
ob
.
end
=
i
;
ob
.
chunks
[
i
].
chunkSize
=
0
;
music_pipe
.
end
=
i
;
music_pipe
.
chunks
[
i
].
chunkSize
=
0
;
if
(
was_empty
)
/* if the buffer was empty, the player thread might be
waiting for us; wake it up now that another decoded
buffer has become available. */
notify_signal
(
ob
.
notify
);
notify_signal
(
music_pipe
.
notify
);
}
void
music_pipe_flush
(
void
)
{
struct
music_chunk
*
chunk
=
music_pipe_get_chunk
(
ob
.
end
);
struct
music_chunk
*
chunk
=
music_pipe_get_chunk
(
music_pipe
.
end
);
if
(
chunk
->
chunkSize
>
0
)
{
unsigned
int
next
=
successor
(
ob
.
end
);
if
(
next
==
ob
.
begin
)
unsigned
int
next
=
successor
(
music_pipe
.
end
);
if
(
next
==
music_pipe
.
begin
)
/* all buffers are full; we have to wait for
the player to free one, so don't flush
right now */
...
...
@@ -99,43 +99,43 @@ void music_pipe_flush(void)
void
music_pipe_set_lazy
(
bool
lazy
)
{
ob
.
lazy
=
lazy
;
music_pipe
.
lazy
=
lazy
;
}
void
music_pipe_shift
(
void
)
{
assert
(
ob
.
begin
!=
ob
.
end
);
assert
(
ob
.
begin
<
ob
.
size
);
assert
(
music_pipe
.
begin
!=
music_pipe
.
end
);
assert
(
music_pipe
.
begin
<
music_pipe
.
size
);
ob
.
begin
=
successor
(
ob
.
begin
);
music_pipe
.
begin
=
successor
(
music_pipe
.
begin
);
}
unsigned
int
music_pipe_relative
(
const
unsigned
i
)
{
if
(
i
>=
ob
.
begin
)
return
i
-
ob
.
begin
;
if
(
i
>=
music_pipe
.
begin
)
return
i
-
music_pipe
.
begin
;
else
return
i
+
ob
.
size
-
ob
.
begin
;
return
i
+
music_pipe
.
size
-
music_pipe
.
begin
;
}
unsigned
music_pipe_available
(
void
)
{
return
music_pipe_relative
(
ob
.
end
);
return
music_pipe_relative
(
music_pipe
.
end
);
}
int
music_pipe_absolute
(
const
unsigned
relative
)
{
unsigned
i
,
max
;
max
=
ob
.
end
;
if
(
max
<
ob
.
begin
)
max
+=
ob
.
size
;
i
=
(
unsigned
)
ob
.
begin
+
relative
;
max
=
music_pipe
.
end
;
if
(
max
<
music_pipe
.
begin
)
max
+=
music_pipe
.
size
;
i
=
(
unsigned
)
music_pipe
.
begin
+
relative
;
if
(
i
>=
max
)
return
-
1
;
if
(
i
>=
ob
.
size
)
i
-=
ob
.
size
;
if
(
i
>=
music_pipe
.
size
)
i
-=
music_pipe
.
size
;
return
(
int
)
i
;
}
...
...
@@ -143,9 +143,9 @@ int music_pipe_absolute(const unsigned relative)
struct
music_chunk
*
music_pipe_get_chunk
(
const
unsigned
i
)
{
assert
(
i
<
ob
.
size
);
assert
(
i
<
music_pipe
.
size
);
return
&
ob
.
chunks
[
i
];
return
&
music_pipe
.
chunks
[
i
];
}
/**
...
...
@@ -160,12 +160,12 @@ tail_chunk(float data_time, uint16_t bitRate, size_t frame_size)
unsigned
int
next
;
struct
music_chunk
*
chunk
;
chunk
=
music_pipe_get_chunk
(
ob
.
end
);
chunk
=
music_pipe_get_chunk
(
music_pipe
.
end
);
assert
(
chunk
->
chunkSize
<=
sizeof
(
chunk
->
data
));
if
(
chunk
->
chunkSize
+
frame_size
>
sizeof
(
chunk
->
data
))
{
/* this chunk is full; allocate a new chunk */
next
=
successor
(
ob
.
end
);
if
(
ob
.
begin
==
next
)
next
=
successor
(
music_pipe
.
end
);
if
(
music_pipe
.
begin
==
next
)
/* no chunks available */
return
NULL
;
...
...
@@ -227,5 +227,5 @@ void music_pipe_skip(unsigned num)
{
int
i
=
music_pipe_absolute
(
num
);
if
(
i
>=
0
)
ob
.
begin
=
i
;
music_pipe
.
begin
=
i
;
}
src/pipe.h
View file @
e9e9d2bc
...
...
@@ -57,7 +57,7 @@ struct music_pipe {
struct
notify
*
notify
;
};
extern
struct
music_pipe
ob
;
extern
struct
music_pipe
music_pipe
;
void
music_pipe_init
(
unsigned
int
size
,
struct
notify
*
notify
);
...
...
@@ -79,25 +79,25 @@ void music_pipe_set_lazy(bool lazy);
static
inline
unsigned
music_pipe_size
(
void
)
{
return
ob
.
size
;
return
music_pipe
.
size
;
}
/** is the buffer empty? */
static
inline
bool
music_pipe_is_empty
(
void
)
{
return
ob
.
begin
==
ob
.
end
;
return
music_pipe
.
begin
==
music_pipe
.
end
;
}
static
inline
bool
music_pipe_head_is
(
unsigned
i
)
{
return
!
music_pipe_is_empty
()
&&
ob
.
begin
==
i
;
return
!
music_pipe_is_empty
()
&&
music_pipe
.
begin
==
i
;
}
static
inline
unsigned
music_pipe_tail_index
(
void
)
{
return
ob
.
end
;
return
music_pipe
.
end
;
}
void
music_pipe_shift
(
void
);
...
...
@@ -126,7 +126,7 @@ music_pipe_peek(void)
if
(
music_pipe_is_empty
())
return
NULL
;
return
music_pipe_get_chunk
(
ob
.
begin
);
return
music_pipe_get_chunk
(
music_pipe
.
begin
);
}
/**
...
...
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