Caught an unhandled exception from libsndfile
This commit is contained in:
parent
ccda509068
commit
1e6a0e635b
|
|
@ -183,9 +183,6 @@ class MainFrame : public wxFrame
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
wxLongLong m_LoopA, m_LoopB;
|
wxLongLong m_LoopA, m_LoopB;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
wxSystemAppearance m_Theme = wxSystemSettings::GetAppearance();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
bool bAutoplay = false;
|
bool bAutoplay = false;
|
||||||
|
|
@ -262,10 +259,6 @@ class MainFrame : public wxFrame
|
||||||
// Frame resize event handler
|
// Frame resize event handler
|
||||||
void OnResizeFrame(wxSizeEvent& event);
|
void OnResizeFrame(wxSizeEvent& event);
|
||||||
|
|
||||||
// Splitter window sash pos event handler
|
|
||||||
void OnTopSplitterSashPosChanged(wxSplitterEvent& event);
|
|
||||||
void OnBottomSplitterSashPosChanged(wxSplitterEvent& event);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Timer update event handler
|
// Timer update event handler
|
||||||
void UpdateElapsedTime(wxTimerEvent& event);
|
void UpdateElapsedTime(wxTimerEvent& event);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include "Utility/Log.hpp"
|
#include "Utility/Log.hpp"
|
||||||
#include "Utility/Paths.hpp"
|
#include "Utility/Paths.hpp"
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <wx/brush.h>
|
#include <wx/brush.h>
|
||||||
|
|
@ -35,6 +36,7 @@
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
#include <wx/pen.h>
|
#include <wx/pen.h>
|
||||||
|
|
||||||
|
#include <sndfile.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
|
|
||||||
WaveformViewer::WaveformViewer(wxWindow* window, wxDataViewListCtrl& library,
|
WaveformViewer::WaveformViewer(wxWindow* window, wxDataViewListCtrl& library,
|
||||||
|
|
@ -178,6 +180,8 @@ void WaveformViewer::UpdateWaveformBitmap()
|
||||||
|
|
||||||
std::vector<float> waveform;
|
std::vector<float> waveform;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// TODO, FIXME: Don't reload file on every window resize
|
// TODO, FIXME: Don't reload file on every window resize
|
||||||
snd_file.read(&sample.at(0), frames * channels);
|
snd_file.read(&sample.at(0), frames * channels);
|
||||||
|
|
||||||
|
|
@ -249,6 +253,12 @@ void WaveformViewer::UpdateWaveformBitmap()
|
||||||
}
|
}
|
||||||
|
|
||||||
SH_LOG_DEBUG("Done drawing bitmap..");
|
SH_LOG_DEBUG("Done drawing bitmap..");
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR("Error! SNDFILE {}", e.what());
|
||||||
|
SH_LOG_ERROR("Error! SNDFILE {}", sf_strerror(snd_file.rawHandle()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::OnControlKeyDown(wxKeyEvent &event)
|
void WaveformViewer::OnControlKeyDown(wxKeyEvent &event)
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,11 @@
|
||||||
#include "Utility/Tags.hpp"
|
#include "Utility/Tags.hpp"
|
||||||
#include "SampleHiveConfig.hpp"
|
#include "SampleHiveConfig.hpp"
|
||||||
|
|
||||||
|
// #include <iomanip>
|
||||||
|
|
||||||
#include <taglib/tag.h>
|
#include <taglib/tag.h>
|
||||||
#include <taglib/fileref.h>
|
#include <taglib/fileref.h>
|
||||||
|
// #include <taglib/tpropertymap.h>
|
||||||
|
|
||||||
#ifndef USE_SYSTEM_INCLUDE_PATH
|
#ifndef USE_SYSTEM_INCLUDE_PATH
|
||||||
#include <taglib/toolkit/tstring.h>
|
#include <taglib/toolkit/tstring.h>
|
||||||
|
|
@ -44,14 +47,15 @@ Tags::~Tags()
|
||||||
AudioInfo Tags::GetAudioInfo()
|
AudioInfo Tags::GetAudioInfo()
|
||||||
{
|
{
|
||||||
wxString artist, album, genre, title, comment;
|
wxString artist, album, genre, title, comment;
|
||||||
int channels = 0, length = 0, sample_rate = 0, bitrate = 0;
|
int channels = 0, length_ms = 0, length_s = 0, sample_rate = 0, bitrate = 0;
|
||||||
|
|
||||||
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
TagLib::FileRef f(static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
||||||
|
|
||||||
if (!f.isNull() && f.tag() && f.audioProperties())
|
if (!f.isNull() && f.tag() && f.audioProperties())
|
||||||
{
|
{
|
||||||
TagLib::Tag* tag = f.tag();
|
TagLib::Tag* tag = f.tag();
|
||||||
TagLib::AudioProperties* properties = f.audioProperties();
|
TagLib::AudioProperties* properties = f.audioProperties();
|
||||||
|
// TagLib::PropertyMap property_map = f.file()->properties();
|
||||||
|
|
||||||
TagLib::String Title = tag->title();
|
TagLib::String Title = tag->title();
|
||||||
TagLib::String Artist = tag->artist();
|
TagLib::String Artist = tag->artist();
|
||||||
|
|
@ -64,8 +68,8 @@ AudioInfo Tags::GetAudioInfo()
|
||||||
|
|
||||||
bitrate = properties->bitrate();
|
bitrate = properties->bitrate();
|
||||||
channels = properties->channels();
|
channels = properties->channels();
|
||||||
length = properties->lengthInMilliseconds();
|
length_ms = properties->lengthInMilliseconds();
|
||||||
int length_sec = properties->lengthInSeconds();
|
length_s = properties->lengthInSeconds();
|
||||||
sample_rate = properties->sampleRate();
|
sample_rate = properties->sampleRate();
|
||||||
|
|
||||||
title = wxString::FromUTF8(Title.toCString(true));
|
title = wxString::FromUTF8(Title.toCString(true));
|
||||||
|
|
@ -75,13 +79,33 @@ AudioInfo Tags::GetAudioInfo()
|
||||||
comment = wxString::FromUTF8(Comment.toCString(true));
|
comment = wxString::FromUTF8(Comment.toCString(true));
|
||||||
|
|
||||||
bValid = true;
|
bValid = true;
|
||||||
|
|
||||||
|
// unsigned int longest = 0;
|
||||||
|
|
||||||
|
// for(TagLib::PropertyMap::ConstIterator i = property_map.begin(); i != property_map.end(); ++i)
|
||||||
|
// {
|
||||||
|
// if (i->first.size() > longest)
|
||||||
|
// {
|
||||||
|
// longest = i->first.size();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// std::cout << "-- TAG (properties) --" << std::endl;
|
||||||
|
|
||||||
|
// for(TagLib::PropertyMap::ConstIterator i = property_map.begin(); i != property_map.end(); ++i)
|
||||||
|
// {
|
||||||
|
// for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j)
|
||||||
|
// {
|
||||||
|
// std::cout << std::left << std::setw(longest) << i->first << " - " << '"' << *j << '"' << std::endl;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bValid = false;
|
bValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { title, artist, album, genre, comment, channels, length, sample_rate, bitrate };
|
return { title, artist, album, genre, comment, channels, length_ms, sample_rate, bitrate };
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tags::SetTitle(std::string title)
|
void Tags::SetTitle(std::string title)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue