From ebf481e1a1d129f8ce9109ea97a77e5a55da128e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 4 Sep 2012 13:05:12 +0200 Subject: decoder/ogg_common: rename to ogg_codec.c --- Makefile.am | 2 +- src/decoder/flac_decoder_plugin.c | 6 ++--- src/decoder/ogg_codec.c | 45 +++++++++++++++++++++++++++++++++++++ src/decoder/ogg_codec.h | 37 ++++++++++++++++++++++++++++++ src/decoder/ogg_common.c | 45 ------------------------------------- src/decoder/ogg_common.h | 37 ------------------------------ src/decoder/vorbis_decoder_plugin.c | 6 ++--- 7 files changed, 89 insertions(+), 89 deletions(-) create mode 100644 src/decoder/ogg_codec.c create mode 100644 src/decoder/ogg_codec.h delete mode 100644 src/decoder/ogg_common.c delete mode 100644 src/decoder/ogg_common.h diff --git a/Makefile.am b/Makefile.am index 22033787c..9e56ae020 100644 --- a/Makefile.am +++ b/Makefile.am @@ -588,7 +588,7 @@ endif if HAVE_OGG_COMMON libdecoder_plugins_a_SOURCES += \ - src/decoder/ogg_common.c src/decoder/ogg_common.h + src/decoder/ogg_codec.c src/decoder/ogg_codec.h endif if HAVE_FLAC_COMMON diff --git a/src/decoder/flac_decoder_plugin.c b/src/decoder/flac_decoder_plugin.c index 8103a8faf..1913480c5 100644 --- a/src/decoder/flac_decoder_plugin.c +++ b/src/decoder/flac_decoder_plugin.c @@ -23,7 +23,7 @@ #include "flac_metadata.h" #if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 -#include "ogg_common.h" +#include "ogg_codec.h" #endif #include @@ -433,10 +433,10 @@ oggflac_scan_file(const char *file, static void oggflac_decode(struct decoder *decoder, struct input_stream *input_stream) { - if (ogg_stream_type_detect(decoder, input_stream) != FLAC) + if (ogg_codec_detect(decoder, input_stream) != OGG_CODEC_FLAC) return; - /* rewind the stream, because ogg_stream_type_detect() has + /* rewind the stream, because ogg_codec_detect() has moved it */ input_stream_lock_seek(input_stream, 0, SEEK_SET, NULL); diff --git a/src/decoder/ogg_codec.c b/src/decoder/ogg_codec.c new file mode 100644 index 000000000..7d05db8e7 --- /dev/null +++ b/src/decoder/ogg_codec.c @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2003-2011 The Music Player Daemon Project + * http://www.musicpd.org + * + * 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. + * + * 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. + */ + +/* + * Common functions used for Ogg data streams (Ogg-Vorbis and OggFLAC) + */ + +#include "config.h" +#include "ogg_codec.h" + +enum ogg_codec +ogg_codec_detect(struct decoder *decoder, struct input_stream *is) +{ + /* oggflac detection based on code in ogg123 and this post + * http://lists.xiph.org/pipermail/flac/2004-December/000393.html + * ogg123 trunk still doesn't have this patch as of June 2005 */ + unsigned char buf[41]; + size_t r = decoder_read(decoder, is, buf, sizeof(buf)); + if (r < sizeof(buf) || memcmp(buf, "OggS", 4) != 0) + return OGG_CODEC_VORBIS; + + if ((memcmp(buf + 29, "FLAC", 4) == 0 && + memcmp(buf + 37, "fLaC", 4) == 0) || + memcmp(buf + 28, "FLAC", 4) == 0 || + memcmp(buf + 28, "fLaC", 4) == 0) + return OGG_CODEC_FLAC; + + return OGG_CODEC_VORBIS; +} diff --git a/src/decoder/ogg_codec.h b/src/decoder/ogg_codec.h new file mode 100644 index 000000000..ac2cdc0ed --- /dev/null +++ b/src/decoder/ogg_codec.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2003-2011 The Music Player Daemon Project + * http://www.musicpd.org + * + * 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. + * + * 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. + */ + +/* + * Common functions used for Ogg data streams (Ogg-Vorbis and OggFLAC) + */ + +#ifndef MPD_OGG_CODEC_H +#define MPD_OGG_CODEC_H + +#include "decoder_api.h" + +enum ogg_codec { + OGG_CODEC_VORBIS, + OGG_CODEC_FLAC, +}; + +enum ogg_codec +ogg_codec_detect(struct decoder *decoder, struct input_stream *is); + +#endif /* _OGG_COMMON_H */ diff --git a/src/decoder/ogg_common.c b/src/decoder/ogg_common.c deleted file mode 100644 index f63bc094b..000000000 --- a/src/decoder/ogg_common.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * http://www.musicpd.org - * - * 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. - * - * 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. - */ - -/* - * Common functions used for Ogg data streams (Ogg-Vorbis and OggFLAC) - */ - -#include "config.h" -#include "ogg_common.h" - -enum ogg_stream_type -ogg_stream_type_detect(struct decoder *decoder, struct input_stream *is) -{ - /* oggflac detection based on code in ogg123 and this post - * http://lists.xiph.org/pipermail/flac/2004-December/000393.html - * ogg123 trunk still doesn't have this patch as of June 2005 */ - unsigned char buf[41]; - size_t r = decoder_read(decoder, is, buf, sizeof(buf)); - if (r < sizeof(buf) || memcmp(buf, "OggS", 4) != 0) - return VORBIS; - - if ((memcmp(buf + 29, "FLAC", 4) == 0 && - memcmp(buf + 37, "fLaC", 4) == 0) || - memcmp(buf + 28, "FLAC", 4) == 0 || - memcmp(buf + 28, "fLaC", 4) == 0) - return FLAC; - - return VORBIS; -} diff --git a/src/decoder/ogg_common.h b/src/decoder/ogg_common.h deleted file mode 100644 index b3c8de238..000000000 --- a/src/decoder/ogg_common.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * http://www.musicpd.org - * - * 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. - * - * 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. - */ - -/* - * Common functions used for Ogg data streams (Ogg-Vorbis and OggFLAC) - */ - -#ifndef MPD_OGG_COMMON_H -#define MPD_OGG_COMMON_H - -#include "decoder_api.h" - -enum ogg_stream_type { - VORBIS, - FLAC, -}; - -enum ogg_stream_type -ogg_stream_type_detect(struct decoder *decoder, struct input_stream *is); - -#endif /* _OGG_COMMON_H */ diff --git a/src/decoder/vorbis_decoder_plugin.c b/src/decoder/vorbis_decoder_plugin.c index e59f7a87f..09bb8c2a0 100644 --- a/src/decoder/vorbis_decoder_plugin.c +++ b/src/decoder/vorbis_decoder_plugin.c @@ -19,7 +19,7 @@ #include "config.h" #include "vorbis_comments.h" -#include "ogg_common.h" +#include "ogg_codec.h" #include "audio_check.h" #include "uri.h" #include "tag_handler.h" @@ -184,10 +184,10 @@ vorbis_stream_decode(struct decoder *decoder, const vorbis_info *vi; enum decoder_command cmd = DECODE_COMMAND_NONE; - if (ogg_stream_type_detect(decoder, input_stream) != VORBIS) + if (ogg_codec_detect(decoder, input_stream) != OGG_CODEC_VORBIS) return; - /* rewind the stream, because ogg_stream_type_detect() has + /* rewind the stream, because ogg_codec_detect() has moved it */ input_stream_lock_seek(input_stream, 0, SEEK_SET, NULL); -- cgit v1.2.3