session-utils: use session's sample-rate
This commit is contained in:
parent
8bb4ac0ac7
commit
53d8b45457
@ -1,6 +1,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <glibmm.h>
|
||||||
|
|
||||||
#include "pbd/debug.h"
|
#include "pbd/debug.h"
|
||||||
#include "pbd/event_loop.h"
|
#include "pbd/event_loop.h"
|
||||||
@ -9,6 +9,8 @@
|
|||||||
#include "pbd/pthread_utils.h"
|
#include "pbd/pthread_utils.h"
|
||||||
|
|
||||||
#include "ardour/audioengine.h"
|
#include "ardour/audioengine.h"
|
||||||
|
#include "ardour/filename_extensions.h"
|
||||||
|
#include "ardour/types.h"
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@ -88,7 +90,7 @@ SessionUtils::init ()
|
|||||||
{
|
{
|
||||||
if (!ARDOUR::init (false, true, localedir)) {
|
if (!ARDOUR::init (false, true, localedir)) {
|
||||||
cerr << "Ardour failed to initialize\n" << endl;
|
cerr << "Ardour failed to initialize\n" << endl;
|
||||||
::exit (1);
|
::exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_loop = new MyEventLoop ("util");
|
event_loop = new MyEventLoop ("util");
|
||||||
@ -101,6 +103,7 @@ SessionUtils::init ()
|
|||||||
test_receiver.listen_to (warning);
|
test_receiver.listen_to (warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO return NULL, rather than exit() ?!
|
||||||
static Session * _load_session (string dir, string state)
|
static Session * _load_session (string dir, string state)
|
||||||
{
|
{
|
||||||
AudioEngine* engine = AudioEngine::create ();
|
AudioEngine* engine = AudioEngine::create ();
|
||||||
@ -110,6 +113,20 @@ static Session * _load_session (string dir, string state)
|
|||||||
::exit (EXIT_FAILURE);
|
::exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float sr;
|
||||||
|
SampleFormat sf;
|
||||||
|
|
||||||
|
std::string s = Glib::build_filename (dir, state + statefile_suffix);
|
||||||
|
if (Session::get_info_from_path (s, sr, sf) == 0) {
|
||||||
|
if (engine->set_sample_rate (sr)) {
|
||||||
|
std::cerr << "Cannot set session's samplerate.\n";
|
||||||
|
::exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "Cannot get samplerate from session.\n";
|
||||||
|
::exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
init_post_engine ();
|
init_post_engine ();
|
||||||
|
|
||||||
if (engine->start () != 0) {
|
if (engine->start () != 0) {
|
||||||
@ -130,16 +147,16 @@ SessionUtils::load_session (string dir, string state)
|
|||||||
s = _load_session (dir, state);
|
s = _load_session (dir, state);
|
||||||
} catch (failed_constructor& e) {
|
} catch (failed_constructor& e) {
|
||||||
cerr << "failed_constructor: " << e.what() << "\n";
|
cerr << "failed_constructor: " << e.what() << "\n";
|
||||||
exit (EXIT_FAILURE);
|
::exit (EXIT_FAILURE);
|
||||||
} catch (AudioEngine::PortRegistrationFailure& e) {
|
} catch (AudioEngine::PortRegistrationFailure& e) {
|
||||||
cerr << "PortRegistrationFailure: " << e.what() << "\n";
|
cerr << "PortRegistrationFailure: " << e.what() << "\n";
|
||||||
exit (EXIT_FAILURE);
|
::exit (EXIT_FAILURE);
|
||||||
} catch (exception& e) {
|
} catch (exception& e) {
|
||||||
cerr << "exception: " << e.what() << "\n";
|
cerr << "exception: " << e.what() << "\n";
|
||||||
exit (EXIT_FAILURE);
|
::exit (EXIT_FAILURE);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
cerr << "unknown exception.\n";
|
cerr << "unknown exception.\n";
|
||||||
exit (EXIT_FAILURE);
|
::exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user