[Summary] Session will try to switch the device to the sample rate it was created with.

This commit is contained in:
Greg Zharun 2014-08-31 16:36:55 +03:00
parent 76ece84d51
commit d3c7c3fdfa
5 changed files with 45 additions and 3 deletions

View file

@ -4016,15 +4016,17 @@ ARDOUR_UI::sr_mismatch_dialog (framecnt_t desired, framecnt_t actual)
ArdourDialog dialog (_("Sample Rate Mismatch"), true);
Label message (string_compose (_("\
This session was created with a sample rate of %1 Hz, but\n\
%2 is currently running at %3 Hz. If you load this session,\n\
%2 is currently running at %3 Hz. If you load this session,\n\
device will be switched to the session sample rate value. \n\
If an attemp to switch the device is unsuccessful\n\
audio may be played at the wrong sample rate.\n"), desired, PROGRAM_NAME, actual));
image->set_alignment(ALIGN_CENTER, ALIGN_TOP);
hbox->pack_start (*image, PACK_EXPAND_WIDGET, 12);
hbox->pack_end (message, PACK_EXPAND_PADDING, 12);
dialog.get_vbox()->pack_start(*hbox, PACK_EXPAND_PADDING, 6);
dialog.add_button (_("Do not load session"), RESPONSE_REJECT);
dialog.add_button (_("Load session anyway"), RESPONSE_ACCEPT);
dialog.add_button (_("Cancel"), RESPONSE_REJECT);
dialog.add_button (_("Accept"), RESPONSE_ACCEPT);
dialog.set_default_response (RESPONSE_ACCEPT);
dialog.set_position (WIN_POS_CENTER);
message.show();

View file

@ -48,6 +48,9 @@ public:
static EngineStateController* instance();
void set_session(Session* session);
void remove_session ();
//Interfaces
void available_backends(std::vector<const AudioBackendInfo*>&);
@ -286,6 +289,8 @@ private:
ARDOUR::framecnt_t _desired_sample_rate;
bool _have_control;
Session* _session;
// Engine connections stuff
PBD::ScopedConnectionList update_connections;
PBD::ScopedConnectionList session_connections;

View file

@ -291,6 +291,9 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
PBD::Signal0<void> RecordStateChanged;
/* Emited when session is loaded */
PBD::Signal0<void> SessionLoaded;
/* Transport mechanism signals */
/** Emitted on the following changes in transport state:

View file

@ -9,6 +9,7 @@
#include "ardour/engine_state_controller.h"
#include "ardour/audioengine.h"
#include "ardour/session.h"
#include "ardour/rc_configuration.h"
#include "ardour/data_type.h"
@ -81,6 +82,22 @@ EngineStateController::~EngineStateController()
}
void
EngineStateController::set_session(Session* session)
{
_session = session;
_session->SessionLoaded.connect_same_thread (session_connections, boost::bind (&EngineStateController::_on_session_loaded, this) );
}
void
EngineStateController::remove_session ()
{
session_connections.drop_connections ();
_session = 0;
}
XMLNode&
EngineStateController::serialize_audio_midi_settings()
{
@ -1176,6 +1193,17 @@ EngineStateController::get_physical_midi_output_states (std::vector<PortState>&
}
void
EngineStateController::_on_session_loaded ()
{
if (_session && _desired_sample_rate && set_new_sample_rate_in_controller(_desired_sample_rate) )
{
push_current_state_to_backend(false);
SampleRateChanged(); // emit a signal
}
}
void
EngineStateController::_on_sample_rate_change(framecnt_t new_sample_rate)
{

View file

@ -357,6 +357,8 @@ Session::Session (AudioEngine &eng,
_engine.set_session (this);
_engine.reset_timebase ();
EngineStateController::instance()->set_session(this);
// Waves Tracks: always create master track
if ( ARDOUR::Profile->get_trx () ) {
create_master_track();
@ -407,6 +409,7 @@ Session::Session (AudioEngine &eng,
_is_new = false;
SessionLoaded();
BootMessage (_("Session loading complete"));
}
@ -512,6 +515,7 @@ Session::destroy ()
drop_connections ();
_engine.remove_session ();
EngineStateController::instance()->remove_session();
/* deregister all ports - there will be no process or any other
* callbacks from the engine any more.