comparison liboggplayer-src/src/open_close.cpp @ 14:083c73ceb716

Get rid of the vorbis related code.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 05 Aug 2013 16:54:46 +0300
parents 3b6cea0d1980
children 9c63b355c82b
comparison
equal deleted inserted replaced
13:c859c22c1af5 14:083c73ceb716
1 #include "imp.hpp" 1 #include "imp.hpp"
2 2
3 void OggPlayer::Imp::close() { 3 void OggPlayer::Imp::close() {
4 if(!need_close) return; 4 if(!need_close) return;
5 5
6 #ifdef VORBIS_SUPPORT
6 if (vorbis_p) { 7 if (vorbis_p) {
7 ogg_stream_clear(&o_vsstate); 8 ogg_stream_clear(&o_vsstate);
8 vorbis_block_clear(&v_block); 9 vorbis_block_clear(&v_block);
9 vorbis_dsp_clear(&v_state); 10 vorbis_dsp_clear(&v_state);
10 } 11 }
11 vorbis_comment_clear(&v_comment); 12 vorbis_comment_clear(&v_comment);
12 vorbis_info_clear(&v_info); 13 vorbis_info_clear(&v_info);
14 #endif
13 15
14 if (theora_p) { 16 if (theora_p) {
15 ogg_stream_clear(&o_tsstate); 17 ogg_stream_clear(&o_tsstate);
16 theora_clear(&t_state); 18 theora_clear(&t_state);
17 } 19 }
50 if (!theora_p && theora_decode_header(&t_info, &t_comment, 52 if (!theora_p && theora_decode_header(&t_info, &t_comment,
51 &o_packet) >= 0) { 53 &o_packet) >= 0) {
52 /* it is theora */ 54 /* it is theora */
53 memcpy(&o_tsstate, &test, sizeof(test)); 55 memcpy(&o_tsstate, &test, sizeof(test));
54 theora_p = 1; 56 theora_p = 1;
55 } else if (!vorbis_p && vorbis_synthesis_headerin(&v_info, 57 } else
58 #ifdef VORBIS_SUPPORT
59 if (!vorbis_p && vorbis_synthesis_headerin(&v_info,
56 &v_comment, &o_packet) >= 0) { 60 &v_comment, &o_packet) >= 0) {
57 /* it is vorbis */ 61 /* it is vorbis */
58 memcpy(&o_vsstate, &test, sizeof(test)); 62 memcpy(&o_vsstate, &test, sizeof(test));
59 vorbis_p = 1; 63 vorbis_p = 1;
60 } else { 64 } else
65 #endif
66 {
61 /* whatever it is, we don't care about it */ 67 /* whatever it is, we don't care about it */
62 ogg_stream_clear(&test); 68 ogg_stream_clear(&test);
63 } 69 }
64 } 70 }
65 } 71 }
66 72
67 // we're expecting more header packets. 73 // we're expecting more header packets.
68 while ((theora_p && theora_p < 3) || (vorbis_p && vorbis_p < 3)) { 74 while ((theora_p && theora_p < 3)
75 #ifdef VORBIS_SUPPORT
76 || (vorbis_p && vorbis_p < 3)
77 #endif
78 ) {
69 int ret; 79 int ret;
70 80
71 // look for further theora headers 81 // look for further theora headers
72 while (theora_p && (theora_p < 3) && (ret = ogg_stream_packetout( 82 while (theora_p && (theora_p < 3) && (ret = ogg_stream_packetout(
73 &o_tsstate, &o_packet))) { 83 &o_tsstate, &o_packet))) {
80 return false; 90 return false;
81 } 91 }
82 theora_p++; 92 theora_p++;
83 } 93 }
84 94
95 #ifdef VORBIS_SUPPORT
85 // look for more vorbis header packets 96 // look for more vorbis header packets
86 while (vorbis_p && (vorbis_p < 3) && (ret = ogg_stream_packetout( 97 while (vorbis_p && (vorbis_p < 3) && (ret = ogg_stream_packetout(
87 &o_vsstate, &o_packet))) { 98 &o_vsstate, &o_packet))) {
88 if (ret < 0) { 99 if (ret < 0) {
89 fprintf(stderr, "X: 2\n"); 100 fprintf(stderr, "X: 2\n");
95 } 106 }
96 vorbis_p++; 107 vorbis_p++;
97 if (vorbis_p == 3) 108 if (vorbis_p == 3)
98 break; 109 break;
99 } 110 }
111 #endif
100 112
101 // The header pages/packets will arrive before anything else we 113 // The header pages/packets will arrive before anything else we
102 // care about, or the stream is not obeying spec 114 // care about, or the stream is not obeying spec
103 115
104 if (ogg_sync_pageout(&o_sync, &o_page) > 0) { 116 if (ogg_sync_pageout(&o_sync, &o_page) > 0) {
125 pp_inc = 0; 137 pp_inc = 0;
126 } else { 138 } else {
127 fprintf(stderr, "DDD: 0\n"); 139 fprintf(stderr, "DDD: 0\n");
128 return false; 140 return false;
129 } 141 }
130 #if 0 142 #ifdef VORBIS_SUPPORT
131 if (vorbis_p) { 143 if (vorbis_p) {
132 vorbis_synthesis_init(&v_state, &v_info); 144 vorbis_synthesis_init(&v_state, &v_info);
133 vorbis_block_init(&v_state, &v_block); 145 vorbis_block_init(&v_state, &v_block);
134 } else { 146 } else {
135 fprintf(stderr, "DDD: 1\n"); 147 fprintf(stderr, "DDD: 1\n");
156 return; 168 return;
157 } 169 }
158 170
159 // 2) init some structs 171 // 2) init some structs
160 ogg_sync_init(&o_sync); 172 ogg_sync_init(&o_sync);
173 #ifdef VORBIS_SUPPORT
161 vorbis_info_init(&v_info); 174 vorbis_info_init(&v_info);
162 vorbis_comment_init(&v_comment); 175 vorbis_comment_init(&v_comment);
176 #endif
163 theora_info_init(&t_info); 177 theora_info_init(&t_info);
164 theora_comment_init(&t_comment); 178 theora_comment_init(&t_comment);
165 179
166 // 3) parse headers 180 // 3) parse headers
167 if (!failbit && !parse_headers()) { 181 if (!failbit && !parse_headers()) {
177 191
178 // 4) if fail, tear down the partial setup 192 // 4) if fail, tear down the partial setup
179 if (failbit) { 193 if (failbit) {
180 theora_info_clear(&t_info); 194 theora_info_clear(&t_info);
181 theora_comment_clear(&t_comment); 195 theora_comment_clear(&t_comment);
196 #ifdef VORBIS_SUPPORT
182 vorbis_info_clear(&v_info); 197 vorbis_info_clear(&v_info);
183 vorbis_comment_clear(&v_comment); 198 vorbis_comment_clear(&v_comment);
199 #endif
184 ogg_sync_clear(&o_sync); 200 ogg_sync_clear(&o_sync);
185 file_in.close(); 201 file_in.close();
186 fprintf(stderr, "XXX: done\n"); 202 fprintf(stderr, "XXX: done\n");
187 return; 203 return;
188 } 204 }
189 205
190 #if 0 206 #ifdef VORBIS_SUPPORT
191 // 5) init audio conversion 207 // 5) init audio conversion
192 int ret = SDL_BuildAudioCVT(&cvt, AUDIO_S16, v_info.channels, 208 int ret = SDL_BuildAudioCVT(&cvt, AUDIO_S16, v_info.channels,
193 v_info.rate, audio_format, channels, rate); 209 v_info.rate, audio_format, channels, rate);
194 if (-1 == ret) { 210 if (-1 == ret) {
195 failbit = true; 211 failbit = true;