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;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
wxSystemAppearance m_Theme = wxSystemSettings::GetAppearance();
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------
|
||||
bool bAutoplay = false;
|
||||
|
|
@ -262,10 +259,6 @@ class MainFrame : public wxFrame
|
|||
// Frame resize event handler
|
||||
void OnResizeFrame(wxSizeEvent& event);
|
||||
|
||||
// Splitter window sash pos event handler
|
||||
void OnTopSplitterSashPosChanged(wxSplitterEvent& event);
|
||||
void OnBottomSplitterSashPosChanged(wxSplitterEvent& event);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Timer update event handler
|
||||
void UpdateElapsedTime(wxTimerEvent& event);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "Utility/Log.hpp"
|
||||
#include "Utility/Paths.hpp"
|
||||
|
||||
#include <exception>
|
||||
#include <vector>
|
||||
|
||||
#include <wx/brush.h>
|
||||
|
|
@ -35,6 +36,7 @@
|
|||
#include <wx/gdicmn.h>
|
||||
#include <wx/pen.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
#include <sndfile.hh>
|
||||
|
||||
WaveformViewer::WaveformViewer(wxWindow* window, wxDataViewListCtrl& library,
|
||||
|
|
@ -178,6 +180,8 @@ void WaveformViewer::UpdateWaveformBitmap()
|
|||
|
||||
std::vector<float> waveform;
|
||||
|
||||
try
|
||||
{
|
||||
// TODO, FIXME: Don't reload file on every window resize
|
||||
snd_file.read(&sample.at(0), frames * channels);
|
||||
|
||||
|
|
@ -250,6 +254,12 @@ void WaveformViewer::UpdateWaveformBitmap()
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,8 +21,11 @@
|
|||
#include "Utility/Tags.hpp"
|
||||
#include "SampleHiveConfig.hpp"
|
||||
|
||||
// #include <iomanip>
|
||||
|
||||
#include <taglib/tag.h>
|
||||
#include <taglib/fileref.h>
|
||||
// #include <taglib/tpropertymap.h>
|
||||
|
||||
#ifndef USE_SYSTEM_INCLUDE_PATH
|
||||
#include <taglib/toolkit/tstring.h>
|
||||
|
|
@ -44,7 +47,7 @@ Tags::~Tags()
|
|||
AudioInfo Tags::GetAudioInfo()
|
||||
{
|
||||
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);
|
||||
|
||||
|
|
@ -52,6 +55,7 @@ AudioInfo Tags::GetAudioInfo()
|
|||
{
|
||||
TagLib::Tag* tag = f.tag();
|
||||
TagLib::AudioProperties* properties = f.audioProperties();
|
||||
// TagLib::PropertyMap property_map = f.file()->properties();
|
||||
|
||||
TagLib::String Title = tag->title();
|
||||
TagLib::String Artist = tag->artist();
|
||||
|
|
@ -64,8 +68,8 @@ AudioInfo Tags::GetAudioInfo()
|
|||
|
||||
bitrate = properties->bitrate();
|
||||
channels = properties->channels();
|
||||
length = properties->lengthInMilliseconds();
|
||||
int length_sec = properties->lengthInSeconds();
|
||||
length_ms = properties->lengthInMilliseconds();
|
||||
length_s = properties->lengthInSeconds();
|
||||
sample_rate = properties->sampleRate();
|
||||
|
||||
title = wxString::FromUTF8(Title.toCString(true));
|
||||
|
|
@ -75,13 +79,33 @@ AudioInfo Tags::GetAudioInfo()
|
|||
comment = wxString::FromUTF8(Comment.toCString(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
|
||||
{
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue