コード例 #1
0
ファイル: doclist.c プロジェクト: TimofonicJunkRoom/plucker-1
/* Create an app info chunk if missing, return result from the database call */
static void InitPlkrAppInfo
    (
    DmOpenRef docRef    /* reference to document */
    )
    /* THROWS */
{
    UInt16              cardNo;
    MemHandle           handle;
    LocalID             dbID;
    LocalID             appInfoID;
    PlkrAppInfoType*    appInfoP;
    Err                 err;

    err = DmOpenDatabaseInfo( docRef, &dbID, NULL, NULL, &cardNo, NULL );
    THROW_IF( err != errNone, err );

    err = DmDatabaseInfo( cardNo, dbID, NULL, NULL, NULL, NULL, NULL,
            NULL, NULL, &appInfoID, NULL, NULL, NULL );
    THROW_IF( err != errNone, err );

    if ( appInfoID == 0 ) {
        handle = DmNewHandle( docRef, sizeof *appInfoP );
        THROW_IF( handle == NULL, dmErrMemError );

        appInfoID = MemHandleToLocalID( handle );
        DmSetDatabaseInfo( cardNo, dbID, NULL, NULL, NULL, NULL,
            NULL, NULL, NULL, &appInfoID, NULL, NULL, NULL );
    }
    appInfoP = MemLocalIDToLockedPtr( appInfoID, cardNo );
    DmSet( appInfoP, 0, sizeof *appInfoP, 0 );
    CategoryInitialize( ( AppInfoPtr ) appInfoP, strCatDefault );
    MemPtrUnlock( appInfoP );
}
コード例 #2
0
ファイル: vorbis.cpp プロジェクト: codealphago/vireo
Vorbis::Vorbis(const functional::Audio<sound::Sound>& sounds, uint8_t channels, uint32_t bitrate) {
  THROW_IF(sounds.count() >= security::kMaxSampleCount, Unsafe);
  THROW_IF(channels != 1 && channels != 2, InvalidArguments);
  THROW_IF(find(kSampleRate.begin(), kSampleRate.end(), sounds.settings().sample_rate) == kSampleRate.end(), InvalidArguments);

  // Adjust bitrate if requested bitrate is larger than the allowed maximum
  for (uint32_t i = 0; i < kMaxBitrates.size(); ++i) {
    if (sounds.settings().sample_rate < kMaxBitrates[i].min_sample_rate) {
      THROW_IF(i == 0, Unsupported);
      uint32_t max_bitrate = (channels == 1) ? kMaxBitrates[i - 1].mono : kMaxBitrates[i - 1].stereo;
      bitrate = min(bitrate, max_bitrate);
      break;
    }
  }

  _this.reset(new _Vorbis(sounds.settings().sample_rate, channels, bitrate));
  _this->sounds = sounds;
  uint32_t index = 0;
  for (auto sound: _this->sounds) {
    queue<Sample> samples;
    _this->encode_pcm((uint32_t)(index++), samples);
    set_bounds(0, b() + (int)samples.size());
  }

  // Update settings
  _settings = _this->sounds.settings();
  _settings.codec = settings::Audio::Codec::Vorbis;
  _settings.channels = channels;
  _settings.bitrate = bitrate;
}
コード例 #3
0
ファイル: h264_bytestream.cpp プロジェクト: codealphago/vireo
  bool finish_initialization() {
    ANNEXB<H264NalType> annexb_parser(data);
    uint32_t index = 0;

    // Parse SPS
    auto sps_info = annexb_parser(index++);
    THROW_IF(sps_info.type != H264NalType::SPS, Invalid);
    common::Data16 sps = common::Data16(data.data() + sps_info.byte_offset, sps_info.size, NULL);

    // Parse PPS
    auto pps_info = annexb_parser(index++);
    THROW_IF(pps_info.type != H264NalType::PPS, Invalid);
    common::Data16 pps = common::Data16(data.data() + pps_info.byte_offset, pps_info.size, NULL);

    // Save SPS/PPS
    sps_pps.reset(new header::SPS_PPS(sps, pps, NALU_LENGTH_SIZE));

    // Parse frames
    annexb_parser.set_bounds(index, annexb_parser.b());
    for (auto info: annexb_parser) {
      THROW_IF(info.type != H264NalType::IDR && info.type != H264NalType::FRM, Invalid);
      bool keyframe = (info.type == H264NalType::IDR) ? true : false;
      common::Data32 nal = common::Data32(data.data() + info.byte_offset, info.size, NULL);
      samples.push_back({ keyframe, move(nal) });
    }
    return true;
  }
コード例 #4
0
ファイル: vorbis.cpp プロジェクト: codealphago/vireo
 void init() {
   vorbis_info_init(&settings);
   THROW_IF(vorbis_encode_setup_managed(&settings, channels, sample_rate, -1, bitrate, -1) != 0, Invalid);
   THROW_IF(vorbis_encode_ctl(&settings, OV_ECTL_RATEMANAGE2_SET, NULL) != 0, Invalid);
   THROW_IF(vorbis_encode_setup_init(&settings) != 0, Invalid);
   THROW_IF(vorbis_analysis_init(&dsp_state, &settings) != 0, Invalid);
   vorbis_comment_init(&comment);
   vorbis_block_init(&dsp_state, &block);
 }
コード例 #5
0
ファイル: pcm.cpp プロジェクト: codealphago/vireo
PCM::PCM(const functional::Audio<Sample>& track)
  : functional::DirectAudio<PCM, sound::Sound>(), _this(new _PCM(track.settings())) {
  THROW_IF(!track(0).keyframe, InvalidArguments);
  THROW_IF(track.count() >= security::kMaxSampleCount, Unsafe);
  _settings = (settings::Audio) {
    settings::Audio::Codec::Unknown,
    track.settings().timescale,
    track.settings().sample_rate,
    track.settings().channels,
    0,
  };
  _this->init(track);
  set_bounds(0, (uint32_t)_this->sound_to_sample_mapping.size());
}
コード例 #6
0
/*!
 * generic_cl_modinit() - module init
 *
 * This is called by the Linux kernel; either when the module is loaded
 * if compiled as a module, or during the system intialization if the
 * driver is linked into the kernel.
 *
 * This function will parse module parameters if required and then register
 * the generic driver with the USB Device software.
 *
 */
static int generic_cl_modinit (void)
{
        #if !defined(OTG_C99)
        /*! function_ops - operations table for the USB Device Core
         */
        ZERO(generic_function_ops);
        generic_function_ops.device_request=generic_cl_device_request;          /*! called for each received device request */

        /*! class_driver - USB Device Core function driver definition
         */
        ZERO(generic_class_driver);
        generic_class_driver.driver.name = "generic-class";                            /*! driver name */
        generic_class_driver.driver.fops = &generic_function_ops;                             /*! operations table */
        #endif /* defined(OTG_C99) */

        GCLASS = otg_trace_obtain_tag(NULL, "generic-cf");

        // register as usb function driver
        TRACE_MSG0(GCLASS, "REGISTER CLASS");
        THROW_IF (usbd_register_class_function (&generic_class_driver, "generic-class", NULL), error);

        TRACE_MSG0(GCLASS, "REGISTER FINISHED");

        CATCH(error) {
                generic_cl_modexit();
                return -EINVAL;
        }
        return 0;
}
コード例 #7
0
ファイル: mouse-cf.c プロジェクト: GodFox/magx_kernel_xpixl
/*! 
 * mouse_cf_modinit() - module init
 *
 * This is called by the Linux kernel; either when the module is loaded
 * if compiled as a module, or during the system intialization if the 
 * driver is linked into the kernel.
 *
 * This function will parse module parameters if required and then register
 * the mouse driver with the USB Device software.
 *
 */
static int mouse_cf_modinit (void)
{
        int i;
        printk (KERN_INFO "%s: vendor_id: %04x product_id: %04x\n", __FUNCTION__, vendor_id, product_id);

        #if !defined(OTG_C99)
        mouse_cf_global_init();
        mouse_cf_ops_init();
        #endif /* defined(OTG_C99) */
        
        MOUSE = otg_trace_obtain_tag();
        TRACE_MSG2(MOUSE, "vendor_id: %04x product_id: %04x",vendor_id, product_id);

        //if (vendor_id) 
        //        mouse_composite_driver.idVendor = cpu_to_le16(vendor_id);
        //if (product_id) 
        //        mouse_composite_driver.idProduct = cpu_to_le16(product_id);


        // register as usb function driver
	TRACE_MSG0(MOUSE, "REGISTER COMPOSITE");

        THROW_IF (usbd_register_composite_function (&mouse_composite_driver, 
                                        "mouse-random-cf", NULL, mouse_arg_list, NULL), error);

	TRACE_MSG0(MOUSE, "REGISTER FINISHED");

        CATCH(error) {
                otg_trace_invalidate_tag(MOUSE);
                return -EINVAL;
        }
        return 0;
}
コード例 #8
0
ファイル: mesh.cpp プロジェクト: icepic1984/glrfw
mesh parse_stl(const std::string& file)
{
    std::ifstream stl(file, std::ios::in | std::ios::binary);
    mesh mesh;
    if (stl.is_open()) {
        // skip header
        stl.seekg(80, std::ifstream::beg);
        uint32_t num_tri = 0;
        stl.read(reinterpret_cast<char*>(&num_tri), sizeof(uint32_t));
        for (uint32_t i = 0; i < num_tri; i++) {
            // skip face normals
            stl.seekg(3 * sizeof(float), std::ifstream::cur);
            glm::vec3 a, b, c;
            stl.read(reinterpret_cast<char*>(&a), sizeof(a));
            stl.read(reinterpret_cast<char*>(&b), sizeof(b));
            stl.read(reinterpret_cast<char*>(&c), sizeof(c));
            stl.seekg(sizeof(uint16_t), std::ifstream::cur);
            mesh.add_triangle(a, b, c);
        }
    }
    else {
	    THROW_IF(!stl.is_open(),error_type::file_not_found);
    }
    mesh.calculate_normals();
    mesh.centralize();
    return mesh;
}
コード例 #9
0
ファイル: doclist.c プロジェクト: TimofonicJunkRoom/plucker-1
/* Add Plucker document */
void AddDocument
    (
    DocumentInfo*   docInfo,
    Char*           volumeLabel
    )
    /* THROWS */
{
    MemHandle   handle;
    UInt8*      dataPtr;
    UInt16      infoSize;
    UInt16      dataSize;
    UInt16      dbIndex;

    infoSize = sizeof *docInfo - 2 * sizeof( UInt16) - sizeof( Char* );
    if ( docInfo->location == RAM )
        dataSize = 0;
    else
        dataSize = StrLen( docInfo->filename ) + StrLen( volumeLabel ) + 2;

    dbIndex = dmMaxRecordIndex;
    handle  = NewRecord( plkrDocList, &dbIndex, infoSize + dataSize );
    THROW_IF( handle == NULL, DmGetLastErr() );
    dataPtr = MemHandleLock( handle );
    DmWrite( dataPtr, 0, docInfo, infoSize );
    if ( docInfo->location != RAM ) {
        DmWrite( dataPtr, infoSize, docInfo->filename,
            StrLen( docInfo->filename ) + 1 );
        DmWrite( dataPtr, infoSize + StrLen( docInfo->filename ) + 1,
            volumeLabel, StrLen( volumeLabel ) + 1 );
    }
    MemHandleUnlock( handle );
    CloseRecord( handle, true );
}
コード例 #10
0
ファイル: doclist.c プロジェクト: TimofonicJunkRoom/plucker-1
/* Rename document name in document list */
void UpdateDocumentName
    (
    UInt16      index,  /* record index */
    const Char* name,   /* new document name */
    const Char* filename  /* new filename */
    )
    /* THROWS */
{
    MemHandle       handle;
    DocumentData*   handlePtr;

    THROW_IF( name == NULL || *name == '\0', errNoDocumentName );

    handle = OpenRecord( plkrDocList, index );
    THROW_IF( handle == NULL, DmGetLastErr() );

    handlePtr = MemHandleLock( handle );
    DmWrite( handlePtr, OFFSETOF( DocumentData, name ),
        name, StrLen( name ) + 1 );
    if ( handlePtr->location != RAM ) {
        DocumentData*   dataPtr;
        UInt16          infoSize;
        UInt16          dataSize;
        Char            volumeLabel[ LABEL_LEN ];
        UInt16          fileLength;
        UInt16          volumeLabelLength;

        fileLength          = StrLen( handlePtr->data ) + 1;
        volumeLabelLength   = StrLen( handlePtr->data + fileLength ) + 1;
        StrNCopy( volumeLabel, handlePtr->data + fileLength,
            volumeLabelLength );

        MemHandleUnlock( handle );

        infoSize = sizeof *dataPtr;
        dataSize = StrLen( filename ) + StrLen( volumeLabel ) + 2;

        handle  = ResizeRecord( plkrDocList, index, infoSize + dataSize );
        dataPtr = MemHandleLock( handle );
        DmWrite( dataPtr, infoSize, filename, StrLen( filename ) + 1 );
        DmWrite( dataPtr, infoSize + StrLen( filename ) + 1, volumeLabel,
            StrLen( volumeLabel ) + 1 );
    }
    MemHandleUnlock( handle );
    CloseRecord( handle, true );
    DmInsertionSort( plkrDocList, CompareDocumentNames, 0 );
}
コード例 #11
0
ファイル: blan-if.c プロジェクト: R0-Developers/YP-R0_Kernel
int blan_fd_function_enable (struct usbd_function_instance *function_instance)
{
        struct usbd_class_network_channel_descriptor *channel = &blan_class_5 ;
        struct usb_network_private *npd = NULL;
        u32 recv_urb_flags;
#if 0
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17)
        struct usbd_class_ethernet_networking_descriptor *ethernet = &blan_class_4;
        char address_str[14];
        snprintf(address_str, 13, "%02x%02x%02x%02x%02x%02x",
                        local_dev_addr[0], local_dev_addr[1], local_dev_addr[2],
                        local_dev_addr[3], local_dev_addr[4], local_dev_addr[5]);
#else
        char address_str[20];
        sprintf(address_str, "%02x%02x%02x%02x%02x%02x",
                        local_dev_addr[0], local_dev_addr[1], local_dev_addr[2],
                        local_dev_addr[3], local_dev_addr[4], local_dev_addr[5]);
#endif
        ethernet->iMACAddress = usbd_alloc_string(address_str);
#endif
        struct usbd_class_ethernet_networking_descriptor *ethernet = &blan_class_4;
        char address_str[20];

        sprintf(address_str, "%02x%02x%02x%02x%02x%02x", 0, 0, 0, 0, 0, 0);
        ethernet->iMACAddress = usbd_alloc_string(function_instance, address_str);

        //channel->iName = usbd_alloc_string(function_instance, system_utsname.nodename);

        //TRACE_MSG3(NTT, "name: %s strings index imac: %d name: %d",
        //                system_utsname.nodename, ethernet->iMACAddress, channel->iName);

        #if defined(CONFIG_OTG_NETWORK_BLAN_CRC) || defined(CONFIG_OTG_NETWORK_SAFE_CRC)
        recv_urb_flags = 0;
        #else /* defined(CONFIG_OTG_NETWORK_BLAN_CRC) || defined(CONFIG_OTG_NETWORK_SAFE_CRC) */
        recv_urb_flags = USBD_URB_FAST_RETURN | USBD_URB_FAST_FINISH;
        #endif /* defined(CONFIG_OTG_NETWORK_BLAN_CRC) || defined(CONFIG_OTG_NETWORK_SAFE_CRC) */


        THROW_IF(net_fd_function_enable(function_instance,
                        network_blan, net_fd_recv_urb_mdlm,
                        net_fd_start_xmit_mdlm,
                        blan_start_recv, recv_urb_flags
                        ), error);

        THROW_UNLESS((npd = function_instance->privdata), error);

        #if !defined(CONFIG_OTG_NETWORK_BLAN_CRC) && !defined(CONFIG_OTG_NETWORK_SAFE_CRC)
        THROW_UNLESS((npd->blan_recv_task = otg_task_init2("blanrcv", blan_start_recv_task, function_instance, NTT)), error);
        //npd->blan_recv_task->taskdebug = TRUE;
        otg_task_start(npd->blan_recv_task);
        #endif /* !defined(CONFIG_OTG_NETWORK_BLAN_CRC) && !defined(CONFIG_OTG_NETWORK_SAFE_CRC) */

        return 0;

        CATCH(error) {
                return -EINVAL;
        }
}
コード例 #12
0
ファイル: h264_bytestream.cpp プロジェクト: codealphago/vireo
H264_BYTESTREAM::H264_BYTESTREAM(common::Data32&& data)
  : _this(new _H264_BYTESTREAM(move(data))) {
  CHECK(data.count());
  if (_this->finish_initialization()) {
    set_bounds(0, (uint32_t)_this->samples.size());
  } else {
    _this->sps_pps.reset(NULL);
    THROW_IF(true, Uninitialized);
  }
}
コード例 #13
0
ファイル: doclist.c プロジェクト: TimofonicJunkRoom/plucker-1
/* Note: You must release the record when done by using CloseRecord() */
MemHandle ReturnDocInfoHandle
    (
    const UInt16 index  /* record index */
    )
    /* THROWS */
{
    THROW_IF( plkrDocList == NULL, dmErrNoOpenDatabase );

    return OpenRecord( plkrDocList, index );
}
コード例 #14
0
void SceneManager::CmdAncestorOf(SceneNodeID p_SceneNodeID1, SceneNodeID p_SceneNodeID2)
{
	try
	{
		auto l_Itr1 = m_SceneNodeIDMap.find(p_SceneNodeID1);
		THROW_IF(l_Itr1 == m_SceneNodeIDMap.end(), "No SceneNode in scene with ID=" << p_SceneNodeID1);
		const SceneNode::SceneNodePtr l_SceneNode1 = l_Itr1->second;

		auto l_Itr2 = m_SceneNodeIDMap.find(p_SceneNodeID2);
		THROW_IF(l_Itr2 == m_SceneNodeIDMap.end(), "No SceneNode in scene with ID=" << p_SceneNodeID2);
		const SceneNode::SceneNodePtr l_SceneNode2 = l_Itr2->second;

		std::cout << "Result: " << l_SceneNode1->IsAncestorOf(l_SceneNode2) << "\n\n";
	}
	catch (Exception& e)
	{
		LOG_EXCEPTION_CONSOLE(e);
	}
}
コード例 #15
0
ファイル: Figure.cpp プロジェクト: dimock/chess
ScoreType Figure::positionEvaluation(int stage, Figure::Color color, Figure::Type type, int pos)
{
  THROW_IF( stage > 1 || color > 1 || type > 7 || pos < 0 || pos > 63, "invalid figure params" );

  uint8 cmask = ((int8)(color << 7)) >> 7;
  uint8 icmask = ~cmask;
  uint8 i = (mirrorIndex_[pos] & cmask) | (pos & icmask);

  ScoreType e = Evaluator::positionEvaluations_[stage][type][i];
  return e;
}
コード例 #16
0
ファイル: doclist.c プロジェクト: TimofonicJunkRoom/plucker-1
/* Remove record with document info, return result from database call */
void RemoveDocInfoRecord
    (
    UInt16 index    /* record index */
    )
    /* THROWS */
{
    Err err;

    err = RemoveRecord( plkrDocList, index );
    THROW_IF( err != errNone, err );
}
コード例 #17
0
ファイル: scl_elevmap.c プロジェクト: Aerobota/PenguPilot
SIMPLE_THREAD_END


