1 /* -*- linux-c -*-
2 Copyright (C) 2005 Tom Szilagyi
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 $Id: dec_null.c 1068 2009-07-24 12:02:30Z peterszilagyi $
19 */
20
21
22 #include <config.h>
23
24 #include <stdio.h>
25 #include <stdlib.h>
26
27 #include "dec_null.h"
28
29
30 decoder_t *
null_decoder_init(file_decoder_t * fdec)31 null_decoder_init(file_decoder_t * fdec) {
32
33 decoder_t * dec = NULL;
34
35 if ((dec = calloc(1, sizeof(decoder_t))) == NULL) {
36 fprintf(stderr, "dec_null.c: null_decoder_new() failed: calloc error\n");
37 return NULL;
38 }
39
40 dec->fdec = fdec;
41
42 if ((dec->pdata = calloc(1, sizeof(null_pdata_t))) == NULL) {
43 fprintf(stderr, "dec_null.c: null_decoder_new() failed: calloc error\n");
44 return NULL;
45 }
46
47 dec->init = null_decoder_init;
48 dec->destroy = null_decoder_destroy;
49 dec->open = null_decoder_open;
50 dec->send_metadata = null_decoder_send_metadata;
51 dec->close = null_decoder_close;
52 dec->read = null_decoder_read;
53 dec->seek = null_decoder_seek;
54
55 return dec;
56 }
57
58
59 void
null_decoder_destroy(decoder_t * dec)60 null_decoder_destroy(decoder_t * dec) {
61
62 free(dec->pdata);
63 free(dec);
64 }
65
66
67 int
null_decoder_open(decoder_t * dec,char * filename)68 null_decoder_open(decoder_t * dec, char * filename) {
69 /* declarations for easy data access:
70 null_pdata_t * pd = (null_pdata_t *)dec->pdata;
71 file_decoder_t * fdec = dec->fdec;
72 */
73
74 /* do whatever is needed to open the file and
75 determine whether this decoder is able to
76 handle it.
77
78 return one of the following:
79
80 DECODER_OPEN_SUCCESS : this decoder is able to deal with
81 the file and opening was successful.
82
83 DECODER_OPEN_BADLIB : this decoder is not appropriate
84 for this file.
85
86 DECODER_OPEN_FERROR : file nonexistent/nonaccessible, so
87 trying other decoders is pointless.
88
89
90 If opening was successful, put a string describing the
91 format/decoder in format_str[]:
92
93 strcpy(dec->format_str, "NULL Audio");
94 */
95
96 return DECODER_OPEN_BADLIB;
97 }
98
99
100 void
null_decoder_send_metadata(decoder_t * dec)101 null_decoder_send_metadata(decoder_t * dec) {
102 }
103
104 void
null_decoder_close(decoder_t * dec)105 null_decoder_close(decoder_t * dec) {
106 /*
107 null_pdata_t * pd = (null_pdata_t *)dec->pdata;
108 */
109 /* close the file */
110 }
111
112
113 unsigned int
null_decoder_read(decoder_t * dec,float * dest,int num)114 null_decoder_read(decoder_t * dec, float * dest, int num) {
115 /*
116 null_pdata_t * pd = (null_pdata_t *)dec->pdata;
117 file_decoder_t * fdec = dec->fdec;
118 */
119 /* read num frames (mono or stereo) from the file.
120 return the number of frames actually read.
121 */
122
123 return 0;
124 }
125
126
127 void
null_decoder_seek(decoder_t * dec,unsigned long long seek_to_pos)128 null_decoder_seek(decoder_t * dec, unsigned long long seek_to_pos) {
129 /*
130 null_pdata_t * pd = (null_pdata_t *)dec->pdata;
131 file_decoder_t * fdec = dec->fdec;
132 */
133 /* seek to seek_to_pos sample position in the file. */
134 }
135
136 // vim: shiftwidth=8:tabstop=8:softtabstop=8 :
137
138