Commit e1bd2c65 authored by Max Kellermann's avatar Max Kellermann

music_pipe: added music_pipe_contains()

parent 9f79c05e
...@@ -70,6 +70,7 @@ music_pipe_free(struct music_pipe *mp) ...@@ -70,6 +70,7 @@ music_pipe_free(struct music_pipe *mp)
} }
#ifndef NDEBUG #ifndef NDEBUG
bool bool
music_pipe_check_format(const struct music_pipe *pipe, music_pipe_check_format(const struct music_pipe *pipe,
const struct audio_format *audio_format) const struct audio_format *audio_format)
...@@ -80,6 +81,26 @@ music_pipe_check_format(const struct music_pipe *pipe, ...@@ -80,6 +81,26 @@ music_pipe_check_format(const struct music_pipe *pipe,
return !audio_format_defined(&pipe->audio_format) || return !audio_format_defined(&pipe->audio_format) ||
audio_format_equals(&pipe->audio_format, audio_format); audio_format_equals(&pipe->audio_format, audio_format);
} }
bool
music_pipe_contains(const struct music_pipe *mp,
const struct music_chunk *chunk)
{
g_mutex_lock(mp->mutex);
for (const struct music_chunk *i = mp->head;
i != NULL; i = i->next) {
if (i == chunk) {
g_mutex_unlock(mp->mutex);
return true;
}
}
g_mutex_unlock(mp->mutex);
return false;
}
#endif #endif
const struct music_chunk * const struct music_chunk *
......
...@@ -47,6 +47,7 @@ void ...@@ -47,6 +47,7 @@ void
music_pipe_free(struct music_pipe *mp); music_pipe_free(struct music_pipe *mp);
#ifndef NDEBUG #ifndef NDEBUG
/** /**
* Checks if the audio format if the chunk is equal to the specified * Checks if the audio format if the chunk is equal to the specified
* audio_format. * audio_format.
...@@ -54,6 +55,14 @@ music_pipe_free(struct music_pipe *mp); ...@@ -54,6 +55,14 @@ music_pipe_free(struct music_pipe *mp);
bool bool
music_pipe_check_format(const struct music_pipe *pipe, music_pipe_check_format(const struct music_pipe *pipe,
const struct audio_format *audio_format); const struct audio_format *audio_format);
/**
* 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);
#endif #endif
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment