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
e29bc691
Commit
e29bc691
authored
Jan 08, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Queue: rename internal types
parent
ce57b8b6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
Queue.cxx
src/Queue.cxx
+13
-13
Queue.hxx
src/Queue.hxx
+6
-6
No files found.
src/Queue.cxx
View file @
e29bc691
...
...
@@ -26,16 +26,16 @@
queue
::
queue
(
unsigned
_max_length
)
:
max_length
(
_max_length
),
length
(
0
),
version
(
1
),
items
(
g_new
(
struct
queue_i
tem
,
max_length
)),
items
(
g_new
(
I
tem
,
max_length
)),
order
((
unsigned
*
)
g_malloc
(
sizeof
(
order
[
0
])
*
max_length
)),
id_to_position
((
int
*
)
g_malloc
(
sizeof
(
id_to_position
[
0
])
*
max_length
*
QUEUE_
HASH_MULT
)),
max_length
*
HASH_MULT
)),
repeat
(
false
),
single
(
false
),
consume
(
false
),
random
(
false
)
{
for
(
unsigned
i
=
0
;
i
<
max_length
*
QUEUE_
HASH_MULT
;
++
i
)
for
(
unsigned
i
=
0
;
i
<
max_length
*
HASH_MULT
;
++
i
)
id_to_position
[
i
]
=
-
1
;
}
...
...
@@ -59,7 +59,7 @@ queue::GenerateId() const
do
{
cur
++
;
if
(
cur
>=
max_length
*
QUEUE_
HASH_MULT
)
if
(
cur
>=
max_length
*
HASH_MULT
)
cur
=
0
;
}
while
(
id_to_position
[
cur
]
!=
-
1
);
...
...
@@ -157,7 +157,7 @@ queue::SwapPositions(unsigned position1, unsigned position2)
void
queue
::
MovePostion
(
unsigned
from
,
unsigned
to
)
{
struct
queue_item
item
=
items
[
from
];
const
Item
tmp
=
items
[
from
];
/* move songs to one less in from->to */
...
...
@@ -171,8 +171,8 @@ queue::MovePostion(unsigned from, unsigned to)
/* put song at _to_ */
id_to_position
[
item
.
id
]
=
to
;
items
[
to
]
=
item
;
id_to_position
[
tmp
.
id
]
=
to
;
items
[
to
]
=
tmp
;
items
[
to
].
version
=
version
;
/* now deal with order */
...
...
@@ -193,7 +193,7 @@ queue::MovePostion(unsigned from, unsigned to)
void
queue
::
MoveRange
(
unsigned
start
,
unsigned
end
,
unsigned
to
)
{
struct
queue_i
tem
tmp
[
end
-
start
];
I
tem
tmp
[
end
-
start
];
// Copy the original block [start,end-1]
for
(
unsigned
i
=
start
;
i
<
end
;
i
++
)
tmp
[
i
-
start
]
=
items
[
i
];
...
...
@@ -290,7 +290,7 @@ void
queue
::
Clear
()
{
for
(
unsigned
i
=
0
;
i
<
length
;
i
++
)
{
struct
queue_i
tem
*
item
=
&
items
[
i
];
I
tem
*
item
=
&
items
[
i
];
assert
(
!
song_in_database
(
item
->
song
)
||
song_is_detached
(
item
->
song
));
...
...
@@ -434,7 +434,7 @@ queue::FindPriorityOrder(unsigned start_order, uint8_t priority,
for
(
unsigned
i
=
start_order
;
i
<
length
;
++
i
)
{
const
unsigned
position
=
OrderToPosition
(
i
);
const
struct
queue_i
tem
*
item
=
&
items
[
position
];
const
I
tem
*
item
=
&
items
[
position
];
if
(
item
->
priority
<=
priority
&&
i
!=
exclude_order
)
return
i
;
}
...
...
@@ -450,7 +450,7 @@ queue::CountSamePriority(unsigned start_order, uint8_t priority) const
for
(
unsigned
i
=
start_order
;
i
<
length
;
++
i
)
{
const
unsigned
position
=
OrderToPosition
(
i
);
const
struct
queue_i
tem
*
item
=
&
items
[
position
];
const
I
tem
*
item
=
&
items
[
position
];
if
(
item
->
priority
!=
priority
)
return
i
-
start_order
;
}
...
...
@@ -463,7 +463,7 @@ queue::SetPriority(unsigned position, uint8_t priority, int after_order)
{
assert
(
position
<
length
);
struct
queue_i
tem
*
item
=
&
items
[
position
];
I
tem
*
item
=
&
items
[
position
];
uint8_t
old_priority
=
item
->
priority
;
if
(
old_priority
==
priority
)
return
false
;
...
...
@@ -488,7 +488,7 @@ queue::SetPriority(unsigned position, uint8_t priority, int after_order)
const
unsigned
after_position
=
OrderToPosition
(
after_order
);
const
struct
queue_i
tem
*
after_item
=
const
I
tem
*
after_item
=
&
items
[
after_position
];
if
(
old_priority
>
after_item
->
priority
||
priority
<=
after_item
->
priority
)
...
...
src/Queue.hxx
View file @
e29bc691
...
...
@@ -40,16 +40,16 @@
*/
struct
queue
{
/**
* reserve max_length *
QUEUE_
HASH_MULT elements in the id
* reserve max_length * HASH_MULT elements in the id
* number space
*/
static
constexpr
unsigned
QUEUE_
HASH_MULT
=
4
;
static
constexpr
unsigned
HASH_MULT
=
4
;
/**
* One element of the queue: basically a song plus some queue specific
* information attached.
*/
struct
queue_i
tem
{
struct
I
tem
{
struct
song
*
song
;
/** the unique id of this item in the queue */
...
...
@@ -76,7 +76,7 @@ struct queue {
uint32_t
version
;
/** all songs in "position" order */
struct
queue_i
tem
*
items
;
I
tem
*
items
;
/** map order numbers to positions */
unsigned
*
order
;
...
...
@@ -148,7 +148,7 @@ struct queue {
}
int
IdToPosition
(
unsigned
id
)
const
{
if
(
id
>=
max_length
*
QUEUE_
HASH_MULT
)
if
(
id
>=
max_length
*
HASH_MULT
)
return
-
1
;
assert
(
id_to_position
[
id
]
>=
-
1
);
...
...
@@ -190,7 +190,7 @@ struct queue {
return
items
[
position
].
priority
;
}
const
queue_i
tem
&
GetOrderItem
(
unsigned
i
)
const
{
const
I
tem
&
GetOrderItem
(
unsigned
i
)
const
{
assert
(
IsValidOrder
(
i
));
return
items
[
OrderToPosition
(
i
)];
...
...
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