void test_get_format_name(void **state) { char *formatName = get_format_name('t'); assert_string_equal(formatName, TextFormatName); formatName = get_format_name('c'); assert_string_equal(formatName, TextFormatName); formatName = get_format_name('b'); assert_string_equal(formatName, GpdbWritableFormatName); MemoryContext old_context = CurrentMemoryContext; PG_TRY(); { formatName = get_format_name('x'); assert_false("Expected Exception"); } PG_CATCH(); { ErrorData *edata; MemoryContextSwitchTo(old_context); edata = CopyErrorData(); FlushErrorState(); assert_string_equal(edata->message, "Unable to get format name for format code: x"); } PG_END_TRY(); }
void generic_packetizer_c::show_experimental_status_version(std::string const &codec_id) { auto idx = get_format_name().get_untranslated(); if (s_experimental_status_warning_shown[idx]) return; s_experimental_status_warning_shown[idx] = true; mxwarn(boost::format(Y("Note that the Matroska specifications regarding the storage of '%1%' have not been finalized yet. " "mkvmerge's support for it is therefore subject to change and uses the CodecID '%2%/EXPERIMENTAL' instead of '%2%'. " "This warning will be removed once the specifications have been finalized and mkvmerge has been updated accordingly.\n")) % get_format_name().get_translated() % codec_id); }
void test__get_format_name(void **state) { char fmtcode = 't'; char *formatName = get_format_name(fmtcode); assert_string_equal(TextFormatName, formatName); fmtcode = 'c'; formatName = get_format_name(fmtcode); assert_string_equal(TextFormatName, formatName); fmtcode = 'b'; formatName = get_format_name(fmtcode); assert_string_equal(GpdbWritableFormatName, formatName); }
static void wavinfo_print(WavInfo *wi) { char *type; int samples, leftover; float playtime; PcmFile *wf = &wi->wf; type = get_format_name(wf->internal_fmt); printf("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n"); printf("File:\n"); printf(" Name: %s\n", wi->fname); if(wf->seekable) { printf(" File Size: %"PRIu64"\n", wf->file_size); } else { printf(" File Size: unknown\n"); } printf("Format:\n"); if(type == NULL) { printf(" Type: unknown - 0x%04X\n", wf->internal_fmt); } else { printf(" Type: %s\n", type); } printf(" Channels: %d\n", wf->channels); printf(" Sample Rate: %d Hz\n", wf->sample_rate); printf(" Avg bytes/sec: %d\n", wf->wav_bps); printf(" Block Align: %d bytes\n", wf->block_align); printf(" Bit Width: %d\n", wf->bit_width); printf("Data:\n"); printf(" Start: %"PRIu64"\n", wf->data_start); printf(" Data Size: %"PRIu64"\n", wf->data_size); leftover = wf->file_size - wf->data_size - wf->data_start; if(leftover < 0) { if(!wf->seekable) { printf(" [ warning! unable to verify true data size ]\n"); } else { printf(" [ warning! reported data size is larger than file size ]\n"); } } else if(leftover > 0) { printf(" Leftover: %d bytes\n", leftover); } if(wf->internal_fmt == 0x0001 || wf->internal_fmt == 0x0003) { samples = wf->data_size / wf->block_align; playtime = (float)samples / (float)wf->sample_rate; printf(" Samples: %d\n", samples); printf(" Playing Time: %0.2f sec\n", playtime); } else { printf(" Samples: unknown\n"); printf(" Playing Time: unknown\n"); } printf("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"); }
void Prog::draw_sample() { const int i = source_list.get_cur_value(); const int j = dest_list.get_cur_value(); ALLEGRO_BITMAP *bitmap1; ALLEGRO_BITMAP *bitmap2; bool use_memory = use_memory_button.get_pushed(); bool enable_timing = enable_timing_button.get_pushed(); if (use_memory) al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); else al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); al_set_new_bitmap_format(formats[i].format); bitmap1 = al_load_bitmap("data/allegro.pcx"); if (!bitmap1) { printf("Could not load image, bitmap format = %d\n", formats[i].format); } al_set_new_bitmap_format(formats[j].format); bitmap2 = al_create_bitmap(320, 200); if (!bitmap2) { printf("Could not create bitmap, format = %d\n", formats[j].format); } al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); if (bitmap1 && bitmap2) { ALLEGRO_BITMAP *target = al_get_target_bitmap(); al_set_target_bitmap(bitmap2); if (enable_timing) { double t0, t1; char str[256]; int frames = 0; t0 = al_get_time(); printf("Timing...\n"); do { al_draw_bitmap(bitmap1, 0, 0, 0); frames++; t1 = al_get_time(); } while (t1 - t0 < 0.25); printf(" ...done.\n"); sprintf(str, "%.0f FPS", (double)frames / (t1 - t0)); time_label.set_text(str); } else { al_draw_bitmap(bitmap1, 0, 0, 0); time_label.set_text(""); } al_set_target_bitmap(target); al_draw_bitmap(bitmap2, 0, 0, 0); } else { al_draw_line(0, 0, 320, 200, al_map_rgb_f(1, 0, 0), 0); al_draw_line(0, 200, 320, 0, al_map_rgb_f(1, 0, 0), 0); } std::string s = get_format_name(bitmap1); s += " -> "; s += get_format_name(bitmap2); true_formats.set_text(s); al_destroy_bitmap(bitmap1); al_destroy_bitmap(bitmap2); }
int main(int argc, char **argv) { int option_index = 0; int c,i; int ch = 2; int rate = 44100; char *mmap = "N"; char *device = "hw:0,0"; char *filename; int rc = 0; if (argc <2) { printf("\nUsage: aplay [options] <file>\n" "options:\n" "-D <hw:C,D> -- Alsa PCM by name\n" "-M -- Mmap stream\n" "-P -- Hostless steam[No PCM]\n" "-C -- Channels\n" "-R -- Rate\n" "-V -- verbose\n" "-F -- Format\n" "-B -- Period\n" "-T <MP3, AAC, AC3_PASS_THROUGH> -- Compressed\n" "<file> \n"); fprintf(stderr, "Formats Supported:\n"); for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; ++i) if (get_format_name(i)) fprintf(stderr, "%s ", get_format_name(i)); fprintf(stderr, "\nSome of these may not be available on selected hardware\n"); return 0; } while ((c = getopt_long(argc, argv, "PVMD:R:C:F:B:T:", long_options, &option_index)) != -1) { switch (c) { case 'P': pcm_flag = 0; break; case 'V': debug = 1; break; case 'M': mmap = "M"; break; case 'D': device = optarg; break; case 'R': rate = (int)strtol(optarg, NULL, 0); break; case 'C': ch = (int)strtol(optarg, NULL, 0); break; case 'F': printf("optarg = %s\n", optarg); format = get_format(optarg); break; case 'B': period = (int)strtol(optarg, NULL, 0); break; case 'T': compressed = 1; printf("compressed codec type requested = %s\n", optarg); compr_codec = optarg; break; default: printf("\nUsage: aplay [options] <file>\n" "options:\n" "-D <hw:C,D> -- Alsa PCM by name\n" "-M -- Mmap stream\n" "-P -- Hostless steam[No PCM]\n" "-V -- verbose\n" "-C -- Channels\n" "-R -- Rate\n" "-F -- Format\n" "-B -- Period\n" "-T -- Compressed\n" "<file> \n"); fprintf(stderr, "Formats Supported:\n"); for (i = 0; i < SNDRV_PCM_FORMAT_LAST; ++i) if (get_format_name(i)) fprintf(stderr, "%s ", get_format_name(i)); fprintf(stderr, "\nSome of these may not be available on selected hardware\n"); return -EINVAL; } } filename = (char*) calloc(1, 30); if (!filename) { fprintf(stderr, "Aplay:Failed to allocate filename!"); return -ENOMEM; } if (optind > argc - 1) { free(filename); filename = NULL; } else { strlcpy(filename, argv[optind++], 30); } if (pcm_flag) { if (format == SNDRV_PCM_FORMAT_S16_LE) rc = play_wav(mmap, rate, ch, device, filename); else rc = play_raw(mmap, rate, ch, device, filename); } else { rc = play_wav(mmap, rate, ch, device, "dummy"); } if (filename) free(filename); return rc; }
void generic_reader_c::id_result_container(const std::vector<std::string> &verbose_info) { m_id_results_container.info = get_format_name().get_translated(); m_id_results_container.verbose_info = verbose_info; m_id_results_container.verbose_info.push_back((boost::format("is_providing_timecodes:%1%") % (is_providing_timecodes() ? 1 : 0)).str()); }
/* * Add key/value pairs to connection header. * These values are the context of the query and used * by the remote component. */ void build_http_header(PxfInputData *input) { extvar_t ev; CHURL_HEADERS headers = input->headers; GPHDUri *gphduri = input->gphduri; Relation rel = input->rel; char *filterstr = input->filterstr; ProjectionInfo *proj_info = input->proj_info; if (rel != NULL) { /* format */ ExtTableEntry *exttbl = GetExtTableEntry(rel->rd_id); /* pxf treats CSV as TEXT */ char* format = get_format_name(exttbl->fmtcode); churl_headers_append(headers, "X-GP-FORMAT", format); /* Record fields - name and type of each field */ add_tuple_desc_httpheader(headers, rel); } if (proj_info != NULL && proj_info->pi_isVarList) { List* qualsAttributes = extractPxfAttributes(input->quals); /* projection information is incomplete if columns from WHERE clause wasn't extracted */ if (qualsAttributes != NIL || list_length(input->quals) == 0) { add_projection_desc_httpheader(headers, proj_info, qualsAttributes); } else elog(DEBUG2, "Query will not be optimized to use projection information"); } /* GP cluster configuration */ external_set_env_vars(&ev, gphduri->uri, false, NULL, NULL, false, 0); churl_headers_append(headers, "X-GP-SEGMENT-ID", ev.GP_SEGMENT_ID); churl_headers_append(headers, "X-GP-SEGMENT-COUNT", ev.GP_SEGMENT_COUNT); churl_headers_append(headers, "X-GP-XID", ev.GP_XID); /* Report alignment size to remote component * GPDBWritable uses alignment that has to be the same as * in the C code. * Since the C code can be compiled for both 32 and 64 bits, * the alignment can be either 4 or 8. */ add_alignment_size_httpheader(headers); /* headers for uri data */ churl_headers_append(headers, "X-GP-URL-HOST", gphduri->host); churl_headers_append(headers, "X-GP-URL-PORT", gphduri->port); churl_headers_append(headers, "X-GP-DATA-DIR", gphduri->data); /* location options */ add_location_options_httpheader(headers, gphduri); /* full uri */ churl_headers_append(headers, "X-GP-URI", gphduri->uri); /* filters */ if (filterstr) { churl_headers_append(headers, "X-GP-HAS-FILTER", "1"); churl_headers_append(headers, "X-GP-FILTER", filterstr); } else churl_headers_append(headers, "X-GP-HAS-FILTER", "0"); add_delegation_token_headers(headers, input); add_remote_credentials(headers); }