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
28442cce
Commit
28442cce
authored
Oct 13, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue: no CamelCase
Renamed idToPosition.
parent
f122e6d4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
+17
-17
queue.c
src/queue.c
+12
-12
queue.h
src/queue.h
+5
-5
No files found.
src/queue.c
View file @
28442cce
...
...
@@ -33,7 +33,7 @@ queue_generate_id(const struct queue *queue)
if
(
cur
>=
queue
->
max_length
*
QUEUE_HASH_MULT
)
cur
=
0
;
}
while
(
queue
->
id
ToP
osition
[
cur
]
!=
-
1
);
}
while
(
queue
->
id
_to_p
osition
[
cur
]
!=
-
1
);
return
cur
;
}
...
...
@@ -111,7 +111,7 @@ queue_append(struct queue *queue, struct song *song)
};
queue
->
order
[
queue
->
length
]
=
queue
->
length
;
queue
->
id
ToP
osition
[
id
]
=
queue
->
length
;
queue
->
id
_to_p
osition
[
id
]
=
queue
->
length
;
++
queue
->
length
;
...
...
@@ -132,8 +132,8 @@ queue_swap(struct queue *queue, unsigned position1, unsigned position2)
queue
->
items
[
position1
].
version
=
queue
->
version
;
queue
->
items
[
position2
].
version
=
queue
->
version
;
queue
->
id
ToP
osition
[
id1
]
=
position2
;
queue
->
id
ToP
osition
[
id2
]
=
position1
;
queue
->
id
_to_p
osition
[
id1
]
=
position2
;
queue
->
id
_to_p
osition
[
id2
]
=
position1
;
}
static
void
...
...
@@ -143,7 +143,7 @@ queue_move_song_to(struct queue *queue, unsigned from, unsigned to)
queue
->
items
[
to
]
=
queue
->
items
[
from
];
queue
->
items
[
to
].
version
=
queue
->
version
;
queue
->
id
ToP
osition
[
from_id
]
=
to
;
queue
->
id
_to_p
osition
[
from_id
]
=
to
;
}
void
...
...
@@ -163,7 +163,7 @@ queue_move(struct queue *queue, unsigned from, unsigned to)
/* put song at _to_ */
queue
->
id
ToP
osition
[
item
.
id
]
=
to
;
queue
->
id
_to_p
osition
[
item
.
id
]
=
to
;
queue
->
items
[
to
]
=
item
;
queue
->
items
[
to
].
version
=
queue
->
version
;
...
...
@@ -203,7 +203,7 @@ queue_move_range(struct queue *queue, unsigned start, unsigned end, unsigned to)
// Copy the original block back in, starting at to.
for
(
unsigned
i
=
start
;
i
<
end
;
i
++
)
{
queue
->
id
ToP
osition
[
items
[
i
-
start
].
id
]
=
to
+
i
-
start
;
queue
->
id
_to_p
osition
[
items
[
i
-
start
].
id
]
=
to
+
i
-
start
;
queue
->
items
[
to
+
i
-
start
]
=
items
[
i
-
start
];
queue
->
items
[
to
+
i
-
start
].
version
=
queue
->
version
;
}
...
...
@@ -243,7 +243,7 @@ queue_delete(struct queue *queue, unsigned position)
/* release the song id */
queue
->
id
ToP
osition
[
id
]
=
-
1
;
queue
->
id
_to_p
osition
[
id
]
=
-
1
;
/* delete song from songs array */
...
...
@@ -271,7 +271,7 @@ queue_clear(struct queue *queue)
if
(
!
song_in_database
(
item
->
song
))
song_free
(
item
->
song
);
queue
->
id
ToP
osition
[
item
->
id
]
=
-
1
;
queue
->
id
_to_p
osition
[
item
->
id
]
=
-
1
;
}
queue
->
length
=
0
;
...
...
@@ -291,11 +291,11 @@ queue_init(struct queue *queue, unsigned max_length)
queue
->
items
=
g_new
(
struct
queue_item
,
max_length
);
queue
->
order
=
g_malloc
(
sizeof
(
queue
->
order
[
0
])
*
max_length
);
queue
->
id
ToPosition
=
g_malloc
(
sizeof
(
queue
->
idToP
osition
[
0
])
*
queue
->
id
_to_position
=
g_malloc
(
sizeof
(
queue
->
id_to_p
osition
[
0
])
*
max_length
*
QUEUE_HASH_MULT
);
for
(
unsigned
i
=
0
;
i
<
max_length
*
QUEUE_HASH_MULT
;
++
i
)
queue
->
id
ToP
osition
[
i
]
=
-
1
;
queue
->
id
_to_p
osition
[
i
]
=
-
1
;
queue
->
rand
=
g_rand_new
();
}
...
...
@@ -307,7 +307,7 @@ queue_finish(struct queue *queue)
g_free
(
queue
->
items
);
g_free
(
queue
->
order
);
g_free
(
queue
->
id
ToP
osition
);
g_free
(
queue
->
id
_to_p
osition
);
g_rand_free
(
queue
->
rand
);
}
...
...
src/queue.h
View file @
28442cce
...
...
@@ -74,8 +74,8 @@ struct queue {
/** map order numbers to positions */
unsigned
*
order
;
/** map song ids to posi
it
ons */
int
*
id
ToP
osition
;
/** map song ids to posi
ti
ons */
int
*
id
_to_p
osition
;
/** repeat playback when the end of the queue has been
reached? */
...
...
@@ -146,10 +146,10 @@ queue_id_to_position(const struct queue *queue, unsigned id)
if
(
id
>=
queue
->
max_length
*
QUEUE_HASH_MULT
)
return
-
1
;
assert
(
queue
->
id
ToP
osition
[
id
]
>=
-
1
);
assert
(
queue
->
id
ToP
osition
[
id
]
<
(
int
)
queue
->
length
);
assert
(
queue
->
id
_to_p
osition
[
id
]
>=
-
1
);
assert
(
queue
->
id
_to_p
osition
[
id
]
<
(
int
)
queue
->
length
);
return
queue
->
id
ToP
osition
[
id
];
return
queue
->
id
_to_p
osition
[
id
];
}
static
inline
int
...
...
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