music_pipe: renamed ob_* functions to music_pipe_*
Rename all functions to the new prefix.
This commit is contained in:
parent
8964c69a64
commit
fd0f195bb7
@ -66,7 +66,7 @@ void decoder_command_finished(mpd_unused struct decoder * decoder)
|
|||||||
|
|
||||||
if (dc.command == DECODE_COMMAND_SEEK)
|
if (dc.command == DECODE_COMMAND_SEEK)
|
||||||
/* delete frames from the old song position */
|
/* delete frames from the old song position */
|
||||||
ob_clear();
|
music_pipe_clear();
|
||||||
|
|
||||||
dc.command = DECODE_COMMAND_NONE;
|
dc.command = DECODE_COMMAND_NONE;
|
||||||
notify_signal(&pc.notify);
|
notify_signal(&pc.notify);
|
||||||
@ -181,7 +181,7 @@ decoder_data(struct decoder *decoder,
|
|||||||
normalizeData(data, datalen, &ob.audioFormat);
|
normalizeData(data, datalen, &ob.audioFormat);
|
||||||
|
|
||||||
while (datalen > 0) {
|
while (datalen > 0) {
|
||||||
nbytes = ob_append(data, datalen, data_time, bitRate);
|
nbytes = music_pipe_append(data, datalen, data_time, bitRate);
|
||||||
datalen -= nbytes;
|
datalen -= nbytes;
|
||||||
data += nbytes;
|
data += nbytes;
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ static void decodeStart(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_flush();
|
music_pipe_flush();
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
dc.error = plugin == NULL
|
dc.error = plugin == NULL
|
||||||
|
@ -424,7 +424,7 @@ int main(int argc, char *argv[])
|
|||||||
command_init();
|
command_init();
|
||||||
initPlayerData();
|
initPlayerData();
|
||||||
pc_init(buffered_before_play);
|
pc_init(buffered_before_play);
|
||||||
ob_init(buffered_chunks, &pc.notify);
|
music_pipe_init(buffered_chunks, &pc.notify);
|
||||||
dc_init();
|
dc_init();
|
||||||
initAudioConfig();
|
initAudioConfig();
|
||||||
initAudioDriver();
|
initAudioDriver();
|
||||||
@ -488,7 +488,7 @@ int main(int argc, char *argv[])
|
|||||||
pc_deinit();
|
pc_deinit();
|
||||||
command_finish();
|
command_finish();
|
||||||
decoder_plugin_deinit_all();
|
decoder_plugin_deinit_all();
|
||||||
ob_free();
|
music_pipe_free();
|
||||||
cleanUpPidFile();
|
cleanUpPidFile();
|
||||||
finishConf();
|
finishConf();
|
||||||
|
|
||||||
|
38
src/pipe.c
38
src/pipe.c
@ -26,7 +26,7 @@
|
|||||||
struct music_pipe ob;
|
struct music_pipe ob;
|
||||||
|
|
||||||
void
|
void
|
||||||
ob_init(unsigned int size, struct notify *notify)
|
music_pipe_init(unsigned int size, struct notify *notify)
|
||||||
{
|
{
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
|
|
||||||
@ -39,13 +39,13 @@ ob_init(unsigned int size, struct notify *notify)
|
|||||||
ob.chunks[0].chunkSize = 0;
|
ob.chunks[0].chunkSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_free(void)
|
void music_pipe_free(void)
|
||||||
{
|
{
|
||||||
assert(ob.chunks != NULL);
|
assert(ob.chunks != NULL);
|
||||||
free(ob.chunks);
|
free(ob.chunks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_clear(void)
|
void music_pipe_clear(void)
|
||||||
{
|
{
|
||||||
ob.end = ob.begin;
|
ob.end = ob.begin;
|
||||||
ob.chunks[ob.end].chunkSize = 0;
|
ob.chunks[ob.end].chunkSize = 0;
|
||||||
@ -66,7 +66,7 @@ static inline unsigned successor(unsigned i)
|
|||||||
*/
|
*/
|
||||||
static void output_buffer_expand(unsigned i)
|
static void output_buffer_expand(unsigned i)
|
||||||
{
|
{
|
||||||
int was_empty = ob.notify != NULL && (!ob.lazy || ob_is_empty());
|
int was_empty = ob.notify != NULL && (!ob.lazy || music_pipe_is_empty());
|
||||||
|
|
||||||
assert(i == (ob.end + 1) % ob.size);
|
assert(i == (ob.end + 1) % ob.size);
|
||||||
assert(i != ob.end);
|
assert(i != ob.end);
|
||||||
@ -80,9 +80,9 @@ static void output_buffer_expand(unsigned i)
|
|||||||
notify_signal(ob.notify);
|
notify_signal(ob.notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_flush(void)
|
void music_pipe_flush(void)
|
||||||
{
|
{
|
||||||
struct music_chunk *chunk = ob_get_chunk(ob.end);
|
struct music_chunk *chunk = music_pipe_get_chunk(ob.end);
|
||||||
|
|
||||||
if (chunk->chunkSize > 0) {
|
if (chunk->chunkSize > 0) {
|
||||||
unsigned int next = successor(ob.end);
|
unsigned int next = successor(ob.end);
|
||||||
@ -96,12 +96,12 @@ void ob_flush(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_set_lazy(bool lazy)
|
void music_pipe_set_lazy(bool lazy)
|
||||||
{
|
{
|
||||||
ob.lazy = lazy;
|
ob.lazy = lazy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_shift(void)
|
void music_pipe_shift(void)
|
||||||
{
|
{
|
||||||
assert(ob.begin != ob.end);
|
assert(ob.begin != ob.end);
|
||||||
assert(ob.begin < ob.size);
|
assert(ob.begin < ob.size);
|
||||||
@ -109,7 +109,7 @@ void ob_shift(void)
|
|||||||
ob.begin = successor(ob.begin);
|
ob.begin = successor(ob.begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ob_relative(const unsigned i)
|
unsigned int music_pipe_relative(const unsigned i)
|
||||||
{
|
{
|
||||||
if (i >= ob.begin)
|
if (i >= ob.begin)
|
||||||
return i - ob.begin;
|
return i - ob.begin;
|
||||||
@ -117,12 +117,12 @@ unsigned int ob_relative(const unsigned i)
|
|||||||
return i + ob.size - ob.begin;
|
return i + ob.size - ob.begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned ob_available(void)
|
unsigned music_pipe_available(void)
|
||||||
{
|
{
|
||||||
return ob_relative(ob.end);
|
return music_pipe_relative(ob.end);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ob_absolute(const unsigned relative)
|
int music_pipe_absolute(const unsigned relative)
|
||||||
{
|
{
|
||||||
unsigned i, max;
|
unsigned i, max;
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ int ob_absolute(const unsigned relative)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct music_chunk *
|
struct music_chunk *
|
||||||
ob_get_chunk(const unsigned i)
|
music_pipe_get_chunk(const unsigned i)
|
||||||
{
|
{
|
||||||
assert(i < ob.size);
|
assert(i < ob.size);
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ tail_chunk(float data_time, uint16_t bitRate)
|
|||||||
unsigned int next;
|
unsigned int next;
|
||||||
struct music_chunk *chunk;
|
struct music_chunk *chunk;
|
||||||
|
|
||||||
chunk = ob_get_chunk(ob.end);
|
chunk = music_pipe_get_chunk(ob.end);
|
||||||
assert(chunk->chunkSize <= sizeof(chunk->data));
|
assert(chunk->chunkSize <= sizeof(chunk->data));
|
||||||
if (chunk->chunkSize + frame_size > sizeof(chunk->data)) {
|
if (chunk->chunkSize + frame_size > sizeof(chunk->data)) {
|
||||||
/* this chunk is full; allocate a new chunk */
|
/* this chunk is full; allocate a new chunk */
|
||||||
@ -170,7 +170,7 @@ tail_chunk(float data_time, uint16_t bitRate)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
output_buffer_expand(next);
|
output_buffer_expand(next);
|
||||||
chunk = ob_get_chunk(next);
|
chunk = music_pipe_get_chunk(next);
|
||||||
assert(chunk->chunkSize == 0);
|
assert(chunk->chunkSize == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ tail_chunk(float data_time, uint16_t bitRate)
|
|||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ob_append(const void *data0, size_t datalen,
|
size_t music_pipe_append(const void *data0, size_t datalen,
|
||||||
float data_time, uint16_t bitRate)
|
float data_time, uint16_t bitRate)
|
||||||
{
|
{
|
||||||
const unsigned char *data = data0;
|
const unsigned char *data = data0;
|
||||||
@ -217,14 +217,14 @@ size_t ob_append(const void *data0, size_t datalen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chunk != NULL && chunk->chunkSize == sizeof(chunk->data))
|
if (chunk != NULL && chunk->chunkSize == sizeof(chunk->data))
|
||||||
ob_flush();
|
music_pipe_flush();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_skip(unsigned num)
|
void music_pipe_skip(unsigned num)
|
||||||
{
|
{
|
||||||
int i = ob_absolute(num);
|
int i = music_pipe_absolute(num);
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
ob.begin = i;
|
ob.begin = i;
|
||||||
}
|
}
|
||||||
|
26
src/pipe.h
26
src/pipe.h
@ -61,13 +61,13 @@ struct music_pipe {
|
|||||||
extern struct music_pipe ob;
|
extern struct music_pipe ob;
|
||||||
|
|
||||||
void
|
void
|
||||||
ob_init(unsigned int size, struct notify *notify);
|
music_pipe_init(unsigned int size, struct notify *notify);
|
||||||
|
|
||||||
void ob_free(void);
|
void music_pipe_free(void);
|
||||||
|
|
||||||
void ob_clear(void);
|
void music_pipe_clear(void);
|
||||||
|
|
||||||
void ob_flush(void);
|
void music_pipe_flush(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a chunk is decoded, we wake up the player thread to tell him
|
* When a chunk is decoded, we wake up the player thread to tell him
|
||||||
@ -75,42 +75,42 @@ void ob_flush(void);
|
|||||||
* previously empty, i.e. when the player thread has really been
|
* previously empty, i.e. when the player thread has really been
|
||||||
* waiting for us.
|
* waiting for us.
|
||||||
*/
|
*/
|
||||||
void ob_set_lazy(bool lazy);
|
void music_pipe_set_lazy(bool lazy);
|
||||||
|
|
||||||
/** is the buffer empty? */
|
/** is the buffer empty? */
|
||||||
static inline bool ob_is_empty(void)
|
static inline bool music_pipe_is_empty(void)
|
||||||
{
|
{
|
||||||
return ob.begin == ob.end;
|
return ob.begin == ob.end;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_shift(void);
|
void music_pipe_shift(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* what is the position of the specified chunk number, relative to
|
* what is the position of the specified chunk number, relative to
|
||||||
* the first chunk in use?
|
* the first chunk in use?
|
||||||
*/
|
*/
|
||||||
unsigned int ob_relative(const unsigned i);
|
unsigned int music_pipe_relative(const unsigned i);
|
||||||
|
|
||||||
/** determine the number of decoded chunks */
|
/** determine the number of decoded chunks */
|
||||||
unsigned ob_available(void);
|
unsigned music_pipe_available(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the absolute index of the nth used chunk after the first one.
|
* Get the absolute index of the nth used chunk after the first one.
|
||||||
* Returns -1 if there is no such chunk.
|
* Returns -1 if there is no such chunk.
|
||||||
*/
|
*/
|
||||||
int ob_absolute(const unsigned relative);
|
int music_pipe_absolute(const unsigned relative);
|
||||||
|
|
||||||
struct music_chunk *
|
struct music_chunk *
|
||||||
ob_get_chunk(const unsigned i);
|
music_pipe_get_chunk(const unsigned i);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append a data block to the buffer.
|
* Append a data block to the buffer.
|
||||||
*
|
*
|
||||||
* @return the number of bytes actually written
|
* @return the number of bytes actually written
|
||||||
*/
|
*/
|
||||||
size_t ob_append(const void *data, size_t datalen,
|
size_t music_pipe_append(const void *data, size_t datalen,
|
||||||
float data_time, uint16_t bitRate);
|
float data_time, uint16_t bitRate);
|
||||||
|
|
||||||
void ob_skip(unsigned num);
|
void music_pipe_skip(unsigned num);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -114,7 +114,7 @@ static bool decodeSeek(struct player *player)
|
|||||||
if (decoder_current_song() != pc.next_song) {
|
if (decoder_current_song() != pc.next_song) {
|
||||||
dc_stop(&pc.notify);
|
dc_stop(&pc.notify);
|
||||||
player->next_song_chunk = -1;
|
player->next_song_chunk = -1;
|
||||||
ob_clear();
|
music_pipe_clear();
|
||||||
dc_start_async(pc.next_song);
|
dc_start_async(pc.next_song);
|
||||||
waitOnDecode(player);
|
waitOnDecode(player);
|
||||||
}
|
}
|
||||||
@ -241,8 +241,8 @@ static void do_play(void)
|
|||||||
struct audio_format play_audio_format;
|
struct audio_format play_audio_format;
|
||||||
double sizeToTime = 0.0;
|
double sizeToTime = 0.0;
|
||||||
|
|
||||||
ob_clear();
|
music_pipe_clear();
|
||||||
ob_set_lazy(false);
|
music_pipe_set_lazy(false);
|
||||||
|
|
||||||
dc_start(&pc.notify, pc.next_song);
|
dc_start(&pc.notify, pc.next_song);
|
||||||
if (waitOnDecode(&player) < 0) {
|
if (waitOnDecode(&player) < 0) {
|
||||||
@ -265,7 +265,7 @@ static void do_play(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (player.buffering) {
|
if (player.buffering) {
|
||||||
if (ob_available() < pc.buffered_before_play &&
|
if (music_pipe_available() < pc.buffered_before_play &&
|
||||||
!decoder_is_idle()) {
|
!decoder_is_idle()) {
|
||||||
/* not enough decoded buffer space yet */
|
/* not enough decoded buffer space yet */
|
||||||
notify_wait(&pc.notify);
|
notify_wait(&pc.notify);
|
||||||
@ -273,7 +273,7 @@ static void do_play(void)
|
|||||||
} else {
|
} else {
|
||||||
/* buffering is complete */
|
/* buffering is complete */
|
||||||
player.buffering = false;
|
player.buffering = false;
|
||||||
ob_set_lazy(true);
|
music_pipe_set_lazy(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,13 +355,14 @@ static void do_play(void)
|
|||||||
|
|
||||||
if (player.paused)
|
if (player.paused)
|
||||||
notify_wait(&pc.notify);
|
notify_wait(&pc.notify);
|
||||||
else if (!ob_is_empty() &&
|
else if (!music_pipe_is_empty() &&
|
||||||
(int)ob.begin != player.next_song_chunk) {
|
(int)ob.begin != player.next_song_chunk) {
|
||||||
struct music_chunk *beginChunk = ob_get_chunk(ob.begin);
|
struct music_chunk *beginChunk =
|
||||||
|
music_pipe_get_chunk(ob.begin);
|
||||||
unsigned int fadePosition;
|
unsigned int fadePosition;
|
||||||
if (player.xfade == XFADE_ENABLED &&
|
if (player.xfade == XFADE_ENABLED &&
|
||||||
player.next_song_chunk >= 0 &&
|
player.next_song_chunk >= 0 &&
|
||||||
(fadePosition = ob_relative(player.next_song_chunk))
|
(fadePosition = music_pipe_relative(player.next_song_chunk))
|
||||||
<= crossFadeChunks) {
|
<= crossFadeChunks) {
|
||||||
/* perform cross fade */
|
/* perform cross fade */
|
||||||
if (nextChunk < 0) {
|
if (nextChunk < 0) {
|
||||||
@ -372,11 +373,11 @@ static void do_play(void)
|
|||||||
chunks in the old song */
|
chunks in the old song */
|
||||||
crossFadeChunks = fadePosition;
|
crossFadeChunks = fadePosition;
|
||||||
}
|
}
|
||||||
nextChunk = ob_absolute(crossFadeChunks);
|
nextChunk = music_pipe_absolute(crossFadeChunks);
|
||||||
if (nextChunk >= 0) {
|
if (nextChunk >= 0) {
|
||||||
ob_set_lazy(true);
|
music_pipe_set_lazy(true);
|
||||||
cross_fade_apply(beginChunk,
|
cross_fade_apply(beginChunk,
|
||||||
ob_get_chunk(nextChunk),
|
music_pipe_get_chunk(nextChunk),
|
||||||
&(ob.audioFormat),
|
&(ob.audioFormat),
|
||||||
fadePosition,
|
fadePosition,
|
||||||
crossFadeChunks);
|
crossFadeChunks);
|
||||||
@ -391,7 +392,7 @@ static void do_play(void)
|
|||||||
} else {
|
} else {
|
||||||
/* wait for the
|
/* wait for the
|
||||||
decoder */
|
decoder */
|
||||||
ob_set_lazy(false);
|
music_pipe_set_lazy(false);
|
||||||
notify_wait(&pc.notify);
|
notify_wait(&pc.notify);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -402,15 +403,15 @@ static void do_play(void)
|
|||||||
if (playChunk(beginChunk, &play_audio_format,
|
if (playChunk(beginChunk, &play_audio_format,
|
||||||
sizeToTime) < 0)
|
sizeToTime) < 0)
|
||||||
break;
|
break;
|
||||||
ob_shift();
|
music_pipe_shift();
|
||||||
|
|
||||||
/* this formula should prevent that the
|
/* this formula should prevent that the
|
||||||
decoder gets woken up with each chunk; it
|
decoder gets woken up with each chunk; it
|
||||||
is more efficient to make it decode a
|
is more efficient to make it decode a
|
||||||
larger block at a time */
|
larger block at a time */
|
||||||
if (ob_available() <= (pc.buffered_before_play + ob.size * 3) / 4)
|
if (music_pipe_available() <= (pc.buffered_before_play + ob.size * 3) / 4)
|
||||||
notify_signal(&dc.notify);
|
notify_signal(&dc.notify);
|
||||||
} else if (!ob_is_empty() &&
|
} else if (!music_pipe_is_empty() &&
|
||||||
(int)ob.begin == player.next_song_chunk) {
|
(int)ob.begin == player.next_song_chunk) {
|
||||||
/* at the beginning of a new song */
|
/* at the beginning of a new song */
|
||||||
|
|
||||||
@ -418,7 +419,7 @@ static void do_play(void)
|
|||||||
/* the cross-fade is finished; skip
|
/* the cross-fade is finished; skip
|
||||||
the section which was cross-faded
|
the section which was cross-faded
|
||||||
(and thus already played) */
|
(and thus already played) */
|
||||||
ob_skip(crossFadeChunks);
|
music_pipe_skip(crossFadeChunks);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.xfade = XFADE_UNKNOWN;
|
player.xfade = XFADE_UNKNOWN;
|
||||||
|
Loading…
Reference in New Issue
Block a user