diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-02-11 12:04:27 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-02-11 12:04:27 +0000 |
| commit | 8aeb741ccbe2edb528e98a431bf55459a6836a9b (patch) | |
| tree | a14569b531d9867683a1ac1c94c8e0eb406906a8 /src/lib | |
| parent | 4ba8772aef261da209bbb882325fd61a8b479fd7 (diff) | |
| parent | 22f2cd94132f93a159c2ce9fe263771cb5a5dbdf (diff) | |
Merge master.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/audio_analysis.cc | 11 | ||||
| -rw-r--r-- | src/lib/config.h | 12 | ||||
| -rw-r--r-- | src/lib/ffmpeg.cc | 6 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.h | 2 | ||||
| -rw-r--r-- | src/lib/image.cc | 8 | ||||
| -rw-r--r-- | src/lib/job.cc | 26 | ||||
| -rw-r--r-- | src/lib/log.cc | 5 | ||||
| -rw-r--r-- | src/lib/player.cc | 5 | ||||
| -rw-r--r-- | src/lib/po/it_IT.po | 66 | ||||
| -rw-r--r-- | src/lib/scp_dcp_job.cc | 6 | ||||
| -rw-r--r-- | src/lib/server_finder.cc | 9 | ||||
| -rw-r--r-- | src/lib/transcode_job.cc | 9 | ||||
| -rw-r--r-- | src/lib/util.cc | 44 | ||||
| -rw-r--r-- | src/lib/util.h | 1 | ||||
| -rw-r--r-- | src/lib/writer.cc | 4 | ||||
| -rw-r--r-- | src/lib/wscript | 4 |
16 files changed, 150 insertions, 68 deletions
diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc index 1488f89fc..98d092726 100644 --- a/src/lib/audio_analysis.cc +++ b/src/lib/audio_analysis.cc @@ -93,10 +93,21 @@ AudioAnalysis::AudioAnalysis (boost::filesystem::path filename) for (int i = 0; i < channels; ++i) { int points; fscanf (f, "%d", &points); + if (feof (f)) { + fclose (f); + return; + } + for (int j = 0; j < points; ++j) { _data[i].push_back (AudioPoint (f)); + if (feof (f)) { + fclose (f); + return; + } } } + + fclose (f); } void diff --git a/src/lib/config.h b/src/lib/config.h index 791e41e8f..d77969b3e 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -193,14 +193,6 @@ public: _server_port_base = p; } - void set_reference_scaler (Scaler const * s) { - _reference_scaler = s; - } - - void set_reference_filters (std::vector<Filter const *> const & f) { - _reference_filters = f; - } - /** @param i IP address of a TMS that we can copy DCPs to */ void set_tms_ip (std::string i) { _tms_ip = i; @@ -326,10 +318,6 @@ private: bool _use_any_servers; /** J2K encoding servers that should definitely be used */ std::vector<std::string> _servers; - /** Scaler to use for the "A" part of A/B comparisons */ - Scaler const * _reference_scaler; - /** Filters to use for the "A" part of A/B comparisons */ - std::vector<Filter const *> _reference_filters; /** The IP address of a TMS that we can copy DCPs to */ std::string _tms_ip; /** The path on a TMS that we should write DCPs to */ diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 4bf941523..5fc333489 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -26,6 +26,7 @@ extern "C" { #include "ffmpeg.h" #include "ffmpeg_content.h" #include "exceptions.h" +#include "util.h" #include "i18n.h" @@ -85,7 +86,7 @@ FFmpeg::setup_general () av_register_all (); _file_group.set_paths (_ffmpeg_content->paths ()); - _avio_buffer = static_cast<uint8_t*> (av_malloc (_avio_buffer_size)); + _avio_buffer = static_cast<uint8_t*> (wrapped_av_malloc (_avio_buffer_size)); _avio_context = avio_alloc_context (_avio_buffer, _avio_buffer_size, 0, this, avio_read_wrapper, 0, avio_seek_wrapper); _format_context = avformat_alloc_context (); _format_context->pb = _avio_context; @@ -146,7 +147,8 @@ void FFmpeg::setup_video () { boost::mutex::scoped_lock lm (_mutex); - + + assert (_video_stream >= 0); AVCodecContext* context = _format_context->streams[_video_stream]->codec; AVCodec* codec = avcodec_find_decoder (context->codec_id); diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index d9037b0d8..e637faf47 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -86,6 +86,8 @@ private: /* Constructor for tests */ FFmpegAudioStream () : FFmpegStream ("", 0) + , frame_rate (0) + , channels (0) , mapping (1) {} }; diff --git a/src/lib/image.cc b/src/lib/image.cc index e5f626c24..78e8bbb2a 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -509,13 +509,13 @@ Image::Image (AVPixelFormat p, libdcp::Size s, bool aligned) void Image::allocate () { - _data = (uint8_t **) av_malloc (4 * sizeof (uint8_t *)); + _data = (uint8_t **) wrapped_av_malloc (4 * sizeof (uint8_t *)); _data[0] = _data[1] = _data[2] = _data[3] = 0; - _line_size = (int *) av_malloc (4 * sizeof (int)); + _line_size = (int *) wrapped_av_malloc (4 * sizeof (int)); _line_size[0] = _line_size[1] = _line_size[2] = _line_size[3] = 0; - _stride = (int *) av_malloc (4 * sizeof (int)); + _stride = (int *) wrapped_av_malloc (4 * sizeof (int)); _stride[0] = _stride[1] = _stride[2] = _stride[3] = 0; for (int i = 0; i < components(); ++i) { @@ -531,7 +531,7 @@ Image::allocate () seem to mind. The nasty + 1 in this malloc makes sure there is always a byte for that instruction to read safely. */ - _data[i] = (uint8_t *) av_malloc (_stride[i] * lines (i) + 1); + _data[i] = (uint8_t *) wrapped_av_malloc (_stride[i] * lines (i) + 1); } } diff --git a/src/lib/job.cc b/src/lib/job.cc index 05a90524c..b543a043f 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -68,9 +68,6 @@ Job::run_wrapper () } catch (libdcp::FileError& e) { - set_progress (1); - set_state (FINISHED_ERROR); - string m = String::compose (_("An error occurred whilst handling the file %1."), boost::filesystem::path (e.filename()).leaf()); try { @@ -84,39 +81,48 @@ Job::run_wrapper () } set_error (e.what(), m); - - } catch (OpenFileError& e) { - set_progress (1); set_state (FINISHED_ERROR); + + } catch (OpenFileError& e) { set_error ( String::compose (_("Could not open %1"), e.file().string()), String::compose (_("DCP-o-matic could not open the file %1. Perhaps it does not exist or is in an unexpected format."), e.file().string()) ); + set_progress (1); + set_state (FINISHED_ERROR); + } catch (boost::thread_interrupted &) { set_state (FINISHED_CANCELLED); - - } catch (std::exception& e) { + } catch (std::bad_alloc& e) { + + set_error (_("Out of memory"), _("There was not enough memory to do this.")); set_progress (1); set_state (FINISHED_ERROR); + + } catch (std::exception& e) { + set_error ( e.what (), _("It is not known what caused this error. The best idea is to report the problem to the DCP-o-matic mailing list (carl@dcpomatic.com)") ); - } catch (...) { - set_progress (1); set_state (FINISHED_ERROR); + + } catch (...) { + set_error ( _("Unknown error"), _("It is not known what caused this error. The best idea is to report the problem to the DCP-o-matic mailing list (carl@dcpomatic.com)") ); + set_progress (1); + set_state (FINISHED_ERROR); } } diff --git a/src/lib/log.cc b/src/lib/log.cc index 9ddf460d4..a0b031589 100644 --- a/src/lib/log.cc +++ b/src/lib/log.cc @@ -104,6 +104,11 @@ void FileLog::do_log (string m) { FILE* f = fopen_boost (_file, "a"); + if (!f) { + cout << "(could not log to " << _file.string() << "): " << m << "\n"; + return; + } + fprintf (f, "%s\n", m.c_str ()); fclose (f); } diff --git a/src/lib/player.cc b/src/lib/player.cc index 3e6a1598d..48c75078e 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -450,6 +450,10 @@ Player::setup_pieces () for (ContentList::iterator i = content.begin(); i != content.end(); ++i) { + if (!(*i)->paths_valid ()) { + continue; + } + shared_ptr<Decoder> decoder; optional<FrameRateChange> frc; @@ -566,6 +570,7 @@ Player::content_changed (weak_ptr<Content> w, int property, bool frequent) } else if (property == ContentProperty::PATH) { + _have_valid_pieces = false; Changed (frequent); } } diff --git a/src/lib/po/it_IT.po b/src/lib/po/it_IT.po index a9a4a6000..584baad6e 100644 --- a/src/lib/po/it_IT.po +++ b/src/lib/po/it_IT.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: IT VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-01-30 21:51+0000\n" -"PO-Revision-Date: 2013-04-28 10:26+0100\n" -"Last-Translator: Maci <macibro@gmail.com>\n" +"PO-Revision-Date: 2014-02-03 10:48+0100\n" +"Last-Translator: William Fanelli <william.f@impronte.com>\n" "Language-Team: \n" -"Language: Italiano\n" +"Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.5.5\n" +"X-Generator: Poedit 1.6.3\n" #: src/lib/sndfile_content.cc:60 msgid "%1 [audio]" @@ -30,9 +30,8 @@ msgid "%1 channels, %2kHz, %3 samples" msgstr "" #: src/lib/ffmpeg_content.cc:237 -#, fuzzy msgid "%1 frames; %2 frames per second" -msgstr "fotogrammi al secondo" +msgstr "%1 fotogrammi; %2 fotogrammi al secondo" #: src/lib/video_content.cc:200 msgid "%1x%2 pixels (%3:1)" @@ -149,14 +148,14 @@ msgid "Content to be joined must have the same ratio." msgstr "" #: src/lib/subtitle_content.cc:74 -#, fuzzy msgid "Content to be joined must have the same subtitle X offset." -msgstr "Il DCP e il sorgente hanno la stessa frequenza." +msgstr "" +"Il contenuto da unire deve avere lo stesso spostamento X dei sottotitoli." #: src/lib/subtitle_content.cc:78 -#, fuzzy msgid "Content to be joined must have the same subtitle Y offset." -msgstr "Il DCP e il sorgente hanno la stessa frequenza." +msgstr "" +"Il contenuto da unire deve avere lo stesso spostamento Y dei sottotitoli." #: src/lib/subtitle_content.cc:82 msgid "Content to be joined must have the same subtitle scale." @@ -191,9 +190,8 @@ msgid "Could not create remote directory %1 (%2)" msgstr "Non posso creare la directory remota %1 (%2)" #: src/lib/job.cc:94 -#, fuzzy msgid "Could not open %1" -msgstr "non riesco ad aprire %1" +msgstr "Non riesco ad aprire %1" #: src/lib/scp_dcp_job.cc:176 msgid "Could not open %1 to send" @@ -230,6 +228,8 @@ msgid "" "DCP-o-matic could not open the file %1. Perhaps it does not exist or is in " "an unexpected format." msgstr "" +"DCP-o-matic non può aprire il file %1. Non esiste oppure è in un formato non " +"riconosciuto." #: src/lib/filter.cc:68 src/lib/filter.cc:69 src/lib/filter.cc:70 #: src/lib/filter.cc:71 src/lib/filter.cc:72 src/lib/filter.cc:73 @@ -253,6 +253,14 @@ msgid "" "Best regards,\n" "DCP-o-matic" msgstr "" +"Spett. Proiezionista\n" +"\n" +"troverà in allegato le KDMs per $CPL_NAME.\n" +"\n" +"Le KDM sono valide da $START_TIME fino a $END_TIME.\n" +"\n" +"Distinti saluti,\n" +"DCP-o-matic" #: src/lib/filter.cc:74 msgid "Deringing filter" @@ -264,14 +272,12 @@ msgid "Dolby CP650 and CP750" msgstr "Dolby CP750" #: src/lib/util.cc:803 -#, fuzzy msgid "Each content frame will be doubled in the DCP.\n" -msgstr "Ogni fotogramma del sorgente sarà raddoppiato nel DCP.\n" +msgstr "Ogni fotogramma del sorgente sarà duplicato nel DCP.\n" #: src/lib/util.cc:805 -#, fuzzy msgid "Each content frame will be repeated %1 more times in the DCP.\n" -msgstr "Ogni fotogramma del sorgente sarà raddoppiato nel DCP.\n" +msgstr "Ogni fotogramma del sorgente sarà ripetuto %1 volte nel DCP.\n" #: src/lib/send_kdm_email_job.cc:50 msgid "Email KDMs for %1" @@ -291,11 +297,11 @@ msgstr "Esamino il contenuto" #: src/lib/filter.cc:72 msgid "Experimental horizontal deblocking filter 1" -msgstr "Filtro di sblocco sperimentale orizzontale 1" +msgstr "Filtro deblocking orizzontale sperimentale 1" #: src/lib/filter.cc:73 msgid "Experimental vertical deblocking filter 1" -msgstr "Filtro di sblocco sperimentale verticale 1" +msgstr "Filtro deblocking verticale sperimentale 1" #: src/lib/filter.cc:79 msgid "FFMPEG deinterlacer" @@ -327,7 +333,7 @@ msgstr "Forza quantizzatore" #: src/lib/ratio.cc:43 msgid "Full frame" -msgstr "" +msgstr "Schermo intero" #: src/lib/scaler.cc:65 msgid "Gaussian" @@ -343,11 +349,11 @@ msgstr "Riduttore di rumore 3D di alta qualità" #: src/lib/filter.cc:68 msgid "Horizontal deblocking filter" -msgstr "Filtro sblocco orizzontale" +msgstr "Filtro deblocking orizzontale" #: src/lib/filter.cc:70 msgid "Horizontal deblocking filter A" -msgstr "Filtro A sblocco orizzontale" +msgstr "Filtro deblocking orizzontale A" #: src/lib/job.cc:108 src/lib/job.cc:117 msgid "" @@ -396,7 +402,7 @@ msgstr "Varie" #: src/lib/filter.cc:81 msgid "Motion compensating deinterlacer" -msgstr "Dinterlacciatore compensativo di movimento" +msgstr "Dinterlacciatore con compensazione di movimento" #: src/lib/filter.cc:84 src/lib/filter.cc:88 src/lib/filter.cc:89 #: src/lib/filter.cc:91 @@ -494,6 +500,10 @@ msgid "" "unfortunately it cannot be loaded into this version. You will need to " "create a new Film, re-add your content and set it up again. Sorry!" msgstr "" +"Questo film è stato creato con una vecchia versione di DCP-o-matic, e " +"purtroppo non può essere caricato in questa versione. Sarà necessario creare " +"un nuovo film, ri-aggiungere i tuoi contenuti e configurarlo di nuovo. Ci " +"dispiace!" #: src/lib/dcp_content_type.cc:46 msgid "Trailer" @@ -521,7 +531,7 @@ msgstr "Maschera unsharp e sfocatura Gaussiana" #: src/lib/colour_conversion.cc:145 msgid "Untitled" -msgstr "" +msgstr "Senza titolo" #: src/lib/filter.cc:69 msgid "Vertical deblocking filter" @@ -545,7 +555,7 @@ msgstr "Altro filtro di deinterlacciamento" #: src/lib/film.cc:289 msgid "You must add some content to the DCP before creating it" -msgstr "" +msgstr "Devi aggiungere dei contenuti al DCP prima di crearlo" #: src/lib/image_content.cc:68 msgid "[moving images]" @@ -569,9 +579,8 @@ msgid "connecting" msgstr "mi sto connettendo" #: src/lib/film.cc:285 -#, fuzzy msgid "container" -msgstr "contenuto" +msgstr "contenitore" #: src/lib/film.cc:293 msgid "content type" @@ -606,9 +615,8 @@ msgid "could not move audio MXF into the DCP (%1)" msgstr "" #: src/lib/sndfile_decoder.cc:45 -#, fuzzy msgid "could not open audio file for reading" -msgstr "non riesco ad aprire il file per leggerlo" +msgstr "non riesco ad aprire il file in lettura" #: src/lib/exceptions.cc:29 msgid "could not open file %1" @@ -720,7 +728,7 @@ msgstr "sRGB" #: src/lib/config.cc:82 msgid "sRGB non-linearised" -msgstr "" +msgstr "sRGB non linearizzato" #: src/lib/util.cc:160 msgid "seconds" diff --git a/src/lib/scp_dcp_job.cc b/src/lib/scp_dcp_job.cc index 310303c09..22715978a 100644 --- a/src/lib/scp_dcp_job.cc +++ b/src/lib/scp_dcp_job.cc @@ -191,8 +191,10 @@ SCPDCPJob::run () } to_do -= t; bytes_transferred += t; - - set_progress ((double) bytes_transferred / bytes_to_transfer); + + if (bytes_to_transfer > 0) { + set_progress ((double) bytes_transferred / bytes_to_transfer); + } } fclose (f); diff --git a/src/lib/server_finder.cc b/src/lib/server_finder.cc index 5b67d8048..3d5825ad4 100644 --- a/src/lib/server_finder.cc +++ b/src/lib/server_finder.cc @@ -65,8 +65,12 @@ try while (1) { if (Config::instance()->use_any_servers ()) { /* Broadcast to look for servers */ - boost::asio::ip::udp::endpoint end_point (boost::asio::ip::address_v4::broadcast(), Config::instance()->server_port_base() + 1); - socket.send_to (boost::asio::buffer (data.c_str(), data.size() + 1), end_point); + try { + boost::asio::ip::udp::endpoint end_point (boost::asio::ip::address_v4::broadcast(), Config::instance()->server_port_base() + 1); + socket.send_to (boost::asio::buffer (data.c_str(), data.size() + 1), end_point); + } catch (...) { + + } } /* Query our `definite' servers (if there are any) */ @@ -104,6 +108,7 @@ try try { sock->accept (Config::instance()->server_port_base() + 1); } catch (std::exception& e) { + dcpomatic_sleep (60); continue; } diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index 289259369..46fc97fb3 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -100,17 +100,20 @@ TranscodeJob::status () const int TranscodeJob::remaining_time () const { - if (!_transcoder) { + /* _transcoder might be destroyed by the job-runner thread */ + shared_ptr<Transcoder> t = _transcoder; + + if (!t) { return 0; } - float fps = _transcoder->current_encoding_rate (); + float fps = t->current_encoding_rate (); if (fps == 0) { return 0; } /* Compute approximate proposed length here, as it's only here that we need it */ - VideoFrame const left = _film->time_to_video_frames (_film->length ()) - _transcoder->video_frames_out(); + VideoFrame const left = _film->time_to_video_frames (_film->length ()) - t->video_frames_out(); return left / fps; } diff --git a/src/lib/util.cc b/src/lib/util.cc index ef203c2bd..418d7b3e0 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -27,6 +27,7 @@ #include <iostream> #include <fstream> #include <climits> +#include <stdexcept> #ifdef DCPOMATIC_POSIX #include <execinfo.h> #include <cxxabi.h> @@ -93,7 +94,9 @@ using std::istream; using std::numeric_limits; using std::pair; using std::cout; +using std::bad_alloc; using std::streampos; +using std::set_terminate; using boost::shared_ptr; using boost::thread; using boost::lexical_cast; @@ -272,6 +275,33 @@ LONG WINAPI exception_handler(struct _EXCEPTION_POINTERS *) } #endif +/* From http://stackoverflow.com/questions/2443135/how-do-i-find-where-an-exception-was-thrown-in-c */ +void +terminate () +{ + static bool tried_throw = false; + + try { + // try once to re-throw currently active exception + if (!tried_throw++) { + throw; + } + } + catch (const std::exception &e) { + std::cerr << __FUNCTION__ << " caught unhandled exception. what(): " + << e.what() << std::endl; + } + catch (...) { + std::cerr << __FUNCTION__ << " caught unknown/unhandled exception." + << std::endl; + } + +#ifdef DCPOMATIC_POSIX + stacktrace (cout, 50); +#endif + abort(); +} + /** Call the required functions to set up DCP-o-matic's static arrays, etc. * Must be called from the UI thread, if there is one. */ @@ -308,7 +338,9 @@ dcpomatic_setup () boost::filesystem::path lib = app_contents (); lib /= "lib"; setenv ("LTDL_LIBRARY_PATH", lib.c_str (), 1); -#endif +#endif + + set_terminate (terminate); Pango::init (); libdcp::init (); @@ -926,3 +958,13 @@ time_round_up (DCPTime t, DCPTime nearest) DCPTime const a = t + nearest - 1; return a - (a % nearest); } + +void * +wrapped_av_malloc (size_t s) +{ + void* p = av_malloc (s); + if (!p) { + throw bad_alloc (); + } + return p; +} diff --git a/src/lib/util.h b/src/lib/util.h index a84e7e4cf..d3e6a67de 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -126,6 +126,7 @@ extern float get_required_float (std::multimap<std::string, std::string> const & extern std::string get_required_string (std::multimap<std::string, std::string> const & kv, std::string k); extern int get_optional_int (std::multimap<std::string, std::string> const & kv, std::string k); extern std::string get_optional_string (std::multimap<std::string, std::string> const & kv, std::string k); +extern void* wrapped_av_malloc (size_t); /** @class Socket * @brief A class to wrap a boost::asio::ip::tcp::socket with some things diff --git a/src/lib/writer.cc b/src/lib/writer.cc index c2a6c981b..42187dc6e 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -541,7 +541,9 @@ Writer::check_existing_picture_mxf () shared_ptr<Job> job = _job.lock (); assert (job); - job->set_progress (float (_first_nonexistant_frame) / N); + if (N > 0) { + job->set_progress (float (_first_nonexistant_frame) / N); + } if (_film->three_d ()) { if (!check_existing_picture_mxf_frame (mxf, _first_nonexistant_frame, EYES_LEFT)) { diff --git a/src/lib/wscript b/src/lib/wscript index 8a20618c0..a5b069184 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -69,7 +69,7 @@ sources = """ """ def build(bld): - if bld.env.STATIC: + if bld.env.BUILD_STATIC: obj = bld(features = 'cxx cxxstlib') else: obj = bld(features = 'cxx cxxshlib') @@ -88,7 +88,7 @@ def build(bld): if bld.env.TARGET_WINDOWS: obj.uselib += ' WINSOCK2 BFD DBGHELP IBERTY SHLWAPI MSWSOCK BOOST_LOCALE' obj.source += ' stack.cpp' - if bld.env.STATIC: + if bld.env.BUILD_STATIC: obj.uselib += ' XML++' obj.target = 'dcpomatic' |