int scl_elevmap_init(void)
{
   THROW_BEGIN();
   scl_socket = scl_get_socket("elev");
   THROW_IF(scl_socket == NULL, -ENODEV);
   tsfloat_init(&elevation, 0.0f);
   simple_thread_start(&thread, thread_func, "elevmap_reader", THREAD_PRIORITY, NULL);
   THROW_END();
}
コード例 #18
0
ファイル: doclist.c プロジェクト: TimofonicJunkRoom/plucker-1
/* Note: You must release the record when done, e.g., by using 
   CloseRecord() */
MemHandle FindDocData
    (
    Char*       name,           /* document name to search for */
    UInt16      numOfElements,  /* number of elements to search, 
                                   set to ALL_ELEMENTS to search 
                                   all elements */
    UInt16*     index           /* upon successful return, the index of
                                   the record, pass NULL for this
                                   parameter if you don't want to
                                   retrieve this value */
    )
    /* THROWS */
{
    THROW_IF( plkrDocList == NULL, dmErrNoOpenDatabase );
    THROW_IF( name == NULL, dmErrInvalidParam );

    if ( numOfElements == ALL_ELEMENTS )
        numOfElements = DmNumRecords( plkrDocList );

    return SearchRAMDocument( plkrDocList, CompareNames, name, numOfElements,
            index );
}
コード例 #19
0
ファイル: scl_power.c プロジェクト: f599gtb/PenguPilot
SIMPLE_THREAD_END


int scl_power_init(void)
{
   THROW_BEGIN();
   scl_socket = scl_get_socket("power");
   THROW_IF(scl_socket == NULL, -ENODEV);
   pthread_mutexattr_init(&mutexattr);
   pthread_mutexattr_setprotocol(&mutexattr, PTHREAD_PRIO_INHERIT);
   pthread_mutex_init(&mutex, &mutexattr);
   simple_thread_start(&thread, thread_func, "power_reader", THREAD_PRIORITY, NULL);
   THROW_END();
}
コード例 #20
0
/* pcd_ocd_modinit - linux module initialization
 *
 * This needs to initialize the ocd, pcd and tcd drivers.  
 *
 * Specifically for each driver:
 *
 * 	obtain tag
 * 	pass ops table address to state machine and get instance address
 * 	call ops.mod_init
 *
 * Note that we automatically provide a default tcd_init if
 * none is set.
 */
