Previous 15994 Revisions Next

r14653 Tuesday 28th February, 2012 at 11:54:45 UTC by Miodrag Milanović
Sync with MAME r15563 (nw)
[src/emu]disound.h schedule.c sound.c sound.h ui.c
[src/tools]chdman.c

src/tools/chdman.c
r14652r14653
5252#include <ctype.h>
5353#include <new>
5454
55#define NUM_PROCESSORS_SUPPORTED 1
5655
56
5757//**************************************************************************
5858//  CONSTANTS & DEFINES
5959//**************************************************************************
r14652r14653
507507   { OPTION_INDEX,               "ix",   true, " <index>: indexed instance of this metadata tag" },
508508   { OPTION_VALUE_TEXT,         "vt",   true, " <text>: text for the metadata" },
509509   { OPTION_VALUE_FILE,         "vf",   true, " <file>: file containing data to add" },
510#if NUM_PROCESSORS_SUPPORTED
511510   { OPTION_NUMPROCESSORS,         "np",   true, " <processors>: limit the number of processors to use during compression" },
512#endif
513511   { OPTION_NO_CHECKSUM,         "nocs",   false, ": do not include this metadata information in the overall SHA-1" },
514512   { OPTION_FIX,               "f",   false, ": fix the SHA-1 if it is incorrect" },
515513   { OPTION_VERBOSE,            "v",   false, ": output additional information" },
r14652r14653
546544         REQUIRED OPTION_HUNK_SIZE,
547545         REQUIRED OPTION_UNIT_SIZE,
548546         OPTION_COMPRESSION,
549#if NUM_PROCESSORS_SUPPORTED
550547         OPTION_NUMPROCESSORS
551#endif
552548      }
553549   },
554550
r14652r14653
567563         OPTION_IDENT,
568564         OPTION_CHS,
569565         OPTION_SECTOR_SIZE,
570#if NUM_PROCESSORS_SUPPORTED
571566         OPTION_NUMPROCESSORS
572#endif
573567      }
574568   },
575569
r14652r14653
581575         REQUIRED OPTION_INPUT,
582576         OPTION_HUNK_SIZE,
583577         OPTION_COMPRESSION,
584#if NUM_PROCESSORS_SUPPORTED
585578         OPTION_NUMPROCESSORS
586#endif
587579      }
588580   },
589581
r14652r14653
597589         OPTION_INPUT_LENGTH_FRAMES,
598590         OPTION_HUNK_SIZE,
599591         OPTION_COMPRESSION,
600#if NUM_PROCESSORS_SUPPORTED
601592         OPTION_NUMPROCESSORS
602#endif
603593      }
604594   },
605595
r14652r14653
663653         OPTION_INPUT_LENGTH_HUNKS,
664654         OPTION_HUNK_SIZE,
665655         OPTION_COMPRESSION,
666#if NUM_PROCESSORS_SUPPORTED
667656         OPTION_NUMPROCESSORS
668#endif
669657      }
670658   },
671659
r14652r14653
10961084
10971085static void parse_numprocessors(const parameters_t &params)
10981086{
1099#if NUM_PROCESSORS_SUPPORTED
11001087   astring *numprocessors_str = params.find(OPTION_NUMPROCESSORS);
11011088   if (numprocessors_str == NULL)
11021089      return;
r14652r14653
11071094      extern int osd_num_processors;
11081095      osd_num_processors = count;
11091096   }
1110#endif
11111097}
11121098
11131099
r14652r14653
15521538   printf("Logical size: %s\n", big_int_string(tempstr, input_end - input_start));
15531539
15541540   // catch errors so we can close & delete the output file
1555   chd_rawfile_compressor* chd = NULL;
1541   chd_rawfile_compressor *chd = NULL;
15561542   try
15571543   {
15581544      // create the new CHD
r14652r14653
15791565      astring *output_chd_str = params.find(OPTION_OUTPUT);
15801566      if (output_chd_str != NULL)
15811567         osd_rmfile(*output_chd_str);
1582      if (chd != NULL)
1583         delete chd;
1568      delete chd;
15841569      throw;
15851570   }
15861571}
r14652r14653
17141699   printf("Logical size: %s\n", big_int_string(tempstr, UINT64(totalsectors) * UINT64(sector_size)));
17151700
17161701   // catch errors so we can close & delete the output file
1702   chd_rawfile_compressor *chd = NULL;
17171703   try
17181704   {
17191705      // 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);
17211707      chd_error err;
17221708      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);
17241710      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);
17261712      if (err != CHDERR_NONE)
17271713         report_error(1, "Error creating CHD file (%s): %s", output_chd_str->cstr(), chd_file::error_string(err));
17281714
17291715      // add the standard hard disk metadata
17301716      astring metadata;
17311717      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);
17331719      if (err != CHDERR_NONE)
17341720         report_error(1, "Error adding hard disk metadata: %s", chd_file::error_string(err));
17351721
17361722      // write the ident if present
17371723      if (identdata.count() > 0)
17381724      {
1739         err = chd.write_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, identdata);
1725         err = chd->write_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, identdata);
17401726         if (err != CHDERR_NONE)
17411727            report_error(1, "Error adding hard disk metadata: %s", chd_file::error_string(err));
17421728      }
17431729
17441730      // compress it generically
17451731      if (input_file != NULL)
1746         compress_common(chd);
1732         compress_common(*chd);
1733      delete chd;
17471734   }
17481735   catch (...)
17491736   {
r14652r14653
17511738      astring *output_chd_str = params.find(OPTION_OUTPUT);
17521739      if (output_chd_str != NULL)
17531740         osd_rmfile(*output_chd_str);
1741      delete chd;
17541742      throw;
17551743   }
17561744}
r14652r14653
18141802   printf("Logical size: %s\n", big_int_string(tempstr, UINT64(totalsectors) * CD_FRAME_SIZE));
18151803
18161804   // catch errors so we can close & delete the output file
1817   chd_cd_compressor* chd = NULL;
1805   chd_cd_compressor *chd = NULL;
18181806   try
18191807   {
18201808      // create the new CD
r14652r14653
18421830      astring *output_chd_str = params.find(OPTION_OUTPUT);
18431831      if (output_chd_str != NULL)
18441832         osd_rmfile(*output_chd_str);
1845      if (chd != NULL)
1846         delete chd;
1833      delete chd;
18471834      throw;
18481835   }
18491836}
r14652r14653
19301917   printf("Logical size: %s\n", big_int_string(tempstr, UINT64(input_end - input_start) * hunk_size));
19311918
19321919   // catch errors so we can close & delete the output file
1933   chd_avi_compressor* chd = NULL;
1920   chd_avi_compressor *chd = NULL;
19341921   try
19351922   {
19361923      // create the new CHD
r14652r14653
19681955      astring *output_chd_str = params.find(OPTION_OUTPUT);
19691956      if (output_chd_str != NULL)
19701957         osd_rmfile(*output_chd_str);
1971      if (chd != NULL)
1972         delete chd;
1958      delete chd;
19731959      throw;
19741960   }
19751961}
r14652r14653
20382024   printf("Logical size: %s\n", big_int_string(tempstr, input_end - input_start));
20392025
20402026   // catch errors so we can close & delete the output file
2041   chd_chdfile_compressor* chd = NULL;
2027   chd_chdfile_compressor *chd = NULL;
20422028   try
20432029   {
20442030      // create the new CHD
r14652r14653
20942080      astring *output_chd_str = params.find(OPTION_OUTPUT);
20952081      if (output_chd_str != NULL)
20962082         osd_rmfile(*output_chd_str);
2097      if (chd != NULL)
2098         delete chd;
2083      delete chd;
20992084      throw;
21002085   }
21012086}
r14652r14653
22512236         const cdrom_track_info &trackinfo = toc->tracks[tracknum];
22522237         output_track_metadata(cuemode, output_toc_file, tracknum, trackinfo, *output_bin_file_str, discoffs, outputoffs);
22532238
2254         UINT32 output_frame_size;
2255
22562239            // If this is bin/cue output and the CHD contains subdata, warn the user and don't include
22572240            // 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)
22592243            {
22602244                printf("Warning: Track %d has subcode data.  bin/cue format cannot contain subcode data and it will be omitted.\n", tracknum+1);
22612245                printf("       : This may affect usage of the output image.  Use bin/toc output to keep all data.\n");
2262
22632246                output_frame_size = trackinfo.datasize;
22642247            }
2265            else
2266            {
2267                output_frame_size = trackinfo.datasize + ((trackinfo.subtype != CD_SUB_NONE) ? trackinfo.subsize : 0);
2268            }
22692248
22702249         // resize the buffer for the track
22712250         buffer.resize((TEMP_BUFFER_SIZE / output_frame_size) * output_frame_size);
r14652r14653
22912270            discoffs++;
22922271
22932272            // read the subcode data
2294            if ((trackinfo.subtype != CD_SUB_NONE) && (!cuemode))
2273            if (trackinfo.subtype != CD_SUB_NONE && !cuemode)
22952274            {
22962275                    cdrom_read_subcode(cdrom, cdrom_get_track_start(cdrom, tracknum) + frame, &buffer[bufferoffs]);
22972276                    bufferoffs += trackinfo.subsize;
src/emu/ui.c
r14652r14653
16541654   tailptr = &(*tailptr)->next;
16551655
16561656   /* add per-channel volume */
1657   speaker_input info;
1658   for (item = 0; machine.sound().indexed_speaker_input(item, info); item++)
1657   mixer_input info;
1658   for (item = 0; machine.sound().indexed_mixer_input(item, info); item++)
16591659   {
16601660      INT32 maxval = 2000;
16611661      INT32 defval = info.stream->initial_input_gain(info.inputnum) * 1000.0f + 0.5f;
r14652r14653
18151815
18161816static INT32 slider_mixervol(running_machine &machine, void *arg, astring *string, INT32 newval)
18171817{
1818   speaker_input info;
1819   if (!machine.sound().indexed_speaker_input((FPTR)arg, info))
1818   mixer_input info;
1819   if (!machine.sound().indexed_mixer_input((FPTR)arg, info))
18201820      return 0;
18211821   if (newval != SLIDER_NOCHANGE)
18221822   {
src/emu/schedule.c
r14652r14653
251251
252252attotime emu_timer::remaining() const
253253{
254   return m_expire - machine().time();
254   attotime curtime = machine().time();
255   if (curtime >= m_expire)
256      return attotime::zero;
257   return m_expire - curtime;
255258}
256259
257260
src/emu/disound.h
r14652r14653
176176   sound_stream *      m_mixer_stream;         // mixing stream
177177};
178178
179// iterator
180typedef device_interface_iterator<device_mixer_interface> mixer_interface_iterator;
179181
182
180183#endif   /* __DISOUND_H__ */
src/emu/sound.c
r14652r14653
786786   if (m_nosound_mode && wavfile[0] == 0 && avifile[0] == 0)
787787      machine.m_sample_rate = 11025;
788788
789   // count the speakers
789   // count the mixers
790790#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()));
793793#endif
794794
795795   // allocate memory for mix buffers
r14652r14653
856856
857857
858858//-------------------------------------------------
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
861861//  input
862862//-------------------------------------------------
863863
864bool sound_manager::indexed_speaker_input(int index, speaker_input &info) const
864bool sound_manager::indexed_mixer_input(int index, mixer_input &info) const
865865{
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())
869869   {
870      if (index < info.speaker->inputs())
870      if (index < info.mixer->inputs())
871871      {
872         info.stream = info.speaker->input_to_stream_input(index, info.inputnum);
872         info.stream = info.mixer->input_to_stream_input(index, info.inputnum);
873873         assert(info.stream != NULL);
874874         return true;
875875      }
876      index -= info.speaker->inputs();
876      index -= info.mixer->inputs();
877877   }
878878
879879   // didn't locate
r14652r14653
946946   // iterate over channel nodes
947947   for (xml_data_node *channelnode = xml_get_sibling(parentnode->child, "channel"); channelnode != NULL; channelnode = xml_get_sibling(channelnode->next, "channel"))
948948   {
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))
951951      {
952952         float defvol = xml_get_attribute_float(channelnode, "defvol", -1000.0);
953953         float newvol = xml_get_attribute_float(channelnode, "newvol", -1000.0);
r14652r14653
973973   if (parentnode != NULL)
974974      for (int mixernum = 0; ; mixernum++)
975975      {
976         speaker_input info;
977         if (!indexed_speaker_input(mixernum, info))
976         mixer_input info;
977         if (!indexed_mixer_input(mixernum, info))
978978            break;
979979         float defvol = info.stream->initial_input_gain(info.inputnum);
980980         float newvol = info.stream->input_gain(info.inputnum);
src/emu/sound.h
r14652r14653
6060//**************************************************************************
6161
6262// forward references
63class speaker_device;
6463typedef struct _wav_file wav_file;
6564
6665
67// structure describing an indexed speaker
68struct speaker_input
66// structure describing an indexed mixer
67struct mixer_input
6968{
70   speaker_device *   speaker;               // owning device
71   sound_stream *      stream;                  // stream within the device
72   int               inputnum;               // input on the stream
69   device_mixer_interface *mixer;         // owning device interface
70   sound_stream *         stream;         // stream within the device
71   int                  inputnum;      // input on the stream
7372};
7473
7574
r14652r14653
237236   void system_enable(bool turn_on = true) { mute(!turn_on, MUTE_REASON_SYSTEM); }
238237
239238   // user gain controls
240   bool indexed_speaker_input(int index, speaker_input &info) const;
239   bool indexed_mixer_input(int index, mixer_input &info) const;
241240
242241private:
243242   // internal helpers

Previous 15994 Revisions Next


© 1998-2018 The MESS Team