Ejemplo n.º 1
0
EncoderSettingsPointer EncoderFactory::getEncoderSettings(Encoder::Format format,
    UserSettingsPointer pConfig) const
{
    if (format.internalName == ENCODING_WAVE) {
        return std::make_shared<EncoderWaveSettings>(pConfig, format);
    } else if (format.internalName == ENCODING_AIFF) {
        return std::make_shared<EncoderWaveSettings>(pConfig, format);
    } else if (format.internalName == ENCODING_FLAC) {
        return std::make_shared<EncoderFlacSettings>(pConfig);
    } else if (format.internalName == ENCODING_MP3) {
        return std::make_shared<EncoderMp3Settings>(pConfig);
    } else if (format.internalName == ENCODING_OGG) {
        return std::make_shared<EncoderVorbisSettings>(pConfig);
    } else if (format.internalName == ENCODING_OPUS) {
        return std::make_shared<EncoderOpusSettings>(pConfig);
    } else {
        qWarning() << "Unsupported format requested! " << format.internalName;
        DEBUG_ASSERT(false);
        return std::make_shared<EncoderWaveSettings>(pConfig, format);
    }
}
Ejemplo n.º 2
0
SINT SoundSourceWV::seekSampleFrame(SINT frameIndex) {
    DEBUG_ASSERT(isValidFrameIndex(m_curFrameIndex));

    if (frameIndex >= getMaxFrameIndex()) {
        // EOF reached
        m_curFrameIndex = getMaxFrameIndex();
        return m_curFrameIndex;
    }

    if (frameIndex == m_curFrameIndex) {
        return m_curFrameIndex;
    }

    if (WavpackSeekSample(m_wpc, frameIndex) == true) {
        m_curFrameIndex = frameIndex;
        return frameIndex;
    } else {
        kLogger.debug() << "could not seek to frame #" << frameIndex;
        return WavpackGetSampleIndex(m_wpc);
    }
}
Ejemplo n.º 3
0
void Foreman::initialize() {
  if (cpu_id_ >= 0) {
    // We can pin the foreman thread to a CPU if specified.
    ThreadUtil::BindToCPU(cpu_id_);
  }
  DEBUG_ASSERT(query_dag_ != nullptr);

  initializeState();

  // Collect all the workorders from all the relational operators in the DAG.
  const dag_node_index dag_size = query_dag_->size();
  for (dag_node_index index = 0; index < dag_size; ++index) {
    if (checkAllBlockingDependenciesMet(index)) {
      query_dag_->getNodePayloadMutable(index)->informAllBlockingDependenciesMet();
      processOperator(index, false);
    }
  }

  // Dispatch the WorkOrders generated so far.
  dispatchWorkerMessages(0, 0);
}
Ejemplo n.º 4
0
Archivo: cbuf.c Proyecto: danscu/lk
size_t cbuf_write_char(cbuf_t *cbuf, char c, bool canreschedule)
{
	DEBUG_ASSERT(cbuf);

	enter_critical_section();

	size_t ret = 0;
	if (cbuf_space_avail(cbuf) > 0) {
		cbuf->buf[cbuf->head] = c;

		cbuf->head = INC_POINTER(cbuf, cbuf->head, 1);
		ret = 1;

		if (cbuf->head != cbuf->tail)
			event_signal(&cbuf->event, canreschedule);
	}

	exit_critical_section();

	return ret;
}
Ejemplo n.º 5
0
// This removes |node| from the list whose first node is |list_head|.  This
// returns the new list head, or nullptr if the list has become empty.
FutexNode* FutexNode::RemoveNodeFromList(FutexNode* list_head,
                                         FutexNode* node) {
    if (node->queue_next_ == node) {
        DEBUG_ASSERT(node->queue_prev_ == node);
        // This list is a singleton, so after removing the node, the list
        // becomes empty.
        list_head = nullptr;
    } else {
        if (node == list_head) {
            // This node is the list head, so adjust the list head to be
            // the next node.
            list_head = node->queue_next_;
        }

        // Remove the node from the list.
        node->queue_next_->queue_prev_ = node->queue_prev_;
        node->queue_prev_->queue_next_ = node->queue_next_;
    }
    node->MarkAsNotInQueue();
    return list_head;
}
Ejemplo n.º 6
0
HRESULT CUIElement::GetRoot(IUIElement** ppRoot)
{
	DEBUG_ASSERT(ppRoot) ;
	IF_RETURN(NULL == ppRoot, E_INVALIDARG) ;
	*ppRoot = NULL ;

	CComPtr<IUIElement> pParentTemp = GetEntity<IUIElement>() ;
	while (pParentTemp)
	{
		CComPtr<IUIElement> pElement ;
		pParentTemp->GetParent(&pElement) ;
		IF_BREAK(NULL == pElement) ;
		pParentTemp = pElement ;
	}

	if (pParentTemp)
	{
		return pParentTemp->QueryInterface(__uuidof(IUIElement), (VOID**)ppRoot) ;
	}
	return E_FAIL ;
}
Ejemplo n.º 7
0
size_t cbuf_write_char(cbuf_t* cbuf, char c) {
    DEBUG_ASSERT(cbuf);

    size_t ret = 0;
    {
        AutoSpinLock guard(&cbuf->lock);

        if (cbuf_space_avail(cbuf) > 0) {
            cbuf->buf[cbuf->head] = c;

            cbuf->head = inc_pointer(cbuf, cbuf->head, 1);
            ret = 1;
        }
    }

    if (ret > 0) {
        event_signal(&cbuf->event, true);
    }

    return ret;
}
Ejemplo n.º 8
0
archi_symtab_idlist* archi_variabledef_typecheck( archi_symtab *st, archi_ast_node *n, const char* id, archi_symtab_idlist *type_list )
{
  DEBUG_ASSERT( st && n && id && type_list ) ;

  while( type_list ){
    if( !strcmp(n->data_type, archi_symtab_idlist_id(type_list)) ){
      archi_ast_node *l = archi_symtab_lookup( st, id ) ;
      if( l != NULL ){  
        EMSG_REDECLARATION( n, id ) ;
        EMSG_PREVIOUS_DECLARATION( n, id, l->linenr ) ;
        break ;
      }
      else{ archi_symtab_insert( st, id, n ) ; break ;}    
    }
    type_list = archi_symtab_idlist_next(type_list) ;
  }

  if( !type_list ) EMSG_WRONG_TYPE( n, id, " " ) ;

  return type_list ;
}
Ejemplo n.º 9
0
Archivo: mmu.c Proyecto: taphier/lk
void arm_mmu_init(void)
{
    /* unmap the initial mapings that are marked temporary */
    struct mmu_initial_mapping *map = mmu_initial_mappings;
    while (map->size > 0) {
        if (map->flags & MMU_INITIAL_MAPPING_TEMPORARY) {
            vaddr_t va = map->virt;
            size_t size = map->size;

            DEBUG_ASSERT(IS_SECTION_ALIGNED(size));

            while (size > 0) {
                arm_mmu_unmap_section(va);
                va += MB;
                size -= MB;
            }
        }
        map++;
    }
    arm_after_invalidate_tlb_barrier();
}
std::string StageStart::GetClearAnimStr()
{
	const GameManager *pGameManager = GameRegister::GetInstance()->GetManagerGame();
	std::string retStr = "";

	switch( pGameManager->GetStageType() ){
	default:
		DEBUG_ASSERT( 0, "ゲームのクリア条件が想定外");
		break;
	case GameManager::TYPE_TIME:
		retStr = "time";
		break;
	case GameManager::TYPE_DESTROY:
		retStr = "destroy";
		break;
	case GameManager::TYPE_DESTROY_BOSS:
		retStr = "boss";
		break;
	}
	return retStr;
}
Ejemplo n.º 11
0
void Game::Start()
{
	DEBUG_ASSERT(m_CurrentScene.get() != NULL);
	
	Uint32 lastTime	= SDL_GetTicks();
	m_Quit = false;
	
	while(!m_Quit)
	{
		// CLEAR SCREEN
		m_DisplayContext.SetColor(Color::Black);
		m_DisplayContext.ClearScreen();

		// MANAGE INPUT DEVICES
		m_KeyboardDevice.Update();
		
		// MANAGE EVENTS
		ManageEvents();
		
		Uint32 currentTime = SDL_GetTicks();
		double deltaTime = (double)(currentTime - lastTime) / 1000.0;
		
		lastTime = currentTime;
		
		// MANAGE CURRENT SCENE
		m_CurrentScene->Update(deltaTime);
		m_Framerate.Update(deltaTime);
		
		// RENDER GAME OBJECTS
		m_CurrentScene->Render(&m_DisplayContext);
		m_Framerate.Render(&m_DisplayContext);
		
		// FLIP (SWAP) DISPLAY BUFFERS
		m_DisplayContext.Flip();
		
#ifdef USE_FRAMERATE_LIMITER
		m_Framerate.LimitFramerate();
#endif
	}
}
Ejemplo n.º 12
0
void ProcessDispatcher::SetStateLocked(State s) {
    LTRACEF("process %p: state %u (%s)\n", this, static_cast<unsigned int>(s), StateToString(s));

    DEBUG_ASSERT(get_lock()->lock().IsHeld());

    // look for some invalid state transitions
    if (state_ == State::DEAD && s != State::DEAD) {
        panic("ProcessDispatcher::SetStateLocked invalid state transition from DEAD to !DEAD\n");
        return;
    }

    // transitions to your own state are okay
    if (s == state_)
        return;

    state_ = s;

    if (s == State::DYING) {
        // send kill to all of our threads
        KillAllThreadsLocked();
    }
}
Ejemplo n.º 13
0
TrackPointer BaseTrackPlayerImpl::unloadTrack() {
    if (!m_pLoadedTrack) {
        // nothing to do
        return TrackPointer();
    }

    // Save the loops that are currently set in a loop cue. If no loop cue is
    // currently on the track, then create a new one.
    double loopStart = m_pLoopInPoint->get();
    double loopEnd = m_pLoopOutPoint->get();
    if (loopStart != kNoTrigger && loopEnd != kNoTrigger && loopStart <= loopEnd) {
        CuePointer pLoopCue;
        QList<CuePointer> cuePoints(m_pLoadedTrack->getCuePoints());
        QListIterator<CuePointer> it(cuePoints);
        while (it.hasNext()) {
            CuePointer pCue(it.next());
            if (pCue->getType() == Cue::LOOP) {
                pLoopCue = pCue;
            }
        }
        if (!pLoopCue) {
            pLoopCue = m_pLoadedTrack->createAndAddCue();
            pLoopCue->setType(Cue::LOOP);
        }
        pLoopCue->setPosition(loopStart);
        pLoopCue->setLength(loopEnd - loopStart);
    }

    disconnectLoadedTrack();

    // Do not reset m_pReplayGain here, because the track might be still
    // playing and the last buffer will be processed.

    m_pPlay->set(0.0);

    TrackPointer pUnloadedTrack(std::move(m_pLoadedTrack));
    DEBUG_ASSERT(!m_pLoadedTrack);
    return pUnloadedTrack;
}
Ejemplo n.º 14
0
status_t device_init(struct device *dev)
{
    if (!dev)
        return ERR_INVALID_ARGS;

    DEBUG_ASSERT(dev->driver);

    const struct driver_ops *ops = dev->driver->ops;

    if (ops && ops->init) {
        dprintf(INFO, "dev: initializing device %s:%s\n", dev->driver->type, dev->name);
        status_t err = ops->init(dev);
        if (err < 0) {
            dev->device_state = DEVICE_INITIALIZED_FAILED;
        } else {
            dev->device_state = DEVICE_INITIALIZED;
        }
        return err;
    } else {
        return ERR_NOT_SUPPORTED;
    }
}
Ejemplo n.º 15
0
void svg_renderer::update_cache_item (const renderable_item *item, const render_cache_id &cache_id, const QTransform &transform,
                                      renderer_config &cfg, int total_x, int total_y)
{
  int block_size = rendered_items_cache::block_pixel_size ();
  SkBitmap bitmap;
  bitmap.setConfig (SkBitmap::kARGB_8888_Config, block_size * total_x, block_size * total_y);
  bitmap.allocPixels ();
  SkBitmapDevice device (bitmap);
  SkCanvas canvas (&device);
  canvas.drawColor (SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode);

  QRectF local_rect = cache_id.pixel_rect (transform);
  QTransform last_inverted = transform.inverted ();
  QPointF last_pos_local = last_inverted.map (QPointF (0, 0));
  QPointF cur_pos_local = last_inverted.map (QPointF (local_rect.x (), local_rect.y ()));
  QPointF diff = -cur_pos_local + last_pos_local;

  QTransform pixmap_transform = QTransform (transform).translate (diff.x (), diff.y ());
  renderer_state state (QRect (0, 0, block_size * total_x, block_size * total_y), pixmap_transform);
  draw_item (item, canvas, state, cfg);

  if (m_queue->is_interrupted ())
    return;

  if (total_x == total_y && total_x == 1)
    m_cache->add_bitmap (cache_id, bitmap, cfg.use_new_cache ());
  else
    {
      for (int i = 0; i < total_x; i++)
        for (int j = 0; j < total_y; j++)
          {
            render_cache_id cur_id (cache_id.x () + i, cache_id.y () + j, cache_id.object_type ());
            SkBitmap bitmap_part;
            DEBUG_ASSERT (bitmap.extractSubset (&bitmap_part, SkIRect::MakeXYWH (i * block_size, j * block_size, block_size, block_size)));
            m_cache->add_bitmap (cur_id, bitmap_part, cfg.use_new_cache ());
          }
    }

}
Ejemplo n.º 16
0
void InputHandler::Create( const RString &drivers_, vector<InputHandler *> &Add )
{
	const RString drivers = drivers_.empty()? RString(DEFAULT_INPUT_DRIVER_LIST):drivers_;
	vector<RString> DriversToTry;
	split( drivers, ",", DriversToTry, true );
	
	if( DriversToTry.empty() )
		RageException::Throw( "%s", INPUT_HANDLERS_EMPTY.GetValue().c_str() );
	
	FOREACH_CONST( RString, DriversToTry, s )
	{
		RageDriver *pDriver = InputHandler::m_pDriverList.Create( *s );
		if( pDriver == NULL )
		{
			LOG->Trace( "Unknown Input Handler name: %s", s->c_str() );
			continue;
		}

		InputHandler *ret = dynamic_cast<InputHandler *>( pDriver );
		DEBUG_ASSERT( ret );
		Add.push_back( ret );
	}
Ejemplo n.º 17
0
ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) {
    DEBUG_ASSERT(obj != nullptr);

    u16 slot = next_free_slot;
    if (slot >= generations.size()) {
        LOG_ERROR(Kernel, "Unable to allocate Handle, too many slots in use.");
        return ERR_OUT_OF_HANDLES;
    }
    next_free_slot = generations[slot];

    u16 generation = next_generation++;

    // Overflow count so it fits in the 15 bits dedicated to the generation in the handle.
    // CTR-OS doesn't use generation 0, so skip straight to 1.
    if (next_generation >= (1 << 15)) next_generation = 1;

    generations[slot] = generation;
    objects[slot] = std::move(obj);

    Handle handle = generation | (slot << 15);
    return MakeResult<Handle>(handle);
}
Ejemplo n.º 18
0
void heap_free(zone_type zone, void *ptr)
{
	if (ptr == 0)
		return;

	LTRACEF("ptr %p\n", ptr);

	// check for the old allocation structure
	struct alloc_struct_begin *as = (struct alloc_struct_begin *)ptr;
	as--;

	DEBUG_ASSERT(as->magic == HEAP_MAGIC);

	LTRACEF("allocation was %zd bytes long at ptr %p\n", as->size, as->ptr);

	// looks good, create a free chunk and add it to the pool
	enter_critical_section();
	heap_insert_free_chunk(zone, heap_create_free_chunk(as->ptr, as->size));
	exit_critical_section();

//	heap_dump();
}
Ejemplo n.º 19
0
void SoundSourceFFmpeg::close() {
    clearCache();

    if (m_pCodecCtx != nullptr) {
        qDebug() << "~SoundSourceFFmpeg(): Clear FFMPEG stuff";
        avcodec_close(m_pCodecCtx);
        m_pCodecCtx = nullptr;
        avformat_close_input(&m_pFormatCtx);
        DEBUG_ASSERT(m_pFormatCtx == nullptr);
    }

    if (m_pResample != nullptr) {
        qDebug() << "~SoundSourceFFmpeg(): Delete FFMPEG Resampler";
        m_pResample.reset();
    }

    while (m_SJumpPoints.size() > 0) {
        ffmpegLocationObject* l_SRmJmp = m_SJumpPoints[0];
        m_SJumpPoints.remove(0);
        free(l_SRmJmp);
    }
}
Ejemplo n.º 20
0
/* ================================================ */
const Common::TYPE_OBJECT ItemObject::GetTypeObject() const
{
	Common::TYPE_OBJECT type = Common::TYPE_MAX;
	switch( m_kindItem ){
	default:
		DEBUG_ASSERT( 0, "アイテムの種類が想定外" );
		/* fall-through */
	case Common::ITEM_KIND_RAPID_BULLET:
		type = Common::TYPE_ITEM_BULLET;
		break;
	case Common::ITEM_KIND_LIFE_UP:
		type = Common::TYPE_ITEM_LIFE;
		break;
	case Common::ITEM_KIND_DAMAGE_UP:
		type = Common::TYPE_ITEM_DAMAGE;
		break;
	case Common::ITEM_KIND_ANTIDOTE:
		type = Common::TYPE_ITEM_ANTIDOTE;
		break;
	};
	return type;
}
Ejemplo n.º 21
0
IndexRange IndexRange::splitAndShrinkFront(SINT frontLength) {
    DEBUG_ASSERT(frontLength >= 0);
    DEBUG_ASSERT(frontLength <= length());
    if (start() <= end()) {
        auto startRange = forward(first, frontLength);
        DEBUG_ASSERT(startRange.length() == frontLength);
        first += frontLength;
        DEBUG_ASSERT(start() == startRange.end()); // adjacent
        return startRange;
    } else {
        auto startRange = backward(first, frontLength);
        DEBUG_ASSERT(startRange.length() == frontLength);
        first -= frontLength;
        DEBUG_ASSERT(start() == startRange.end()); // adjacent
        return startRange;
    }
}
Ejemplo n.º 22
0
IndexRange IndexRange::splitAndShrinkBack(SINT backLength) {
    DEBUG_ASSERT(backLength >= 0);
    DEBUG_ASSERT(backLength <= length());
    if (start() <= end()) {
        auto endRange = between(end() - backLength, end());
        DEBUG_ASSERT(endRange.length() == backLength);
        second -= backLength;
        DEBUG_ASSERT(end() == endRange.start()); // adjacent
        return endRange;
    } else {
        auto endRange = between(end() + backLength, end());
        DEBUG_ASSERT(endRange.length() == backLength);
        second += backLength;
        DEBUG_ASSERT(end() == endRange.start()); // adjacent
        return endRange;
    }
}
Ejemplo n.º 23
0
HRESULT CUIElement::GetChildByNameDeeply(BSTR bstrName, IUIElement** ppChild)
{
	DEBUG_ASSERT(ppChild) ;
	IF_RETURN(NULL == ppChild, E_INVALIDARG) ;
	*ppChild = NULL ;

	std::vector<CComPtr<IUIElement>> vecElem ;
	for (size_t i = 0; i < this->m_vecChildrenPool.size(); ++i)
	{
		vecElem.push_back(this->m_vecChildrenPool[i]) ;
	}

	for (size_t i = 0; i < vecElem.size(); ++i)
	{
		CComPtr<IUIElement> pElement = vecElem[i] ;
		IF_CONTINUE(NULL == pElement) ;

		CComBSTR _bstrName ;
		pElement->GetName(&_bstrName) ;
		if (CString(_bstrName) == CString(bstrName))
		{
			return pElement->QueryInterface(__uuidof(IUIElement), (VOID**)ppChild) ;
		}
		else
		{
			LONG lChildrenCount = 0 ;
			pElement->GetChildrenCount(&lChildrenCount) ;
			for (INT i = 0; i < lChildrenCount; ++i)
			{
				CComPtr<IUIElement> pElementTemp ;
				pElement->GetChildByIndex(i, &pElementTemp) ;
				IF_CONTINUE(NULL == pElementTemp) ;
				vecElem.push_back(pElementTemp) ;
			}
		}
	}
	return S_OK ;
}
Ejemplo n.º 24
0
static MI_Result MI_CALL _SetIndicationProperties_Impl(
    _In_ void* cfg,
    _Outptr_ MI_Instance** indication)
{
    MI_Result r = MI_RESULT_OK;
    Config* config = (Config*)cfg;
    DEBUG_ASSERT (indication);
    *indication = NULL;
    {
        MI_Boolean match;
        R_IndicationC1* inst;

        MI_Context* context = config->postctx;
        r = MI_Context_NewInstance(context, &R_IndicationC1_rtti, indication);
        CHKMIRESULTRETURN(r, "MI_Context_NewInstance failed");

        L_Indication_SetIndicationProperties(cfg, *indication);
        CHKSETPROPERTY(r, "L_Indication Properties");

        inst = (R_IndicationC1*) (*indication);
        r = R_IndicationC1_Set_message(inst, MI_T("test indication message"));
        CHKSETPROPERTY(r, "message");
        r = R_IndicationC1_Set_id(inst, config->count);
        CHKSETPROPERTY(r, "id");
        r = R_IndicationC1_Set_rcode1(inst, config->count);
        CHKSETPROPERTY(r, "rcode1");

        r = class_TestFilter(config, &inst->__instance, &match);
        if (r == MI_RESULT_OK)
        {
            if (match == MI_FALSE)
            {
                LOGMSG(("Indication does not match filter"));
            }
        }
    }
    return r;
}
Ejemplo n.º 25
0
void PagerSource::QueueMessageLocked(page_request_t* request) {
    if (packet_busy_) {
        list_add_tail(&pending_requests_, &request->node);
        return;
    }

    packet_busy_ = true;
    active_request_ = request;

    uint64_t offset, length;
    uint16_t cmd;
    if (request != &complete_request_) {
        cmd = ZX_PAGER_VMO_READ;
        offset = request->offset;
        length = request->length;

        // The vm subsystem should guarantee this
        uint64_t unused;
        DEBUG_ASSERT(!add_overflow(offset, length, &unused));
    } else {
        offset = length = 0;
        cmd = ZX_PAGER_VMO_COMPLETE;
    }

    zx_port_packet_t packet = {};
    packet.key = key_;
    packet.type = ZX_PKT_TYPE_PAGE_REQUEST;
    packet.page_request.command = cmd;
    packet.page_request.offset = offset;
    packet.page_request.length = length;

    packet_.packet = packet;

    // We can treat ZX_ERR_BAD_STATE as if the packet was queued
    // but the pager service never responds.
    // TODO: Bypass the port's max queued packet count to prevent ZX_ERR_SHOULD_WAIT
    ASSERT(port_->Queue(&packet_, ZX_SIGNAL_NONE, 0) != ZX_ERR_SHOULD_WAIT);
}
Ejemplo n.º 26
0
/*
================================================================================
//	Name:
//	Desc:
================================================================================
*/
void CIndexBuffer::Unlock()
{
	if ( false == m_bLocked )
	{
		DEBUG_ASSERT( !"Try to unlock non-locked buffer" );
		return;
	}
	
	if ( g_pRenderer->IsExtSupported( EXT_GL_VBO ) )
	{
		glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nBufferID );
		GL_VALIDATE;

		glUnmapBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB );
		GL_VALIDATE;

		glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
		GL_VALIDATE;
	}
	
	m_bLocked = false;
	return;
}
Ejemplo n.º 27
0
void ImageVariableGroup::unlinkVariablePart(ImageVariableEnum variable,
                                            unsigned int partNr)
{
    DEBUG_ASSERT(m_variables.find(variable) != m_variables.end());
    // find all images in the requested part.
    for (unsigned int i = 0; i < m_image_part_numbers.size(); i++)
    {
        if (m_image_part_numbers[i] == partNr)
        {
            // unlink the variable
            switch (variable)
            {
#define image_variable( name, type, default_value )\
                case IVE_##name:\
                    m_pano.unlinkImageVariable##name(i);\
                    break;
#include "image_variables.h"
#undef image_variable
            }
        }
    }
    setPartNumbers();
}
Ejemplo n.º 28
0
static inline bool CheckEquals_(Buffer const& actual, Buffer const& expected) {

    DEBUG_ASSERT(actual.GetLength() == expected.GetLength());

    uint32_t const nSamp = expected.GetLength();
    bool bEq = true;
    if (!Utils::ApproxEqual(actual, expected)) {
        bEq = false;
        std::cout << "Not equal!" << std::endl;
        std::cout << "Values:   ";
        for (uint8_t n = 0; n < nSamp; ++n) {
            std::cout << actual.GetConst()[n] << " ";
        }
        std::cout << std::endl;
        std::cout << "Expected: ";
        for (uint8_t n = 0; n < nSamp; ++n) {
            std::cout << expected.GetConst()[n] << " ";
        }
        std::cout << std::endl;
    }
    
    return bEq;
}
Ejemplo n.º 29
0
void SoundSourceProviderRegistry::insertRegistration(
        QList<SoundSourceProviderRegistration> *pRegistrations,
        SoundSourceProviderRegistration registration) {
    QList<SoundSourceProviderRegistration>::iterator listIter(
            pRegistrations->begin());
    // Perform a linear search through the list & insert
    while (pRegistrations->end() != listIter) {
        // Priority comparison with <=: New registrations will be inserted
        // before existing registrations with equal priority, but after
        // existing registrations with higher priority.
        if (listIter->getProviderPriority() <= registration.getProviderPriority()) {
            listIter = pRegistrations->insert(listIter, std::move(registration));
            DEBUG_ASSERT(pRegistrations->end() != listIter);
            return; // done
        } else {
            ++listIter; // continue loop
        }
    }
    if (pRegistrations->end() == listIter) {
        // List was empty or registration has the lowest priority
        pRegistrations->append(std::move(registration));
    }
}
Ejemplo n.º 30
0
void heap_free(void *ptr)
{
	if (ptr == 0)
		return;

	LTRACEF("ptr %p\n", ptr);

	// check for the old allocation structure
	struct alloc_struct_begin *as = (struct alloc_struct_begin *)ptr;
	as--;
	
	DEBUG_ASSERT(as->magic == HEAP_MAGIC);

#if DEBUG_HEAP
	{
		uint i;
		uint8_t *pad = (uint8_t *)as->padding_start;

		for (i = 0; i < as->padding_size; i++) {
			if (pad[i] != PADDING_FILL) {
				printf("free at %p scribbled outside the lines:\n", ptr);
				hexdump(pad, as->padding_size);
				panic("die\n");
			}
		}
	}
#endif

	LTRACEF("allocation was %zd bytes long at ptr %p\n", as->size, as->ptr);

	// looks good, create a free chunk and add it to the pool
	enter_critical_section();
	heap_insert_free_chunk(heap_create_free_chunk(as->ptr, as->size));
	exit_critical_section();

//	heap_dump();
}