summaryrefslogtreecommitdiff
path: root/gtk2_ardour/sfdb_freesound_mootcher.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-01-18 18:43:43 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-01-18 18:43:43 +0000
commit577469a06aa48310ec5cd9a6428f32c35fca5fcb (patch)
tree9ac07e8d8155025a978e97b675db257afc8b21ca /gtk2_ardour/sfdb_freesound_mootcher.cc
parent759f1216afa4487441106d3b2c17e47651f57d11 (diff)
colinf's 2011-12-08 patch for freesound mootcher (add stop, remove URI, clear barberpole, etc)
git-svn-id: svn://localhost/ardour2/branches/3.0@11265 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/sfdb_freesound_mootcher.cc')
-rw-r--r--gtk2_ardour/sfdb_freesound_mootcher.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/gtk2_ardour/sfdb_freesound_mootcher.cc b/gtk2_ardour/sfdb_freesound_mootcher.cc
index 69c13794f6..3b558e17e1 100644
--- a/gtk2_ardour/sfdb_freesound_mootcher.cc
+++ b/gtk2_ardour/sfdb_freesound_mootcher.cc
@@ -139,7 +139,7 @@ void Mootcher::setcUrlOptions()
// Allow connections to time out (without using signals)
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
- curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10);
+ curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 30);
}
@@ -295,7 +295,7 @@ int audioFileWrite(void *buffer, size_t size, size_t nmemb, void *file)
};
//------------------------------------------------------------------------
-std::string Mootcher::getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, Gtk::ProgressBar *progress_bar)
+std::string Mootcher::getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, SoundFileBrowser *caller)
{
ensureWorkingDir();
std::string audioFileName = basePath + "snd/" + ID + "-" + originalFileName;
@@ -332,17 +332,20 @@ std::string Mootcher::getAudioFile(std::string originalFileName, std::string ID,
curl_easy_setopt(curl, CURLOPT_WRITEDATA, theFile);
std::cerr << "downloading " << audioFileName << " from " << audioURL << "..." << std::endl;
+ /* hack to get rid of the barber-pole stripes */
+ caller->progress_bar.hide();
+ caller->progress_bar.show();
curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 0); // turn on the progress bar
curl_easy_setopt (curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
- curl_easy_setopt (curl, CURLOPT_PROGRESSDATA, progress_bar);
+ curl_easy_setopt (curl, CURLOPT_PROGRESSDATA, caller);
CURLcode res = curl_easy_perform(curl);
fclose(theFile);
curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 1); // turn off the progress bar
- progress_bar->set_fraction(0.0);
-
+ caller->progress_bar.set_fraction(0.0);
+
if( res != 0 ) {
std::cerr << "curl error " << res << " (" << curl_easy_strerror(res) << ")" << std::endl;
remove( audioFileName.c_str() );
@@ -359,14 +362,18 @@ std::string Mootcher::getAudioFile(std::string originalFileName, std::string ID,
}
//---------
-int Mootcher::progress_callback(void *bar, double dltotal, double dlnow, double ultotal, double ulnow)
+int Mootcher::progress_callback(void *caller, double dltotal, double dlnow, double ultotal, double ulnow)
{
+SoundFileBrowser *sfb = (SoundFileBrowser *) caller;
//XXX I hope it's OK to do GTK things in this callback. Otherwise
// I'll have to do stuff like in interthread_progress_window.
+ if (sfb->freesound_stop) {
+ return -1;
+ }
+
- Gtk::ProgressBar *progress_bar = (Gtk::ProgressBar *) bar;
- progress_bar->set_fraction(dlnow/dltotal);
+ sfb->progress_bar.set_fraction(dlnow/dltotal);
/* Make sure the progress widget gets updated */
while (Glib::MainContext::get_default()->iteration (false)) {
/* do nothing */