2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2011-01-29 10:13:54 +01:00
|
|
|
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-05-07 17:58:04 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-05-07 17:58:04 +02:00
|
|
|
*/
|
|
|
|
|
2008-11-02 14:12:52 +01:00
|
|
|
#ifndef MPD_PIPE_H
|
|
|
|
#define MPD_PIPE_H
|
2004-05-07 17:58:04 +02:00
|
|
|
|
2012-08-02 18:15:49 +02:00
|
|
|
#include "gcc.h"
|
|
|
|
|
2011-01-14 15:43:51 +01:00
|
|
|
#ifndef NDEBUG
|
2013-08-03 21:00:50 +02:00
|
|
|
struct AudioFormat;
|
2009-03-08 13:45:24 +01:00
|
|
|
#endif
|
|
|
|
|
2009-03-03 22:23:25 +01:00
|
|
|
struct music_chunk;
|
2009-03-06 00:42:03 +01:00
|
|
|
struct music_buffer;
|
2008-04-12 06:13:24 +02:00
|
|
|
|
2008-04-12 06:08:35 +02:00
|
|
|
/**
|
2009-03-06 00:42:03 +01:00
|
|
|
* A queue of #music_chunk objects. One party appends chunks at the
|
|
|
|
* tail, and the other consumes them from the head.
|
2008-04-15 07:57:22 +02:00
|
|
|
*/
|
2009-03-06 00:42:03 +01:00
|
|
|
struct music_pipe;
|
2008-04-12 06:13:51 +02:00
|
|
|
|
2008-04-12 06:12:53 +02:00
|
|
|
/**
|
2009-03-06 00:42:03 +01:00
|
|
|
* Creates a new #music_pipe object. It is empty.
|
2008-04-12 06:12:53 +02:00
|
|
|
*/
|
2012-08-02 18:15:49 +02:00
|
|
|
gcc_malloc
|
2009-03-06 00:42:03 +01:00
|
|
|
struct music_pipe *
|
|
|
|
music_pipe_new(void);
|
2008-04-12 06:11:41 +02:00
|
|
|
|
2008-04-12 06:12:42 +02:00
|
|
|
/**
|
2009-03-06 00:42:03 +01:00
|
|
|
* Frees the object. It must be empty now.
|
2008-04-12 06:12:42 +02:00
|
|
|
*/
|
2009-03-06 00:42:03 +01:00
|
|
|
void
|
|
|
|
music_pipe_free(struct music_pipe *mp);
|
2008-11-02 16:55:53 +01:00
|
|
|
|
2009-03-08 13:45:24 +01:00
|
|
|
#ifndef NDEBUG
|
2009-03-09 19:15:54 +01:00
|
|
|
|
2009-03-08 13:45:24 +01:00
|
|
|
/**
|
|
|
|
* Checks if the audio format if the chunk is equal to the specified
|
|
|
|
* audio_format.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
music_pipe_check_format(const struct music_pipe *pipe,
|
2013-08-03 21:00:50 +02:00
|
|
|
AudioFormat audio_format);
|
2009-03-09 19:15:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the specified chunk is enqueued in the music pipe.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
music_pipe_contains(const struct music_pipe *mp,
|
|
|
|
const struct music_chunk *chunk);
|
|
|
|
|
2009-03-08 13:45:24 +01:00
|
|
|
#endif
|
|
|
|
|
2009-03-07 19:56:31 +01:00
|
|
|
/**
|
|
|
|
* Returns the first #music_chunk from the pipe. Returns NULL if the
|
|
|
|
* pipe is empty.
|
|
|
|
*/
|
2012-08-02 18:15:49 +02:00
|
|
|
gcc_pure
|
2009-03-07 19:56:31 +01:00
|
|
|
const struct music_chunk *
|
|
|
|
music_pipe_peek(const struct music_pipe *mp);
|
|
|
|
|
2009-03-06 00:42:01 +01:00
|
|
|
/**
|
2009-03-06 00:42:03 +01:00
|
|
|
* Removes the first chunk from the head, and returns it.
|
2009-03-06 00:42:01 +01:00
|
|
|
*/
|
|
|
|
struct music_chunk *
|
2009-03-06 00:42:03 +01:00
|
|
|
music_pipe_shift(struct music_pipe *mp);
|
2009-03-06 00:42:01 +01:00
|
|
|
|
|
|
|
/**
|
2009-03-06 00:42:03 +01:00
|
|
|
* Clears the whole pipe and returns the chunks to the buffer.
|
2009-03-06 00:42:01 +01:00
|
|
|
*
|
2009-03-06 00:42:03 +01:00
|
|
|
* @param buffer the buffer object to return the chunks to
|
2009-03-06 00:42:01 +01:00
|
|
|
*/
|
|
|
|
void
|
2009-03-06 00:42:03 +01:00
|
|
|
music_pipe_clear(struct music_pipe *mp, struct music_buffer *buffer);
|
2009-03-06 00:42:01 +01:00
|
|
|
|
2009-01-17 13:09:29 +01:00
|
|
|
/**
|
2009-03-06 00:42:03 +01:00
|
|
|
* Pushes a chunk to the tail of the pipe.
|
2009-01-17 13:09:29 +01:00
|
|
|
*/
|
|
|
|
void
|
2009-03-06 00:42:03 +01:00
|
|
|
music_pipe_push(struct music_pipe *mp, struct music_chunk *chunk);
|
2008-04-12 06:18:19 +02:00
|
|
|
|
2008-11-13 02:09:33 +01:00
|
|
|
/**
|
2009-03-06 00:42:03 +01:00
|
|
|
* Returns the number of chunks currently in this pipe.
|
2008-11-13 02:09:33 +01:00
|
|
|
*/
|
2012-08-02 18:15:49 +02:00
|
|
|
gcc_pure
|
2009-03-06 00:42:03 +01:00
|
|
|
unsigned
|
|
|
|
music_pipe_size(const struct music_pipe *mp);
|
2008-11-13 02:06:58 +01:00
|
|
|
|
2012-08-02 18:15:49 +02:00
|
|
|
gcc_pure
|
2010-11-05 18:34:06 +01:00
|
|
|
static inline bool
|
|
|
|
music_pipe_empty(const struct music_pipe *mp)
|
|
|
|
{
|
|
|
|
return music_pipe_size(mp) == 0;
|
|
|
|
}
|
|
|
|
|
2004-05-07 17:58:04 +02:00
|
|
|
#endif
|