summaryrefslogtreecommitdiff
path: root/libs/ardour/audiosource.cc
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2015-07-25 20:09:34 +1000
committerTim Mayberry <mojofunk@gmail.com>2015-07-25 23:14:51 +1000
commit0d356174aec9180f025f544504e3d2f5db91dc83 (patch)
treea8c216d8e401fd90eccbad811af7cfaf29ee7f9d /libs/ardour/audiosource.cc
parent44cba5321908e625c71b9c0eb9832384d6e0dc80 (diff)
Revert "When peakfiles get opened using a non-glib function (in a non-English locale) make sure that we pass locale-specific paths"
This reverts commit f89a976f1a0477fba30bd7117310e6d04b370d68.
Diffstat (limited to 'libs/ardour/audiosource.cc')
-rw-r--r--libs/ardour/audiosource.cc51
1 files changed, 25 insertions, 26 deletions
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc
index 5ecda69f22..9f52e847a0 100644
--- a/libs/ardour/audiosource.cc
+++ b/libs/ardour/audiosource.cc
@@ -47,7 +47,6 @@
#include <boost/scoped_ptr.hpp>
-#include <glibmm/convert.h>
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
@@ -225,7 +224,7 @@ AudioSource::rename_peakfile (string newpath)
if (Glib::file_test (oldpath, Glib::FILE_TEST_EXISTS)) {
if (g_rename (oldpath.c_str(), newpath.c_str()) != 0) {
- error << string_compose (_("cannot rename peakfile for %1 from %2 to %3 (%4)"), _name, Glib::locale_from_utf8(oldpath), Glib::locale_from_utf8(newpath), strerror (errno)) << endmsg;
+ error << string_compose (_("cannot rename peakfile for %1 from %2 to %3 (%4)"), _name, oldpath, newpath, strerror (errno)) << endmsg;
return -1;
}
}
@@ -242,7 +241,7 @@ AudioSource::initialize_peakfile (string audio_path)
peakpath = peak_path (audio_path);
- DEBUG_TRACE(DEBUG::Peaks, string_compose ("Initialize Peakfile %1 for Audio file %2\n", Glib::locale_from_utf8(peakpath), Glib::locale_from_utf8(audio_path)));
+ DEBUG_TRACE(DEBUG::Peaks, string_compose ("Initialize Peakfile %1 for Audio file %2\n", peakpath, audio_path));
/* if the peak file should be there, but isn't .... */
@@ -254,11 +253,11 @@ AudioSource::initialize_peakfile (string audio_path)
if (errno != ENOENT) {
/* it exists in the peaks dir, but there is some kind of error */
- error << string_compose(_("AudioSource: cannot stat peakfile \"%1\""), Glib::locale_from_utf8(peakpath)) << endmsg;
+ error << string_compose(_("AudioSource: cannot stat peakfile \"%1\""), peakpath) << endmsg;
return -1;
}
- DEBUG_TRACE(DEBUG::Peaks, string_compose("Peakfile %1 does not exist\n", Glib::locale_from_utf8(peakpath)));
+ DEBUG_TRACE(DEBUG::Peaks, string_compose("Peakfile %1 does not exist\n", peakpath));
_peaks_built = false;
@@ -267,19 +266,19 @@ AudioSource::initialize_peakfile (string audio_path)
/* we found it in the peaks dir, so check it out */
if (statbuf.st_size == 0 || (statbuf.st_size < (off_t) ((length(_timeline_position) / _FPP) * sizeof (PeakData)))) {
- DEBUG_TRACE(DEBUG::Peaks, string_compose("Peakfile %1 is empty\n", Glib::locale_from_utf8(peakpath)));
+ DEBUG_TRACE(DEBUG::Peaks, string_compose("Peakfile %1 is empty\n", peakpath));
_peaks_built = false;
} else {
// Check if the audio file has changed since the peakfile was built.
- GStatBuf stat_file;
- int err = g_stat (audio_path.c_str(), &stat_file);
+ struct stat stat_file;
+ int err = stat (audio_path.c_str(), &stat_file);
if (err) {
/* no audio path - nested source or we can't
read it or ... whatever, use the peakfile as-is.
*/
- DEBUG_TRACE(DEBUG::Peaks, string_compose("Error when calling stat on Peakfile %1\n", Glib::locale_from_utf8(peakpath)));
+ DEBUG_TRACE(DEBUG::Peaks, string_compose("Error when calling stat on Peakfile %1\n", peakpath));
_peaks_built = true;
_peak_byte_max = statbuf.st_size;
@@ -360,7 +359,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
expected_peaks = (cnt / (double) samples_per_file_peak);
if (g_stat (peakpath.c_str(), &statbuf) != 0) {
- error << string_compose (_("Cannot open peakfile @ %1 for size check (%2)"), Glib::locale_from_utf8(peakpath), strerror (errno)) << endmsg;
+ error << string_compose (_("Cannot open peakfile @ %1 for size check (%2)"), peakpath, strerror (errno)) << endmsg;
return -1;
}
@@ -381,10 +380,10 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
const off_t expected_file_size = (_length / (double) samples_per_file_peak) * sizeof (PeakData);
if (statbuf.st_size < expected_file_size) {
- warning << string_compose (_("peak file %1 is truncated from %2 to %3"), Glib::locale_from_utf8(peakpath), expected_file_size, statbuf.st_size) << endmsg;
+ warning << string_compose (_("peak file %1 is truncated from %2 to %3"), peakpath, expected_file_size, statbuf.st_size) << endmsg;
const_cast<AudioSource*>(this)->build_peaks_from_scratch ();
if (g_stat (peakpath.c_str(), &statbuf) != 0) {
- error << string_compose (_("Cannot open peakfile @ %1 for size check (%2) after rebuild"), Glib::locale_from_utf8(peakpath), strerror (errno)) << endmsg;
+ error << string_compose (_("Cannot open peakfile @ %1 for size check (%2) after rebuild"), peakpath, strerror (errno)) << endmsg;
}
if (statbuf.st_size < expected_file_size) {
fatal << "peak file is still truncated after rebuild" << endmsg;
@@ -393,10 +392,10 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
}
}
- ScopedFileDescriptor sfd (::open (Glib::locale_from_utf8 (peakpath).c_str(), O_RDONLY));
+ ScopedFileDescriptor sfd (::open (peakpath.c_str(), O_RDONLY));
if (sfd < 0) {
- error << string_compose (_("Cannot open peakfile @ %1 for reading (%2)"), Glib::locale_from_utf8(peakpath), strerror (errno)) << endmsg;
+ error << string_compose (_("Cannot open peakfile @ %1 for reading (%2)"), peakpath, strerror (errno)) << endmsg;
return -1;
}
@@ -465,13 +464,13 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
map_handle = CreateFileMapping(file_handle, NULL, PAGE_READONLY, 0, 0, NULL);
if (map_handle == NULL) {
- error << string_compose (_("map failed - could not create file mapping for peakfile %1."), Glib::locale_from_utf8(peakpath)) << endmsg;
+ error << string_compose (_("map failed - could not create file mapping for peakfile %1."), peakpath) << endmsg;
return -1;
}
view_handle = MapViewOfFile(map_handle, FILE_MAP_READ, 0, read_map_off, map_length);
if (view_handle == NULL) {
- error << string_compose (_("map failed - could not map peakfile %1."), Glib::locale_from_utf8(peakpath)) << endmsg;
+ error << string_compose (_("map failed - could not map peakfile %1."), peakpath) << endmsg;
return -1;
}
@@ -482,7 +481,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
err_flag = UnmapViewOfFile (view_handle);
err_flag = CloseHandle(map_handle);
if(!err_flag) {
- error << string_compose (_("unmap failed - could not unmap peakfile %1."), Glib::locale_from_utf8(peakpath)) << endmsg;
+ error << string_compose (_("unmap failed - could not unmap peakfile %1."), peakpath) << endmsg;
return -1;
}
#else
@@ -560,13 +559,13 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
map_handle = CreateFileMapping(file_handle, NULL, PAGE_READONLY, 0, 0, NULL);
if (map_handle == NULL) {
- error << string_compose (_("map failed - could not create file mapping for peakfile %1."), Glib::locale_from_utf8(peakpath)) << endmsg;
+ error << string_compose (_("map failed - could not create file mapping for peakfile %1."), peakpath) << endmsg;
return -1;
}
view_handle = MapViewOfFile(map_handle, FILE_MAP_READ, 0, read_map_off, map_length);
if (view_handle == NULL) {
- error << string_compose (_("map failed - could not map peakfile %1."), Glib::locale_from_utf8(peakpath)) << endmsg;
+ error << string_compose (_("map failed - could not map peakfile %1."), peakpath) << endmsg;
return -1;
}
@@ -577,7 +576,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
err_flag = UnmapViewOfFile (view_handle);
err_flag = CloseHandle(map_handle);
if(!err_flag) {
- error << string_compose (_("unmap failed - could not unmap peakfile %1."), Glib::locale_from_utf8(peakpath)) << endmsg;
+ error << string_compose (_("unmap failed - could not unmap peakfile %1."), peakpath) << endmsg;
return -1;
}
#else
@@ -766,7 +765,7 @@ AudioSource::build_peaks_from_scratch ()
out:
if (ret) {
- DEBUG_TRACE (DEBUG::Peaks, string_compose("Could not write peak data, attempting to remove peakfile %1\n", Glib::locale_from_utf8(peakpath)));
+ DEBUG_TRACE (DEBUG::Peaks, string_compose("Could not write peak data, attempting to remove peakfile %1\n", peakpath));
::g_unlink (peakpath.c_str());
}
@@ -776,8 +775,8 @@ AudioSource::build_peaks_from_scratch ()
int
AudioSource::prepare_for_peakfile_writes ()
{
- if ((_peakfile_fd = open (Glib::locale_from_utf8 (peakpath).c_str(), O_CREAT|O_RDWR, 0664)) < 0) {
- error << string_compose(_("AudioSource: cannot open peakpath (c) \"%1\" (%2)"), Glib::locale_from_utf8(peakpath), strerror (errno)) << endmsg;
+ if ((_peakfile_fd = open (peakpath.c_str(), O_CREAT|O_RDWR, 0664)) < 0) {
+ error << string_compose(_("AudioSource: cannot open peakpath (c) \"%1\" (%2)"), peakpath, strerror (errno)) << endmsg;
return -1;
}
return 0;
@@ -959,7 +958,7 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame
off_t target_length = blocksize * ((first_peak_byte + blocksize + 1) / blocksize);
if (endpos < target_length) {
- DEBUG_TRACE(DEBUG::Peaks, string_compose ("Truncating Peakfile %1\n", Glib::locale_from_utf8(peakpath)));
+ DEBUG_TRACE(DEBUG::Peaks, string_compose ("Truncating Peakfile %1\n", peakpath));
if (ftruncate (_peakfile_fd, target_length)) {
/* error doesn't actually matter so continue on without testing */
}
@@ -1010,10 +1009,10 @@ AudioSource::truncate_peakfile ()
off_t end = lseek (_peakfile_fd, 0, SEEK_END);
if (end > _peak_byte_max) {
- DEBUG_TRACE(DEBUG::Peaks, string_compose ("Truncating Peakfile %1\n", Glib::locale_from_utf8(peakpath)));
+ DEBUG_TRACE(DEBUG::Peaks, string_compose ("Truncating Peakfile %1\n", peakpath));
if (ftruncate (_peakfile_fd, _peak_byte_max)) {
error << string_compose (_("could not truncate peakfile %1 to %2 (error: %3)"),
- Glib::locale_from_utf8(peakpath), _peak_byte_max, errno) << endmsg;
+ peakpath, _peak_byte_max, errno) << endmsg;
}
}
}