static int pcd_ocd_modinit (void)
{
        printk(KERN_INFO"%s\n", __FUNCTION__);

        #if !defined(OTG_C99)
        pcd_global_init();
        #endif /* !defined(OTG_C99) */

        UNLESS(pcd_ops.pcd_init_func) pcd_ops.pcd_init_func = pcd_init_func;
        PCD = otg_trace_obtain_tag();
        THROW_UNLESS(pcd_instance = otg_set_pcd_ops(&pcd_ops), error);
        THROW_IF((pcd_ops.mod_init) ? pcd_ops.mod_init() : 0, error);

        OCD = otg_trace_obtain_tag();
        THROW_UNLESS(ocd_instance = otg_set_ocd_ops(&ocd_ops), error);
        THROW_IF((ocd_ops.mod_init) ? ocd_ops.mod_init() : 0, error);

        CATCH(error) {
                pcd_ocd_modexit();
                return -EINVAL;
        }
        return 0;
}
コード例 #21
0
void SceneManager::CmdReparentSceneNode(SceneNodeID p_SceneNodeID, SceneNodeID p_NewParentID)
{
	try
	{
		THROW_IF(p_SceneNodeID == p_NewParentID, "Cannot add SceneNode to itself");

		auto l_Itr = m_SceneNodeIDMap.find(p_SceneNodeID);
		THROW_IF(l_Itr == m_SceneNodeIDMap.end(), "No SceneNode in scene with ID=" << p_SceneNodeID);
		const SceneNode::SceneNodePtr l_SceneNode = l_Itr->second;

		auto l_ParentItr = m_SceneNodeIDMap.find(p_NewParentID);
		THROW_IF(l_ParentItr == m_SceneNodeIDMap.end(), "No SceneNode in scene with ID=" << p_NewParentID);
		const SceneNode::SceneNodePtr l_ParentSceneNode = l_ParentItr->second;

		THROW_IF(l_SceneNode->IsChildOf(l_ParentSceneNode->GetID()), "Already child of specified SceneNode");

		l_ParentSceneNode->AddChild(l_SceneNode);
		std::cout << "Child reparented.\n";
	}
	catch (Exception& e)
	{
		LOG_EXCEPTION_CONSOLE(e);
	}
}
コード例 #22
0
/*!
 * otg_message_init_l24() - initialize
 */
int otg_message_init_l24(struct otg_instance *otg)
{
        struct proc_dir_entry *message = NULL;
        init_waitqueue_head(&otg_message_queue);

        THROW_IF (!(message = create_proc_entry (OTG_MESSAGE, 0666, 0)), error);
        message->proc_fops = &otg_message_proc_switch_functions;
        CATCH(error) {
                printk(KERN_ERR"%s: creating /proc/otg_message failed\n", __FUNCTION__);
                if (message)
                        remove_proc_entry(OTG_MESSAGE, NULL);
                return -EINVAL;
        }
        return 0;
}
コード例 #23
0
void SceneManager::CmdRemoveSceneNode(SceneNodeID p_SceneNodeID)
{
	try
	{
		auto l_Itr = m_SceneNodeIDMap.find(p_SceneNodeID);
		THROW_IF(l_Itr == m_SceneNodeIDMap.end(), "No SceneNode in scene with ID=" << p_SceneNodeID);

		const SceneNode::SceneNodePtr l_SceneNode = l_Itr->second;
		l_SceneNode->GetParent()->RemoveChild(l_SceneNode);
		std::cout << "SceneNode removed.\n";
	}
	catch (Exception& e)
	{
		LOG_EXCEPTION_CONSOLE(e);
	}
}
コード例 #24
0
ファイル: scl_gps.c プロジェクト: aaxixi/PenguPilot
SIMPLE_THREAD_END


