comparison decoders/ogg.c @ 59:cd91e1857b42

Changed _D macro to SNDDBG, and fixed a warning if compiling without debug chatter enabled.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 24 Sep 2001 15:29:27 +0000
parents ea58bc3b15d7
children 9669aa13d3e0
comparison
equal deleted inserted replaced
58:4a51162099e0 59:cd91e1857b42
119 RWops_ogg_tell 119 RWops_ogg_tell
120 }; 120 };
121 121
122 122
123 /* Return a human readable version of an VorbisFile error code... */ 123 /* Return a human readable version of an VorbisFile error code... */
124 #if (defined DEBUG_CHATTER)
124 static const char *ogg_error(int errnum) 125 static const char *ogg_error(int errnum)
125 { 126 {
126 switch(errnum) 127 switch(errnum)
127 { 128 {
128 case OV_EREAD: 129 case OV_EREAD:
137 return("internal logic fault in Vorbis library"); 138 return("internal logic fault in Vorbis library");
138 } /* switch */ 139 } /* switch */
139 140
140 return("unknown error"); 141 return("unknown error");
141 } /* ogg_error */ 142 } /* ogg_error */
142 143 #endif
143 144
144 static __inline__ void output_ogg_comments(OggVorbis_File *vf) 145 static __inline__ void output_ogg_comments(OggVorbis_File *vf)
145 { 146 {
146 #if (defined DEBUG_CHATTER) 147 #if (defined DEBUG_CHATTER)
147 int i; 148 int i;
148 vorbis_comment *vc = ov_comment(vf, -1); 149 vorbis_comment *vc = ov_comment(vf, -1);
149 150
150 if (vc == NULL) 151 if (vc == NULL)
151 return; 152 return;
152 153
153 _D(("OGG: vendor == [%s].\n", vc->vendor)); 154 SNDDBG(("OGG: vendor == [%s].\n", vc->vendor));
154 for (i = 0; i < vc->comments; i++) 155 for (i = 0; i < vc->comments; i++)
155 { 156 {
156 _D(("OGG: user comment [%s].\n", vc->user_comments[i])); 157 SNDDBG(("OGG: user comment [%s].\n", vc->user_comments[i]));
157 } /* for */ 158 } /* for */
158 #endif 159 #endif
159 } /* output_ogg_comments */ 160 } /* output_ogg_comments */
160 161
161 162
170 BAIL_IF_MACRO(vf == NULL, ERR_OUT_OF_MEMORY, 0); 171 BAIL_IF_MACRO(vf == NULL, ERR_OUT_OF_MEMORY, 0);
171 172
172 rc = ov_open_callbacks(internal->rw, vf, NULL, 0, RWops_ogg_callbacks); 173 rc = ov_open_callbacks(internal->rw, vf, NULL, 0, RWops_ogg_callbacks);
173 if (rc != 0) 174 if (rc != 0)
174 { 175 {
175 _D(("OGG: can't grok data. reason: [%s].\n", ogg_error(rc))); 176 SNDDBG(("OGG: can't grok data. reason: [%s].\n", ogg_error(rc)));
176 free(vf); 177 free(vf);
177 BAIL_MACRO("OGG: Not valid Ogg Vorbis data.", 0); 178 BAIL_MACRO("OGG: Not valid Ogg Vorbis data.", 0);
178 } /* if */ 179 } /* if */
179 180
180 info = ov_info(vf, -1); 181 info = ov_info(vf, -1);
183 ov_clear(vf); 184 ov_clear(vf);
184 free(vf); 185 free(vf);
185 BAIL_MACRO("OGG: failed to retrieve bitstream info", 0); 186 BAIL_MACRO("OGG: failed to retrieve bitstream info", 0);
186 } /* if */ 187 } /* if */
187 188
188 _D(("OGG: Accepting data stream.\n")); 189 SNDDBG(("OGG: Accepting data stream.\n"));
189 190
190 output_ogg_comments(vf); 191 output_ogg_comments(vf);
191 _D(("OGG: bitstream version == (%d).\n", info->version)); 192 SNDDBG(("OGG: bitstream version == (%d).\n", info->version));
192 _D(("OGG: bitstream channels == (%d).\n", info->channels)); 193 SNDDBG(("OGG: bitstream channels == (%d).\n", info->channels));
193 _D(("OGG: bitstream sampling rate == (%ld).\n", info->rate)); 194 SNDDBG(("OGG: bitstream sampling rate == (%ld).\n", info->rate));
194 _D(("OGG: seekable == {%s}.\n", ov_seekable(vf) ? "TRUE" : "FALSE")); 195 SNDDBG(("OGG: seekable == {%s}.\n", ov_seekable(vf) ? "TRUE" : "FALSE"));
195 _D(("OGG: number of logical bitstreams == (%ld).\n", ov_streams(vf))); 196 SNDDBG(("OGG: number of logical bitstreams == (%ld).\n", ov_streams(vf)));
196 _D(("OGG: serial number == (%ld).\n", ov_serialnumber(vf, -1))); 197 SNDDBG(("OGG: serial number == (%ld).\n", ov_serialnumber(vf, -1)));
197 _D(("OGG: total seconds of sample == (%f).\n", ov_time_total(vf, -1))); 198 SNDDBG(("OGG: total seconds of sample == (%f).\n", ov_time_total(vf, -1)));
198 199
199 internal->decoder_private = vf; 200 internal->decoder_private = vf;
200 sample->flags = SOUND_SAMPLEFLAG_NONE; 201 sample->flags = SOUND_SAMPLEFLAG_NONE;
201 sample->actual.rate = (Uint32) info->rate; 202 sample->actual.rate = (Uint32) info->rate;
202 sample->actual.channels = (Uint8) info->channels; 203 sample->actual.channels = (Uint8) info->channels;