fprintf(stderr, "sample rate : %u Hz\n", sample_rate);
fprintf(stderr, "channels : %u\n", channels);
fprintf(stderr, "bits per sample: %u\n", bps);
-#ifdef _MSC_VER
- fprintf(stderr, "total samples : %I64u\n", total_samples);
-#else
- fprintf(stderr, "total samples : %llu\n", total_samples);
-#endif
+ fprintf(stderr, "total samples : %" PRIu64 "\n", total_samples);
}
}
channels = 2;
bps = 16;
total_samples = (((((((unsigned)buffer[43] << 8) | buffer[42]) << 8) | buffer[41]) << 8) | buffer[40]) / 4;
-
+
/* allocate the encoder */
if((encoder = FLAC__stream_encoder_new()) == NULL) {
fprintf(stderr, "ERROR: allocating encoder\n");
{
(void)encoder, (void)client_data;
-#ifdef _MSC_VER
- fprintf(stderr, "wrote %I64u bytes, %I64u/%u samples, %u/%u frames\n", bytes_written, samples_written, total_samples, frames_written, total_frames_estimate);
-#else
- fprintf(stderr, "wrote %llu bytes, %llu/%u samples, %u/%u frames\n", bytes_written, samples_written, total_samples, frames_written, total_frames_estimate);
-#endif
+ fprintf(stderr, "wrote %" PRIu64 " bytes, %" PRIu64 "/%u samples, %u/%u frames\n", bytes_written, samples_written, total_samples, frames_written, total_frames_estimate);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <inttypes.h>
#include "FLAC/all.h"
#include "analyze.h"
unsigned i, channel, partitions;
/* do the human-readable part first */
-#ifdef _MSC_VER
- fprintf(fout, "frame=%u\toffset=%I64u\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
-#else
- fprintf(fout, "frame=%u\toffset=%llu\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, (unsigned long long)frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
-#endif
+ fprintf(fout, "frame=%u\toffset=%" PRIu64 "\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, (uint64_t)frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
for(channel = 0; channel < channels; channel++) {
const FLAC__Subframe *subframe = frame->subframes+channel;
const FLAC__bool is_rice2 = subframe->data.fixed.entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2;
fprintf(stderr, "ERROR reading %s\n", fn);
return 1;
}
-#ifdef _MSC_VER
- printf(" RIFF size=%016I64x=(%I64u)", unpack64le_(buf+8), unpack64le_(buf+8));
- printf(" data size=%016I64x=(%I64u)", unpack64le_(buf+16), unpack64le_(buf+16));
- printf(" sample count=%016I64x=(%I64u)", unpack64le_(buf+24), unpack64le_(buf+24));
-#else
- printf(" RIFF size=%016llx=(%llu)", unpack64le_(buf+8), unpack64le_(buf+8));
- printf(" data size=%016llx=(%llu)", unpack64le_(buf+16), unpack64le_(buf+16));
- printf(" sample count=%016llx=(%llu)", unpack64le_(buf+24), unpack64le_(buf+24));
-#endif
+ printf(" RIFF size=%016" PRIx64 "=(" PRIu64 ")", unpack64le_(buf+8), unpack64le_(buf+8));
+ printf(" data size=%016" PRIx64 "=(" PRIu64 ")", unpack64le_(buf+16), unpack64le_(buf+16));
+ printf(" sample count=%016" PRIx64 "=(" PRIu64 ")", unpack64le_(buf+24), unpack64le_(buf+24));
printf(" table size=%08x=(%u)", unpack32le_(buf+32), unpack32le_(buf+32));
}
printf("\n");
PPR; printf(" sample_rate: %u Hz\n", block->data.stream_info.sample_rate);
PPR; printf(" channels: %u\n", block->data.stream_info.channels);
PPR; printf(" bits-per-sample: %u\n", block->data.stream_info.bits_per_sample);
-#ifdef _MSC_VER
- PPR; printf(" total samples: %I64u\n", block->data.stream_info.total_samples);
-#else
- PPR; printf(" total samples: %llu\n", (unsigned long long)block->data.stream_info.total_samples);
-#endif
+ PPR; printf(" total samples: %" PRIu64 "\n", (uint64_t)block->data.stream_info.total_samples);
PPR; printf(" MD5 signature: ");
for(i = 0; i < 16; i++) {
printf("%02x", (unsigned)block->data.stream_info.md5sum[i]);
PPR; printf(" seek points: %u\n", block->data.seek_table.num_points);
for(i = 0; i < block->data.seek_table.num_points; i++) {
if(block->data.seek_table.points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) {
-#ifdef _MSC_VER
- PPR; printf(" point %u: sample_number=%I64u, stream_offset=%I64u, frame_samples=%u\n", i, block->data.seek_table.points[i].sample_number, block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
-#else
- PPR; printf(" point %u: sample_number=%llu, stream_offset=%llu, frame_samples=%u\n", i, (unsigned long long)block->data.seek_table.points[i].sample_number, (unsigned long long)block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
-#endif
+ PPR; printf(" point %u: sample_number=%" PRIu64 ", stream_offset=%" PRIu64 ", frame_samples=%u\n", i, (uint64_t)block->data.seek_table.points[i].sample_number, (uint64_t)block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
}
else {
PPR; printf(" point %u: PLACEHOLDER\n", i);
break;
case FLAC__METADATA_TYPE_CUESHEET:
PPR; printf(" media catalog number: %s\n", block->data.cue_sheet.media_catalog_number);
-#ifdef _MSC_VER
- PPR; printf(" lead-in: %I64u\n", block->data.cue_sheet.lead_in);
-#else
- PPR; printf(" lead-in: %llu\n", (unsigned long long)block->data.cue_sheet.lead_in);
-#endif
+ PPR; printf(" lead-in: %" PRIu64 "\n", (uint64_t)block->data.cue_sheet.lead_in);
PPR; printf(" is CD: %s\n", block->data.cue_sheet.is_cd? "true":"false");
PPR; printf(" number of tracks: %u\n", block->data.cue_sheet.num_tracks);
for(i = 0; i < block->data.cue_sheet.num_tracks; i++) {
const FLAC__bool is_last = (i == block->data.cue_sheet.num_tracks-1);
const FLAC__bool is_leadout = is_last && track->num_indices == 0;
PPR; printf(" track[%u]\n", i);
-#ifdef _MSC_VER
- PPR; printf(" offset: %I64u\n", track->offset);
-#else
- PPR; printf(" offset: %llu\n", (unsigned long long)track->offset);
-#endif
+ PPR; printf(" offset: %" PRIu64 "\n", (uint64_t)track->offset);
if(is_last) {
PPR; printf(" number: %u (%s)\n", (unsigned)track->number, is_leadout? "LEAD-OUT" : "INVALID");
}
for(j = 0; j < track->num_indices; j++) {
const FLAC__StreamMetadata_CueSheet_Index *index = track->indices+j;
PPR; printf(" index[%u]\n", j);
-#ifdef _MSC_VER
- PPR; printf(" offset: %I64u\n", index->offset);
-#else
- PPR; printf(" offset: %llu\n", (unsigned long long)index->offset);
-#endif
+ PPR; printf(" offset: %" PRIu64 "\n", (uint64_t)index->offset);
PPR; printf(" number: %u\n", (unsigned)index->number);
}
}
for(track = 0; track < cs->num_tracks; track++) {
const FLAC__StreamMetadata_CueSheet_Track *tr = cs->tracks+track;
for(index = 0; index < tr->num_indices; index++) {
-#ifdef _MSC_VER
- sprintf(spec, "%I64u;", tr->offset + tr->indices[index].offset);
-#else
- sprintf(spec, "%llu;", (unsigned long long)(tr->offset + tr->indices[index].offset));
-#endif
+ sprintf(spec, "%" PRIu64 "u;", (uint64_t)(tr->offset + tr->indices[index].offset));
local_strcat(seekpoint_specification, spec);
}
}
printf("%u\n", block->data.stream_info.bits_per_sample);
break;
case OP__SHOW_TOTAL_SAMPLES:
-#ifdef _MSC_VER
- printf("%I64u\n", block->data.stream_info.total_samples);
-#else
- printf("%llu\n", (unsigned long long)block->data.stream_info.total_samples);
-#endif
+ printf("%" PRIu64 "\n", (uint64_t)block->data.stream_info.total_samples);
break;
case OP__SET_MD5SUM:
memcpy(block->data.stream_info.md5sum, operation->argument.streaminfo_md5.value, 16);
{
(void)w;
(void)data;
-
+
FLAC_plugin__tags_delete_tag(tags_, "TITLE");
FLAC_plugin__tags_delete_tag(tags_, "ARTIST");
FLAC_plugin__tags_delete_tag(tags_, "ALBUM");
label_set_text(flac_blocksize, _("Blocksize: variable\n min/max: %d/%d"), streaminfo.data.stream_info.min_blocksize, streaminfo.data.stream_info.max_blocksize);
if (streaminfo.data.stream_info.total_samples)
- label_set_text(flac_samples, _("Samples: %llu\nLength: %d:%.2d"),
+ label_set_text(flac_samples, _("Samples: %" PRIu64 "\nLength: %d:%.2d"),
streaminfo.data.stream_info.total_samples,
(int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate / 60),
(int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate % 60));
if(!stat(current_filename, &_stat) && S_ISREG(_stat.st_mode)) {
-#if _FILE_OFFSET_BITS == 64
- label_set_text(flac_filesize, _("Filesize: %lld B"), _stat.st_size);
-#else
- label_set_text(flac_filesize, _("Filesize: %ld B"), _stat.st_size);
-#endif
+ label_set_text(flac_filesize, _("Filesize: %zd B"), _stat.st_size);
if (streaminfo.data.stream_info.total_samples)
label_set_text(flac_bitrate, _("Avg. bitrate: %.1f kb/s\nCompression ratio: %.1f%%"),
8.0 * (float)(_stat.st_size) / (1000.0 * (float)streaminfo.data.stream_info.total_samples / (float)streaminfo.data.stream_info.sample_rate),
res = g_strdup_printf("%s: Basic %s\r\n", header, t2);
g_free(t2);
g_free(t1);
-
+
return res;
}
*port = 80;
}
*host = g_strdup(h);
-
+
if (f)
*filename = g_strdup(f + 1);
else
do
{
redirect=FALSE;
-
+
g_strstrip(url);
parse_url(url, &user, &pass, &host, &port, &filename);
flac_ip.set_info_text(NULL);
eof = TRUE;
-
+
}
break;
}
if (flac_cfg.stream.use_udp_channel)
{
udp_port = udp_establish_listener (&udp_sock);
- if (udp_port > 0)
+ if (udp_port > 0)
sprintf (udpspace, "x-audiocast-udpport: %d\r\n", udp_port);
else
udp_sock = 0;
}
-
+
if(user && pass)
auth = basic_authentication_encode(user, pass, "Authorization");
"Host: %s\r\n"
"User-Agent: %s/%s\r\n"
"%s%s%s%s",
- file, host, "Reference FLAC Player", FLAC__VERSION_STRING,
+ file, host, "Reference FLAC Player", FLAC__VERSION_STRING,
proxy_auth ? proxy_auth : "", auth ? auth : "",
flac_cfg.stream.cast_title_streaming ? "Icy-MetaData:1\r\n" : "",
flac_cfg.stream.use_udp_channel ? udpspace : "");
if (offset && !head) {
gchar *temp_dead = temp;
- temp = g_strdup_printf ("%sRange: %llu-\r\n", temp, offset);
+ temp = g_strdup_printf ("%sRange: %" PRIu64 "-\r\n", temp, offset);
fprintf (stderr, "%s", temp);
g_free (temp_dead);
}
-
+
g_free(file);
if(proxy_auth)
g_free(proxy_auth);
break;
}
}
- }
+ }
redirect=TRUE;
break;
}
#endif
/*udp_serverport = atoi (line + 20);*/
}
-
+
}
else
{
}
}
}
-
+
if(redirect)
{
if (output_file)
url = (gchar *) arg;
sock = http_connect (url, false, offset);
-
+
if (sock >= 0 && flac_cfg.stream.save_http_stream) {
gchar *output_name;
file = flac_http_get_title(url);
g_free(buffer);
g_free(url);
-
+
pthread_exit(NULL);
return NULL; /* avoid compiler warning */
}
{
struct sockaddr_in sin;
socklen_t sinlen = sizeof (struct sockaddr_in);
-
+
#ifdef DEBUG_UDP
fprintf (stderr,"Establishing udp listener\n");
#endif
-
+
if ((*sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
g_log(NULL, G_LOG_LEVEL_CRITICAL,
memset(&sin, 0, sinlen);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = g_htonl(INADDR_ANY);
-
+
if (bind(*sock, (struct sockaddr *)&sin, sinlen) < 0)
{
g_log(NULL, G_LOG_LEVEL_CRITICAL,
#ifdef DEBUG_UDP
fprintf (stderr,"Listening on local %s:%d\n", inet_ntoa(sin.sin_addr), g_ntohs(sin.sin_port));
#endif
-
+
return g_ntohs(sin.sin_port);
}
socklen_t fromlen;
fromlen = sizeof(struct sockaddr_in);
-
+
if ((len = recvfrom(sock, buf, 1024, 0, (struct sockaddr *)&from, &fromlen)) < 0)
{
if (errno != EAGAIN)
lines = g_strsplit(buf, "\n", 0);
if (!lines)
return 0;
-
+
for (i = 0; lines[i]; i++)
{
while ((lines[i][strlen(lines[i]) - 1] == '\n') ||
(lines[i][strlen(lines[i]) - 1] == '\r'))
lines[i][strlen(lines[i]) - 1] = '\0';
-
+
valptr = strchr(lines[i], ':');
-
+
if (!valptr)
continue;
else
valptr++;
-
+
g_strstrip(valptr);
if (!strlen(valptr))
continue;
-
+
if (strstr(lines[i], "x-audiocast-streamtitle") != NULL)
{
title = g_strdup_printf ("%s (%s)", valptr, icy_name);
set_track_info(NULL, atoi(valptr));
}
#endif
-
+
else if (strstr(lines[i], "x-audiocast-streammsg") != NULL)
{
/* set_track_info(title, -1); */
fprintf(file, "%02u:%02u:%02u\n", m, s, f);
}
else
-#ifdef _MSC_VER
- fprintf(file, "%I64u\n", track->offset + index->offset);
-#else
- fprintf(file, "%llu\n", (unsigned long long)(track->offset + index->offset));
-#endif
+ fprintf(file, "%" PRIu64 "\n", (uint64_t)(track->offset + index->offset));
}
}
-#ifdef _MSC_VER
- fprintf(file, "REM FLAC__lead-in %I64u\n", cs->lead_in);
- fprintf(file, "REM FLAC__lead-out %u %I64u\n", (unsigned)cs->tracks[track_num].number, cs->tracks[track_num].offset);
-#else
- fprintf(file, "REM FLAC__lead-in %llu\n", (unsigned long long)cs->lead_in);
- fprintf(file, "REM FLAC__lead-out %u %llu\n", (unsigned)cs->tracks[track_num].number, (unsigned long long)cs->tracks[track_num].offset);
-#endif
+ fprintf(file, "REM FLAC__lead-in %" PRIu64 "\n", (uint64_t)cs->lead_in);
+ fprintf(file, "REM FLAC__lead-out %u %" PRIu64 "\n", (unsigned)cs->tracks[track_num].number, (uint64_t)cs->tracks[track_num].offset);
}
printf("testing FLAC__stream_encoder_get_total_samples_estimate()... ");
if(FLAC__stream_encoder_get_total_samples_estimate(encoder) != streaminfo_.data.stream_info.total_samples) {
-#ifdef _MSC_VER
- printf("FAILED, expected %I64u, got %I64u\n", streaminfo_.data.stream_info.total_samples, FLAC__stream_encoder_get_total_samples_estimate(encoder));
-#else
- printf("FAILED, expected %llu, got %llu\n", (unsigned long long)streaminfo_.data.stream_info.total_samples, (unsigned long long)FLAC__stream_encoder_get_total_samples_estimate(encoder));
-#endif
+ printf("FAILED, expected %" PRIu64 ", got %" PRIu64 "\n", (uint64_t)streaminfo_.data.stream_info.total_samples, (uint64_t)FLAC__stream_encoder_get_total_samples_estimate(encoder));
return false;
}
printf("OK\n");
unsigned i;
if(from->offset != to->offset) {
-#ifdef _MSC_VER
- printf("FAILED, track offset mismatch, expected %I64u, got %I64u\n", to->offset, from->offset);
-#else
- printf("FAILED, track offset mismatch, expected %llu, got %llu\n", (unsigned long long)to->offset, (unsigned long long)from->offset);
-#endif
+ printf("FAILED, track offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", (uint64_t)to->offset, (uint64_t)from->offset);
return false;
}
if(from->number != to->number) {
else {
for(i = 0; i < to->num_indices; i++) {
if(from->indices[i].offset != to->indices[i].offset) {
-#ifdef _MSC_VER
- printf("FAILED, track indices[%u].offset mismatch, expected %I64u, got %I64u\n", i, to->indices[i].offset, from->indices[i].offset);
-#else
- printf("FAILED, track indices[%u].offset mismatch, expected %llu, got %llu\n", i, (unsigned long long)to->indices[i].offset, (unsigned long long)from->indices[i].offset);
-#endif
+ printf("FAILED, track indices[%u].offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, (uint64_t)to->indices[i].offset, (uint64_t)from->indices[i].offset);
return false;
}
if(from->indices[i].number != to->indices[i].number) {
for(i = 0; i < n; i++) {
if(from[i].sample_number != to[i].sample_number) {
-#ifdef _MSC_VER
- printf("FAILED, point[%u].sample_number mismatch, expected %I64u, got %I64u\n", i, to[i].sample_number, from[i].sample_number);
-#else
- printf("FAILED, point[%u].sample_number mismatch, expected %llu, got %llu\n", i, (unsigned long long)to[i].sample_number, (unsigned long long)from[i].sample_number);
-#endif
+ printf("FAILED, point[%u].sample_number mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, (uint64_t)to[i].sample_number, (uint64_t)from[i].sample_number);
return false;
}
if(from[i].stream_offset != to[i].stream_offset) {
-#ifdef _MSC_VER
- printf("FAILED, point[%u].stream_offset mismatch, expected %I64u, got %I64u\n", i, to[i].stream_offset, from[i].stream_offset);
-#else
- printf("FAILED, point[%u].stream_offset mismatch, expected %llu, got %llu\n", i, (unsigned long long)to[i].stream_offset, (unsigned long long)from[i].stream_offset);
-#endif
+ printf("FAILED, point[%u].stream_offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, (uint64_t)to[i].stream_offset, (uint64_t)from[i].stream_offset);
return false;
}
if(from[i].frame_samples != to[i].frame_samples) {
FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); /* decoder guarantees this */
if (!dcd->quiet)
-#ifdef _MSC_VER
- printf("frame@%I64u(%u)... ", frame->header.number.sample_number, frame->header.blocksize);
-#else
- printf("frame@%llu(%u)... ", (unsigned long long)frame->header.number.sample_number, frame->header.blocksize);
-#endif
+ printf("frame@%" PRIu64 "(%u)... ", (uint64_t)frame->header.number.sample_number, frame->header.blocksize);
fflush(stdout);
/* check against PCM data if we have it */
return die_s_("expected FLAC__STREAM_DECODER_END_OF_STREAM", decoder);
}
-#ifdef _MSC_VER
- printf("file's total_samples is %I64u\n", decoder_client_data.total_samples);
-#else
- printf("file's total_samples is %llu\n", (unsigned long long)decoder_client_data.total_samples);
-#endif
+ printf("file's total_samples is %" PRIu64 "\n", (uint64_t)decoder_client_data.total_samples);
n = (long int)decoder_client_data.total_samples;
if(n == 0 && total_samples >= 0)
pos = (FLAC__uint64)(local_rand_() % n);
}
-#ifdef _MSC_VER
- printf("#%u:seek(%I64u)... ", i, pos);
-#else
- printf("#%u:seek(%llu)... ", i, (unsigned long long)pos);
-#endif
+ printf("#%u:seek(%" PRIu64 ")... ", i, (uint64_t)pos);
fflush(stdout);
if(!FLAC__stream_decoder_seek_absolute(decoder, pos)) {
if(pos >= (FLAC__uint64)n)