/*! Changes the output device */
v8::Handle<v8::Value> Audio::AudioEngine::SetOutputDevice( const v8::Arguments& args ) {
	HandleScope scope;

	// Validate the output args
	if( !args[0]->IsNumber() ) {
		return ThrowException( Exception::TypeError(String::New("setOutputDevice() requires a device index")) );
	}

	Local<Number> deviceIndex = Local<Number>::Cast( args[0] );

	AudioEngine* engine = AudioEngine::Unwrap<AudioEngine>( args.This() );

	// Set the new output device
	engine->m_outputParameters.device = deviceIndex->NumberValue();

	// Restart the audio stream
	engine->restartStream( engine );

	return scope.Close( Undefined() );
} // end AudioEngine::SetOutputDevice()