int scl_gps_init(void)
{
   ASSERT_ONCE();
   THROW_BEGIN();
   scl_socket = scl_get_socket("gps");
   THROW_IF(scl_socket == NULL, -ENODEV);
   pthread_mutexattr_init(&mutexattr);
   pthread_mutexattr_setprotocol(&mutexattr, PTHREAD_PRIO_INHERIT);
   pthread_mutex_init(&mutex, &mutexattr);
   interval_init(&interval);
   simple_thread_start(&thread, thread_func, "gps_reader", THREAD_PRIORITY, NULL);
   THROW_END();
}
コード例 #25
0
ファイル: data.cpp プロジェクト: codealphago/vireo
Data<Y, X>::Data(int fd, std::function<void(int fd)> deleter)
  : domain::Interval<Data<Y, X>, Y, X>(0, 0) {
  struct stat sb;
  CHECK(fstat(fd, &sb) != -1);
  size_t size = (size_t)sb.st_size;
  CHECK(size != 0);
  THROW_IF(size > std::numeric_limits<X>::max(), Unsupported, "File size too large");
  int fd_copy = dup(fd);
  CHECK(fd_copy != 0);
  this->set_bounds(0, (X)size);
  _this = new _Data<Y, X>();
  auto bytes = (const Y*)mmap(nullptr, size, PROT_READ, MAP_SHARED, fd_copy, 0);
  CHECK(bytes != MAP_FAILED);
  _this->bytes = bytes;
  _this->capacity = (X)size;
  _this->deleter = [fd_copy, size, deleter, fd](Y* p) { munmap(p, size); close(fd_copy); if (deleter) { deleter(fd); } };
}
コード例 #26
0
ファイル: mxc-gptcr.c プロジェクト: GodFox/magx_kernel_xpixl
/*!
 * mxc_gptcr_ocd_mod_init() - initial tcd setup
 * Allocate interrupts and setup hardware.
 */
int mxc_gptcr_mod_init (int divisor, int multiplier)
{
        int timer;

	if (*_reg_GPT_GPTCR & 0x1)
		mxc_shared_int = 1;
	else
		mxc_shared_int = 0;
	
        if (mxc_shared_int){
		printk (KERN_INFO"Using shared interrupt for timer 3 \n");
		timer = request_irq (INT_GPT, mxc_gptcr_timer_int_hndlr, SA_INTERRUPT | SA_SHIRQ, 
                                UDC_NAME " OTG TIMER", (int *) &dev_id);
	}
	else{
		printk (KERN_INFO"OTG TIMER is the only ISR for timer 3 \n");
		timer = request_irq (INT_GPT, mxc_gptcr_timer_int_hndlr, SA_INTERRUPT | SA_SHIRQ, 
                                UDC_NAME " OTG TIMER", (int *) &dev_id);
	        /* disable and reset GPT
		*/
		*_reg_GPT_GPTCR &= ~0x00000001;
		*_reg_GPT_GPTCR |= (1<<15);
		while ((*_reg_GPT_GPTCR & (1<<15)) != 0) ;
		*_reg_GPT_GPTPR = 0;
		*_reg_GPT_GPTCR = (0x1 << 9) | (0x2 << 6);
		*_reg_GPT_GPTCR |= 0x1;      
	}

	TRACE_MSG0(OCD, "1. Interrupts requested");

        THROW_IF(timer, error);

        mxc_gptcr_divisor = divisor;
        mxc_gptcr_multiplier = multiplier;

	return 0;

        CATCH(error) {
                return -EINVAL;
        }
        return 0;
}
コード例 #27
0
// Convert the raw floating point numbers to bytes, then write them to a file
// after a simple header encoding the file type, the resolution, and number of bits
// per channel.
string ppm_writer::Write( string file_name, const Raster *raster )
    {
    const unsigned width  = raster->width;
    const unsigned height = raster->height;
    string full_name = file_name + ".ppm";

    // Don't attempt to write anything if the raster is empty.
    if( width == 0 || height == 0 ) return "";

    // Open the file for writing in binary.  Return an empty
    // string on failure.
    ofstream fout( full_name.c_str(), ofstream::binary );
	THROW_IF(!fout, FileIOException, "Could not create file %s", full_name.c_str());

    // Write the header information, which consists of five fields,
    // each terminated by a newline character.
    fout << "P6"    << "\n" 
         << width   << " "   // width and height are separated by a space.
         << height  << "\n"
         << 255     << "\n";

    int  num_bytes = 3 * width * height;
    char *ppm = new char[ num_bytes ];

    Color *p = raster->pixels;
    char  *q = ppm;
    for( unsigned i = 0; i < width * height; i++ )
        {
        Color c = *p++;
        *q++ = clamp( c.red   );
        *q++ = clamp( c.green );
        *q++ = clamp( c.blue  );
        }

    // Write the actual data, which consists of triples of bytes.
    fout.write( ppm, num_bytes );
    fout.close();

    // Return the full file name to indicate success.
    return full_name;
    }
コード例 #28
0
ファイル: pcm.cpp プロジェクト: codealphago/vireo
 void init(const functional::Audio<Sample>& _samples) {
   samples = _samples;
   uint32_t bytes_accumulated = 0;
   vector<uint32_t> indices;
   for (uint32_t index = 0; index < samples.count(); ++index) {
     const auto& sample = samples(index);
     uint32_t sample_size = sample.byte_range.available ? sample.byte_range.size : sample.nal().count();
     CHECK(sample_size <= bytes_per_sound());
     indices.push_back(index);
     bytes_accumulated += sample_size;
     THROW_IF(bytes_accumulated > bytes_per_sound(), Unsupported);  // splitting bytes of a sample into multiple sounds not supported
     if (bytes_accumulated == bytes_per_sound()) {  // enough bytes accumulated, create a sound
       sound_to_sample_mapping.push_back(indices);
       bytes_accumulated = 0;
       indices.clear();
     }
   }
   if (bytes_accumulated) {
     sound_to_sample_mapping.push_back(indices);
   }
 }
コード例 #29
0
int mxc_iomux_gpio_isp1301_set (struct otg_instance *otg, int usb_mode)
{

        int gpio = 1;

        printk (KERN_INFO"MXC gpio setting for isp1301\n");

        isp1301_mod_init(otg, &zasevb_isp1301_bh);

        TRACE_MSG0(otg->tcd->TAG, "5. IOMUX and GPIO Interrupt Configuration");
        iomux_config_mux(PIN_GPIO2, OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);

        //Setting interrupt for ISP1301
        #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
        set_irq_type(IOMUX_TO_IRQ(PIN_GPIO2), IRQF_TRIGGER_FALLING);
        #else
        set_irq_type(IOMUX_TO_IRQ(PIN_GPIO2), IRQT_FALLING);
        #endif
        gpio = request_irq(IOMUX_TO_IRQ(PIN_GPIO2), zasevb_gpio_int_hndlr,
                        0, "ISP1301", (void *)&ocd_ops);
        THROW_IF(gpio, error);


        iomux_config_mux(PIN_USB_XRXD,  OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);
        iomux_config_mux(PIN_USB_VMOUT, OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);
        iomux_config_mux(PIN_USB_VPOUT, OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);
        iomux_config_mux(PIN_USB_VPIN,  OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);
        iomux_config_mux(PIN_USB_TXENB, OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);
        iomux_config_mux(PIN_USB_VMIN,  OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);



        CATCH(error) {
                printk(KERN_INFO"%s: failed\n", __FUNCTION__);
                UNLESS (gpio) gpio_free_irq (ZGPIO_PORT, ZGPIO_PIN, GPIO_HIGH_PRIO);
                return -EINVAL;
        }

        return 0;
}
コード例 #30
0
ファイル: doclist.c プロジェクト: TimofonicJunkRoom/plucker-1
/* Create database for list of documents */
static void CreateDocList( void )
    /* THROWS */
{
    UInt16  cardNo;
    Err     err;
    LocalID dbID;
    UInt16  version;

    /* list is always put on first card in RAM */
    cardNo  = 0;
    err     = errNone;

    err = DmCreateDatabase( cardNo, PlkrDocListName, ViewerAppID,
            PlkrDocListType, false );
    THROW_IF( err != errNone, memErrNotEnoughSpace );

    dbID    = DmFindDatabase( cardNo, PlkrDocListName );
    version = PlkrDocListVersion;
    err     = DmSetDatabaseInfo( cardNo, dbID, NULL, NULL, &version, 
                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );

    plkrDocList = DmOpenDatabaseByTypeCreator( PlkrDocListType, ViewerAppID,
                    dmModeReadWrite );

    ErrTry {
        InitPlkrAppInfo( plkrDocList );
    }
    ErrCatch( UNUSED_PARAM( err ) ) {
        LocalID dbID;

        DmOpenDatabaseInfo( plkrDocList, &dbID, NULL, NULL, &cardNo, NULL );
        CloseDatabase( plkrDocList );
        DmDeleteDatabase( cardNo, dbID );
        MSG( "Couldn't initialize Plkr document list [ appInfo ]\n" );
        ErrThrow( memErrNotEnoughSpace );
    } ErrEndCatch
}