Added vorbis-tools.
[vorbis-lancer-gcc.git] / vorbis-tools-1.2.0 / ogg123 / format.c
blob53eb3ad1d55a71da010189dc6e83f41b1d7ec17d
1 /********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5 * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
6 * PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7 * *
8 * THE Ogg123 SOURCE CODE IS (C) COPYRIGHT 2000-2001 *
9 * by Stan Seibert <volsung@xiph.org> AND OTHER CONTRIBUTORS *
10 * http://www.xiph.org/ *
11 * *
12 ********************************************************************
14 last mod: $Id: format.c,v 1.5 2003/01/12 20:19:22 volsung Exp $
16 ********************************************************************/
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
22 #include <stdio.h>
23 #include <string.h>
25 #include "transport.h"
26 #include "format.h"
27 #include "i18n.h"
29 extern format_t oggvorbis_format;
30 extern format_t speex_format;
32 #ifdef HAVE_LIBFLAC
33 extern format_t flac_format;
34 extern format_t oggflac_format;
35 #endif
37 #ifdef HAVE_LIBSPEEX
38 extern format_t speex_format;
39 #endif
41 format_t *formats[] = {
42 #ifdef HAVE_LIBFLAC
43 &flac_format,
44 &oggflac_format,
45 #endif
46 #ifdef HAVE_LIBSPEEX
47 &speex_format,
48 #endif
49 &oggvorbis_format,
50 NULL };
53 format_t *get_format_by_name (char *name)
55 int i = 0;
57 while (formats[i] != NULL && strcmp(name, formats[i]->name) != 0)
58 i++;
60 return formats[i];
64 format_t *select_format (data_source_t *source)
66 int i = 0;
68 while (formats[i] != NULL && !formats[i]->can_decode(source))
69 i++;
71 return formats[i];
75 decoder_stats_t *malloc_decoder_stats (decoder_stats_t *to_copy)
77 decoder_stats_t *new_stats;
79 new_stats = malloc(sizeof(decoder_stats_t));
81 if (new_stats == NULL) {
82 fprintf(stderr, _("Error: Could not allocate memory in malloc_decoder_stats()\n"));
83 exit(1);
86 *new_stats = *to_copy; /* Copy the data */
88 return new_stats;