#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
-#include "server.cmdline.h"
#include "server.h"
-#include "vss.h"
#include "error.h"
#include "string.h"
num = time_total / chunk_time + 3;
PARA_DEBUG_LOG("chunk time: %g allocating %d chunk pointers\n",
chunk_time, num);
- afi->chunk_table = para_malloc(num * sizeof(size_t));
+ afi->chunk_table = para_malloc((num + 1) * sizeof(size_t));
afi->chunk_table[0] = 0;
max_chunk_len = 0;
- for (i = 1; ret == 0; i++) {
+ for (i = 1; ret <= num; i++) {
ogg_int64_t diff;
ret = ov_time_seek(of, i * chunk_time);
if (ret)
old_pos = pos;
}
num_chunks = i - 1;
- afi->chunk_table[i] = pos;
+//fi->chunk_table[i] = pos;
PARA_INFO_LOG("%lu chunks (%fs), max chunk: %zd, min chunk: %zd\n",
num_chunks, chunk_time, max_chunk_len, min);
return num_chunks;
struct audio_format_info *afi)
{
int ret;
- double time_total;
vorbis_info *vi;
- ogg_int64_t raw_total;
- long vi_sampling_rate, vi_bitrate;
OggVorbis_File of;
const ov_callbacks ovc = {
.read_func = cb_read,
vi = ov_info(&of, 0);
if (!vi)
goto err;
- time_total = ov_time_total(&of, -1);
- raw_total = ov_raw_total(&of, -1);
- afi->seconds_total = time_total;
- vi_sampling_rate = vi->rate;
- vi_bitrate = ov_bitrate(&of, 0);
- afi->chunks_total = ogg_compute_chunk_table(&of, afi, time_total);
- sprintf(afi->info_string, "audio_file_info1:%lu x %lu, %ldkHz, "
- "%d channels, %ldkbps\n"
+ afi->seconds_total = ov_time_total(&of, -1);
+ afi->frequency = vi->rate;
+ afi->bitrate = ov_bitrate(&of, 0);
+ afi->channels = vi->channels;
+ afi->chunks_total = ogg_compute_chunk_table(&of, afi, afi->seconds_total);
+ sprintf(afi->info_string, "audio_file_info1:%lu x %lu, %ukHz, "
+ "%d channels, %ukbps\n"
"audio_file_info2: \n"
"audio_file_info3: \n",
afi->chunks_total, (long unsigned) (chunk_time * 1000 * 1000),
- vi_sampling_rate / 1000, vi->channels, vi_bitrate / 1000
+ afi->frequency / 1000, vi->channels, afi->bitrate / 1000
);
afi->chunk_tv.tv_sec = 0;
afi->chunk_tv.tv_usec = 250 * 1000;