Exemple #1
0
/*
 * Moves the item at from_pos to to_pos in the play-queue (shuffle = 0) or shuffle-queue (shuffle = 1)
 *
 * The position arguments are relativ to the item with the given id. At position = 1 is the first item
 * after the item with the given id (either in the play-queue or shuffle-queue, depending on the shuffle
 * argument).
 *
 * @param queue     The queue to move items
 * @param from_pos  The position of the first item to be moved
 * @param to_pos    The position to move the items
 * @param shuffle   If 0 the position in the play-queue, 1 the position in the shuffle-queue
 */
void
queue_move_bypos(struct queue *queue, unsigned int item_id, unsigned int from_pos, unsigned int to_offset, char shuffle)
{
  struct queue_item *item;
  struct queue_item *item_next;

  // Get the item to be moved
  item = queueitem_get_bypos(queue, item_id, from_pos, shuffle);
  if (!item)
    {
      DPRINTF(E_LOG, L_PLAYER, "Invalid position given to move items\n");
      return;
    }

  // Get the item at the target position
  item_next = queueitem_get_bypos(queue, item_id, to_offset, shuffle);
  if (!item_next)
    {
      DPRINTF(E_LOG, L_PLAYER, "Invalid position given to move items\n");
      return;
    }

  // Remove item from the queue
  if (shuffle)
    {
      item->shuffle_prev->shuffle_next = item->shuffle_next;
      item->shuffle_next->shuffle_prev = item->shuffle_prev;
    }
  else
    {
      item->prev->next = item->next;
      item->next->prev = item->prev;
    }

  // Insert item into the queue befor the item at the target postion
  if (shuffle)
    {
      item_next->shuffle_prev->shuffle_next = item;
      item->shuffle_prev = item_next->shuffle_prev;

      item_next->shuffle_prev = item;
      item->shuffle_next = item_next;
    }
  else
    {
      item_next->next->prev = item;
      item->next = item_next->next;

      item_next->next = item;
      item->prev = item_next;
    }
}
Exemple #2
0
/*
 * Moves the item at from_pos to to_pos in the play-queue (shuffle = 0) or shuffle-queue (shuffle = 1)
 *
 * The position arguments are relativ to the item with the given id. At position = 1 is the first item
 * after the item with the given id (either in the play-queue or shuffle-queue, depending on the shuffle
 * argument).
 *
 * @param queue     The queue to move items
 * @param from_pos  The position of the first item to be moved
 * @param to_pos    The position to move the items
 * @param shuffle   If 0 the position in the play-queue, 1 the position in the shuffle-queue
 */
void
queue_move_bypos(struct queue *queue, unsigned int item_id, unsigned int from_pos, unsigned int to_offset, char shuffle)
{
  struct queue_item *item;
  struct queue_item *item_next;

  // Get the item to be moved
  item = queueitem_get_bypos(queue, item_id, from_pos, shuffle);
  if (!item)
    {
      DPRINTF(E_LOG, L_PLAYER, "Invalid position given to move items\n");
      return;
    }

  // Get the item at the target position
  item_next = queueitem_get_bypos(queue, item_id, (to_offset + 1), shuffle);

  queue_move_item_before_item(queue, item, item_next, shuffle);
}
Exemple #3
0
/*
 * Returns the item at the given position relative to the item with the given item_id in the
 * play queue (shuffle = 0) or shuffle queue (shuffle = 1).
 *
 * The item with item_id is at pos == 0.
 *
 * @param queue   The queue
 * @param item_id The unique id of the item in the queue
 * @param pos     The position relative to the item with given queue-item-id
 * @param shuffle If 0 the position in the play-queue, 1 the position in the shuffle-queue
 * @return        Item at position in the queue or NULL if not found
 */
struct queue_item *
queue_get_bypos(struct queue *queue, unsigned int item_id, unsigned int pos, char shuffle)
{
  struct queue_item *item;

  item = queueitem_get_bypos(queue, item_id, pos, shuffle);

  if (!item)
    return NULL;

  return item;
}
Exemple #4
0
/*
 * Removes the item at pos from the play-queue (shuffle = 0) or shuffle-queue (shuffle = 1)
 *
 * The position argument is relativ to the item with the given id. At position = 1 is the first item
 * after the item with the given id (either in the play-queue or shuffle-queue, depending on the shuffle
 * argument).
 *
 * @param queue   The queue to add the new items
 * @param item_id The unique id of the item in the queue
 * @param pos     The position of the first item to be removed
 * @param shuffle If 0 the position in the play-queue, 1 the position in the shuffle-queue
 */
void
queue_remove_bypos(struct queue *queue, unsigned int item_id, unsigned int pos, char shuffle)
{
  struct queue_item *item;

  // Get the item after which the items will be removed from the queue
  item = queueitem_get_bypos(queue, item_id, pos, shuffle);
  if (!item)
    {
      DPRINTF(E_LOG, L_PLAYER, "Invalid position given to remove items\n");
      return;
    }

  queue_remove_item(item);
}