src/tools/chdman.c
| r14652 | r14653 | |
| 52 | 52 | #include <ctype.h> |
| 53 | 53 | #include <new> |
| 54 | 54 | |
| 55 | | #define NUM_PROCESSORS_SUPPORTED 1 |
| 56 | 55 | |
| 56 | |
| 57 | 57 | //************************************************************************** |
| 58 | 58 | // CONSTANTS & DEFINES |
| 59 | 59 | //************************************************************************** |
| r14652 | r14653 | |
| 507 | 507 | { OPTION_INDEX, "ix", true, " <index>: indexed instance of this metadata tag" }, |
| 508 | 508 | { OPTION_VALUE_TEXT, "vt", true, " <text>: text for the metadata" }, |
| 509 | 509 | { OPTION_VALUE_FILE, "vf", true, " <file>: file containing data to add" }, |
| 510 | | #if NUM_PROCESSORS_SUPPORTED |
| 511 | 510 | { OPTION_NUMPROCESSORS, "np", true, " <processors>: limit the number of processors to use during compression" }, |
| 512 | | #endif |
| 513 | 511 | { OPTION_NO_CHECKSUM, "nocs", false, ": do not include this metadata information in the overall SHA-1" }, |
| 514 | 512 | { OPTION_FIX, "f", false, ": fix the SHA-1 if it is incorrect" }, |
| 515 | 513 | { OPTION_VERBOSE, "v", false, ": output additional information" }, |
| r14652 | r14653 | |
| 546 | 544 | REQUIRED OPTION_HUNK_SIZE, |
| 547 | 545 | REQUIRED OPTION_UNIT_SIZE, |
| 548 | 546 | OPTION_COMPRESSION, |
| 549 | | #if NUM_PROCESSORS_SUPPORTED |
| 550 | 547 | OPTION_NUMPROCESSORS |
| 551 | | #endif |
| 552 | 548 | } |
| 553 | 549 | }, |
| 554 | 550 | |
| r14652 | r14653 | |
| 567 | 563 | OPTION_IDENT, |
| 568 | 564 | OPTION_CHS, |
| 569 | 565 | OPTION_SECTOR_SIZE, |
| 570 | | #if NUM_PROCESSORS_SUPPORTED |
| 571 | 566 | OPTION_NUMPROCESSORS |
| 572 | | #endif |
| 573 | 567 | } |
| 574 | 568 | }, |
| 575 | 569 | |
| r14652 | r14653 | |
| 581 | 575 | REQUIRED OPTION_INPUT, |
| 582 | 576 | OPTION_HUNK_SIZE, |
| 583 | 577 | OPTION_COMPRESSION, |
| 584 | | #if NUM_PROCESSORS_SUPPORTED |
| 585 | 578 | OPTION_NUMPROCESSORS |
| 586 | | #endif |
| 587 | 579 | } |
| 588 | 580 | }, |
| 589 | 581 | |
| r14652 | r14653 | |
| 597 | 589 | OPTION_INPUT_LENGTH_FRAMES, |
| 598 | 590 | OPTION_HUNK_SIZE, |
| 599 | 591 | OPTION_COMPRESSION, |
| 600 | | #if NUM_PROCESSORS_SUPPORTED |
| 601 | 592 | OPTION_NUMPROCESSORS |
| 602 | | #endif |
| 603 | 593 | } |
| 604 | 594 | }, |
| 605 | 595 | |
| r14652 | r14653 | |
| 663 | 653 | OPTION_INPUT_LENGTH_HUNKS, |
| 664 | 654 | OPTION_HUNK_SIZE, |
| 665 | 655 | OPTION_COMPRESSION, |
| 666 | | #if NUM_PROCESSORS_SUPPORTED |
| 667 | 656 | OPTION_NUMPROCESSORS |
| 668 | | #endif |
| 669 | 657 | } |
| 670 | 658 | }, |
| 671 | 659 | |
| r14652 | r14653 | |
| 1096 | 1084 | |
| 1097 | 1085 | static void parse_numprocessors(const parameters_t ¶ms) |
| 1098 | 1086 | { |
| 1099 | | #if NUM_PROCESSORS_SUPPORTED |
| 1100 | 1087 | astring *numprocessors_str = params.find(OPTION_NUMPROCESSORS); |
| 1101 | 1088 | if (numprocessors_str == NULL) |
| 1102 | 1089 | return; |
| r14652 | r14653 | |
| 1107 | 1094 | extern int osd_num_processors; |
| 1108 | 1095 | osd_num_processors = count; |
| 1109 | 1096 | } |
| 1110 | | #endif |
| 1111 | 1097 | } |
| 1112 | 1098 | |
| 1113 | 1099 | |
| r14652 | r14653 | |
| 1552 | 1538 | printf("Logical size: %s\n", big_int_string(tempstr, input_end - input_start)); |
| 1553 | 1539 | |
| 1554 | 1540 | // catch errors so we can close & delete the output file |
| 1555 | | chd_rawfile_compressor* chd = NULL; |
| 1541 | chd_rawfile_compressor *chd = NULL; |
| 1556 | 1542 | try |
| 1557 | 1543 | { |
| 1558 | 1544 | // create the new CHD |
| r14652 | r14653 | |
| 1579 | 1565 | astring *output_chd_str = params.find(OPTION_OUTPUT); |
| 1580 | 1566 | if (output_chd_str != NULL) |
| 1581 | 1567 | osd_rmfile(*output_chd_str); |
| 1582 | | if (chd != NULL) |
| 1583 | | delete chd; |
| 1568 | delete chd; |
| 1584 | 1569 | throw; |
| 1585 | 1570 | } |
| 1586 | 1571 | } |
| r14652 | r14653 | |
| 1714 | 1699 | printf("Logical size: %s\n", big_int_string(tempstr, UINT64(totalsectors) * UINT64(sector_size))); |
| 1715 | 1700 | |
| 1716 | 1701 | // catch errors so we can close & delete the output file |
| 1702 | chd_rawfile_compressor *chd = NULL; |
| 1717 | 1703 | try |
| 1718 | 1704 | { |
| 1719 | 1705 | // create the new hard drive |
| 1720 | | chd_rawfile_compressor chd(input_file, input_start, input_end); |
| 1706 | chd = new chd_rawfile_compressor(input_file, input_start, input_end); |
| 1721 | 1707 | chd_error err; |
| 1722 | 1708 | if (output_parent.opened()) |
| 1723 | | err = chd.create(*output_chd_str, UINT64(totalsectors) * UINT64(sector_size), hunk_size, compression, output_parent); |
| 1709 | err = chd->create(*output_chd_str, UINT64(totalsectors) * UINT64(sector_size), hunk_size, compression, output_parent); |
| 1724 | 1710 | else |
| 1725 | | err = chd.create(*output_chd_str, UINT64(totalsectors) * UINT64(sector_size), hunk_size, sector_size, compression); |
| 1711 | err = chd->create(*output_chd_str, UINT64(totalsectors) * UINT64(sector_size), hunk_size, sector_size, compression); |
| 1726 | 1712 | if (err != CHDERR_NONE) |
| 1727 | 1713 | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->cstr(), chd_file::error_string(err)); |
| 1728 | 1714 | |
| 1729 | 1715 | // add the standard hard disk metadata |
| 1730 | 1716 | astring metadata; |
| 1731 | 1717 | metadata.format(HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sector_size); |
| 1732 | | err = chd.write_metadata(HARD_DISK_METADATA_TAG, 0, metadata); |
| 1718 | err = chd->write_metadata(HARD_DISK_METADATA_TAG, 0, metadata); |
| 1733 | 1719 | if (err != CHDERR_NONE) |
| 1734 | 1720 | report_error(1, "Error adding hard disk metadata: %s", chd_file::error_string(err)); |
| 1735 | 1721 | |
| 1736 | 1722 | // write the ident if present |
| 1737 | 1723 | if (identdata.count() > 0) |
| 1738 | 1724 | { |
| 1739 | | err = chd.write_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, identdata); |
| 1725 | err = chd->write_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, identdata); |
| 1740 | 1726 | if (err != CHDERR_NONE) |
| 1741 | 1727 | report_error(1, "Error adding hard disk metadata: %s", chd_file::error_string(err)); |
| 1742 | 1728 | } |
| 1743 | 1729 | |
| 1744 | 1730 | // compress it generically |
| 1745 | 1731 | if (input_file != NULL) |
| 1746 | | compress_common(chd); |
| 1732 | compress_common(*chd); |
| 1733 | delete chd; |
| 1747 | 1734 | } |
| 1748 | 1735 | catch (...) |
| 1749 | 1736 | { |
| r14652 | r14653 | |
| 1751 | 1738 | astring *output_chd_str = params.find(OPTION_OUTPUT); |
| 1752 | 1739 | if (output_chd_str != NULL) |
| 1753 | 1740 | osd_rmfile(*output_chd_str); |
| 1741 | delete chd; |
| 1754 | 1742 | throw; |
| 1755 | 1743 | } |
| 1756 | 1744 | } |
| r14652 | r14653 | |
| 1814 | 1802 | printf("Logical size: %s\n", big_int_string(tempstr, UINT64(totalsectors) * CD_FRAME_SIZE)); |
| 1815 | 1803 | |
| 1816 | 1804 | // catch errors so we can close & delete the output file |
| 1817 | | chd_cd_compressor* chd = NULL; |
| 1805 | chd_cd_compressor *chd = NULL; |
| 1818 | 1806 | try |
| 1819 | 1807 | { |
| 1820 | 1808 | // create the new CD |
| r14652 | r14653 | |
| 1842 | 1830 | astring *output_chd_str = params.find(OPTION_OUTPUT); |
| 1843 | 1831 | if (output_chd_str != NULL) |
| 1844 | 1832 | osd_rmfile(*output_chd_str); |
| 1845 | | if (chd != NULL) |
| 1846 | | delete chd; |
| 1833 | delete chd; |
| 1847 | 1834 | throw; |
| 1848 | 1835 | } |
| 1849 | 1836 | } |
| r14652 | r14653 | |
| 1930 | 1917 | printf("Logical size: %s\n", big_int_string(tempstr, UINT64(input_end - input_start) * hunk_size)); |
| 1931 | 1918 | |
| 1932 | 1919 | // catch errors so we can close & delete the output file |
| 1933 | | chd_avi_compressor* chd = NULL; |
| 1920 | chd_avi_compressor *chd = NULL; |
| 1934 | 1921 | try |
| 1935 | 1922 | { |
| 1936 | 1923 | // create the new CHD |
| r14652 | r14653 | |
| 1968 | 1955 | astring *output_chd_str = params.find(OPTION_OUTPUT); |
| 1969 | 1956 | if (output_chd_str != NULL) |
| 1970 | 1957 | osd_rmfile(*output_chd_str); |
| 1971 | | if (chd != NULL) |
| 1972 | | delete chd; |
| 1958 | delete chd; |
| 1973 | 1959 | throw; |
| 1974 | 1960 | } |
| 1975 | 1961 | } |
| r14652 | r14653 | |
| 2038 | 2024 | printf("Logical size: %s\n", big_int_string(tempstr, input_end - input_start)); |
| 2039 | 2025 | |
| 2040 | 2026 | // catch errors so we can close & delete the output file |
| 2041 | | chd_chdfile_compressor* chd = NULL; |
| 2027 | chd_chdfile_compressor *chd = NULL; |
| 2042 | 2028 | try |
| 2043 | 2029 | { |
| 2044 | 2030 | // create the new CHD |
| r14652 | r14653 | |
| 2094 | 2080 | astring *output_chd_str = params.find(OPTION_OUTPUT); |
| 2095 | 2081 | if (output_chd_str != NULL) |
| 2096 | 2082 | osd_rmfile(*output_chd_str); |
| 2097 | | if (chd != NULL) |
| 2098 | | delete chd; |
| 2083 | delete chd; |
| 2099 | 2084 | throw; |
| 2100 | 2085 | } |
| 2101 | 2086 | } |
| r14652 | r14653 | |
| 2251 | 2236 | const cdrom_track_info &trackinfo = toc->tracks[tracknum]; |
| 2252 | 2237 | output_track_metadata(cuemode, output_toc_file, tracknum, trackinfo, *output_bin_file_str, discoffs, outputoffs); |
| 2253 | 2238 | |
| 2254 | | UINT32 output_frame_size; |
| 2255 | | |
| 2256 | 2239 | // If this is bin/cue output and the CHD contains subdata, warn the user and don't include |
| 2257 | 2240 | // the subdata size in the buffer calculation. |
| 2258 | | if ((trackinfo.subtype != CD_SUB_NONE) && (cuemode)) |
| 2241 | UINT32 output_frame_size = trackinfo.datasize + ((trackinfo.subtype != CD_SUB_NONE) ? trackinfo.subsize : 0); |
| 2242 | if (trackinfo.subtype != CD_SUB_NONE && cuemode) |
| 2259 | 2243 | { |
| 2260 | 2244 | printf("Warning: Track %d has subcode data. bin/cue format cannot contain subcode data and it will be omitted.\n", tracknum+1); |
| 2261 | 2245 | printf(" : This may affect usage of the output image. Use bin/toc output to keep all data.\n"); |
| 2262 | | |
| 2263 | 2246 | output_frame_size = trackinfo.datasize; |
| 2264 | 2247 | } |
| 2265 | | else |
| 2266 | | { |
| 2267 | | output_frame_size = trackinfo.datasize + ((trackinfo.subtype != CD_SUB_NONE) ? trackinfo.subsize : 0); |
| 2268 | | } |
| 2269 | 2248 | |
| 2270 | 2249 | // resize the buffer for the track |
| 2271 | 2250 | buffer.resize((TEMP_BUFFER_SIZE / output_frame_size) * output_frame_size); |
| r14652 | r14653 | |
| 2291 | 2270 | discoffs++; |
| 2292 | 2271 | |
| 2293 | 2272 | // read the subcode data |
| 2294 | | if ((trackinfo.subtype != CD_SUB_NONE) && (!cuemode)) |
| 2273 | if (trackinfo.subtype != CD_SUB_NONE && !cuemode) |
| 2295 | 2274 | { |
| 2296 | 2275 | cdrom_read_subcode(cdrom, cdrom_get_track_start(cdrom, tracknum) + frame, &buffer[bufferoffs]); |
| 2297 | 2276 | bufferoffs += trackinfo.subsize; |
src/emu/sound.c
| r14652 | r14653 | |
| 786 | 786 | if (m_nosound_mode && wavfile[0] == 0 && avifile[0] == 0) |
| 787 | 787 | machine.m_sample_rate = 11025; |
| 788 | 788 | |
| 789 | | // count the speakers |
| 789 | // count the mixers |
| 790 | 790 | #if VERBOSE |
| 791 | | speaker_device_iterator iter(machine.root_device()); |
| 792 | | VPRINTF(("total speakers = %d\n", iter.count())); |
| 791 | mixer_interface_iterator iter(machine.root_device()); |
| 792 | VPRINTF(("total mixers = %d\n", iter.count())); |
| 793 | 793 | #endif |
| 794 | 794 | |
| 795 | 795 | // allocate memory for mix buffers |
| r14652 | r14653 | |
| 856 | 856 | |
| 857 | 857 | |
| 858 | 858 | //------------------------------------------------- |
| 859 | | // indexed_speaker_input - return the speaker |
| 860 | | // device and input index of the global speaker |
| 859 | // indexed_mixer_input - return the mixer |
| 860 | // device and input index of the global mixer |
| 861 | 861 | // input |
| 862 | 862 | //------------------------------------------------- |
| 863 | 863 | |
| 864 | | bool sound_manager::indexed_speaker_input(int index, speaker_input &info) const |
| 864 | bool sound_manager::indexed_mixer_input(int index, mixer_input &info) const |
| 865 | 865 | { |
| 866 | | // scan through the speakers until we find the indexed input |
| 867 | | speaker_device_iterator iter(machine().root_device()); |
| 868 | | for (info.speaker = iter.first(); info.speaker != NULL; info.speaker = iter.next()) |
| 866 | // scan through the mixers until we find the indexed input |
| 867 | mixer_interface_iterator iter(machine().root_device()); |
| 868 | for (info.mixer = iter.first(); info.mixer != NULL; info.mixer = iter.next()) |
| 869 | 869 | { |
| 870 | | if (index < info.speaker->inputs()) |
| 870 | if (index < info.mixer->inputs()) |
| 871 | 871 | { |
| 872 | | info.stream = info.speaker->input_to_stream_input(index, info.inputnum); |
| 872 | info.stream = info.mixer->input_to_stream_input(index, info.inputnum); |
| 873 | 873 | assert(info.stream != NULL); |
| 874 | 874 | return true; |
| 875 | 875 | } |
| 876 | | index -= info.speaker->inputs(); |
| 876 | index -= info.mixer->inputs(); |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | // didn't locate |
| r14652 | r14653 | |
| 946 | 946 | // iterate over channel nodes |
| 947 | 947 | for (xml_data_node *channelnode = xml_get_sibling(parentnode->child, "channel"); channelnode != NULL; channelnode = xml_get_sibling(channelnode->next, "channel")) |
| 948 | 948 | { |
| 949 | | speaker_input info; |
| 950 | | if (indexed_speaker_input(xml_get_attribute_int(channelnode, "index", -1), info)) |
| 949 | mixer_input info; |
| 950 | if (indexed_mixer_input(xml_get_attribute_int(channelnode, "index", -1), info)) |
| 951 | 951 | { |
| 952 | 952 | float defvol = xml_get_attribute_float(channelnode, "defvol", -1000.0); |
| 953 | 953 | float newvol = xml_get_attribute_float(channelnode, "newvol", -1000.0); |
| r14652 | r14653 | |
| 973 | 973 | if (parentnode != NULL) |
| 974 | 974 | for (int mixernum = 0; ; mixernum++) |
| 975 | 975 | { |
| 976 | | speaker_input info; |
| 977 | | if (!indexed_speaker_input(mixernum, info)) |
| 976 | mixer_input info; |
| 977 | if (!indexed_mixer_input(mixernum, info)) |
| 978 | 978 | break; |
| 979 | 979 | float defvol = info.stream->initial_input_gain(info.inputnum); |
| 980 | 980 | float newvol = info.stream->input_gain(info.inputnum); |