Example #1
0
File: main.cpp Project: CCJY/coliru
int main()
{
    Impl i;
    i.enter_state(active_open{}, closed{}, listen{});
    i.enter_state(passive_open{}, closed{}, listen{});
    i.enter_state(send_syn{}, closed{}, syn_sent{});
}
Example #2
0
File: db.hpp Project: mrktj/tmwa
 void put(const K& k, U v)
 {
     if (!v)
         impl.erase(k);
     else
         impl.insert(k, std::move(v));
 }
  static OSStatus OutputIOProc(AudioDeviceID          inDevice,
			       const AudioTimeStamp*  /*inNow*/,
			       const AudioBufferList* /*inputData*/,
			       const AudioTimeStamp*  /*inInputTime*/,
			       AudioBufferList*	      outputData,
			       const AudioTimeStamp*  /*inOutputTime*/,
			       void*                  inClientData)
  {
    Impl* impl = reinterpret_cast<Impl*>(inClientData);
	
    switch (impl->m_outputProcState)
      {
      case kStarting:
	impl->m_outputProcState = kRunning;
	break;
      case kStopRequested:
	AudioDeviceStop(inDevice, OutputIOProc);
	impl->m_outputProcState = kOff;
	return noErr;
      default:
	break;
      }

    /*
    char buf[512] = {0};
    sprintf(buf, "Received %i bytes of audio data\n",
	    inputData->mBuffers[0].mDataByteSize);
	    impl->m_logger(2, buf);*/

    impl->read(reinterpret_cast<unsigned char*>(outputData->mBuffers[0].mData),
	       outputData->mBuffers[0].mDataByteSize / impl->m_format.mBytesPerFrame);


    return noErr;
  }
la_int64_t OdinPatcher::Impl::laSkipCb(archive *a, void *userdata,
                                       la_int64_t request)
{
    (void) a;
    Impl *impl = static_cast<Impl *>(userdata);
    bool ret = true;

#ifdef __ANDROID__
    if (impl->fd >= 0) {
        if (lseek64(impl->fd, request, SEEK_CUR) < 0) {
            LOGE("%s: Failed to seek: %s", impl->info->inputPath().c_str(),
                 strerror(errno));
            ret = false;
        }
    } else {
#endif
        if (!impl->laFile.seek(request, io::File::SeekCurrent)) {
            LOGE("%s: Failed to seek: %s", impl->info->inputPath().c_str(),
                impl->laFile.errorString().c_str());
            ret = false;
        }
#ifdef __ANDROID__
    }
#endif

    if (ret) {
        impl->bytes += request;
        impl->updateProgress(impl->bytes, impl->maxBytes);
    } else {
        impl->error = ErrorCode::FileSeekError;
    }

    return ret ? request : -1;
}
Example #5
0
File: db.hpp Project: mrktj/tmwa
 void put(const K& k, V v)
 {
     if (v == V())
         impl.erase(k);
     else
         impl.insert(k, std::move(v));
 }
Example #6
0
File: db.hpp Project: mrktj/tmwa
 const V *search(const K& k) const
 {
     const_iterator it = impl.find(k);
     if (it == impl.end())
         return nullptr;
     return &it->second;
 }
Example #7
0
	static void* StartRoutineWrapper(void* data)
	{
		Impl* impl = (Impl*) data;

		impl->StartRoutine(impl->Data);

		return NULL;
	}
Example #8
0
int main()
{
    Impl impl;
    impl.run();
    Interface& intf = impl;
    intf.run();
    return 0;
}
Example #9
0
VampFeatureList *
PluginAdapterBase::Impl::vampGetRemainingFeatures(VampPluginHandle handle)
{
#ifdef DEBUG_PLUGIN_ADAPTER
    std::cerr << "PluginAdapterBase::Impl::vampGetRemainingFeatures(" << handle << ")" << std::endl;
#endif

    Impl *adapter = lookupAdapter(handle);
    if (!adapter) return 0;
    return adapter->getRemainingFeatures((Plugin *)handle);
}
Example #10
0
File: db.hpp Project: mrktj/tmwa
    void insert(const K& k, V v)
    {
        // As far as I can tell, this is the simplest way to
        // implement move-only insert-with-replacement.
        iterator it = impl.lower_bound(k);
        // invariant: if it is valid, it->first >= k
        if (it != impl.end() && it->first == k)
            it->second = std::move(v);
        else
            it = impl.insert(std::pair<K, V>(std::move(k), std::move(v))).first;
        return (void)&it->second;

    }
Example #11
0
VampFeatureList *
PluginAdapterBase::Impl::vampProcess(VampPluginHandle handle,
                                     const float *const *inputBuffers,
                                     int sec,
                                     int nsec)
{
#ifdef DEBUG_PLUGIN_ADAPTER
    std::cerr << "PluginAdapterBase::Impl::vampProcess(" << handle << ", " << sec << ", " << nsec << ")" << std::endl;
#endif

    Impl *adapter = lookupAdapter(handle);
    if (!adapter) return 0;
    return adapter->process((Plugin *)handle, inputBuffers, sec, nsec);
}
Example #12
0
void
PluginAdapterBase::Impl::vampSetParameter(VampPluginHandle handle,
                                    int param, float value)
{
#ifdef DEBUG_PLUGIN_ADAPTER
    std::cerr << "PluginAdapterBase::Impl::vampSetParameter(" << handle << ", " << param << ", " << value << ")" << std::endl;
#endif

    Impl *adapter = lookupAdapter(handle);
    if (!adapter) return;
    Plugin::ParameterList &list = adapter->m_parameters;
    ((Plugin *)handle)->setParameter(list[param].identifier, value);
    adapter->markOutputsChanged((Plugin *)handle);
}
Example #13
0
unsigned int
PluginAdapterBase::Impl::vampGetOutputCount(VampPluginHandle handle)
{
#ifdef DEBUG_PLUGIN_ADAPTER
    std::cerr << "PluginAdapterBase::Impl::vampGetOutputCount(" << handle << ")" << std::endl;
#endif

    Impl *adapter = lookupAdapter(handle);

//    std::cerr << "vampGetOutputCount: handle " << handle << " -> adapter "<< adapter << std::endl;

    if (!adapter) return 0;
    return adapter->getOutputCount((Plugin *)handle);
}
Example #14
0
void
PluginAdapterBase::Impl::vampCleanup(VampPluginHandle handle)
{
#ifdef DEBUG_PLUGIN_ADAPTER
    std::cerr << "PluginAdapterBase::Impl::vampCleanup(" << handle << ")" << std::endl;
#endif

    Impl *adapter = lookupAdapter(handle);
    if (!adapter) {
        delete ((Plugin *)handle);
        return;
    }
    adapter->cleanup(((Plugin *)handle));
}
Example #15
0
VampOutputDescriptor *
PluginAdapterBase::Impl::vampGetOutputDescriptor(VampPluginHandle handle,
                                           unsigned int i)
{
#ifdef DEBUG_PLUGIN_ADAPTER
    std::cerr << "PluginAdapterBase::Impl::vampGetOutputDescriptor(" << handle << ", " << i << ")" << std::endl;
#endif

    Impl *adapter = lookupAdapter(handle);

//    std::cerr << "vampGetOutputDescriptor: handle " << handle << " -> adapter "<< adapter << std::endl;

    if (!adapter) return 0;
    return adapter->getOutputDescriptor((Plugin *)handle, i);
}
Example #16
0
	static LRESULT WINAPI MessageRouter(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
	{
		if (message == WM_CREATE)
		{
			SetWindowLong(hWnd, 0, (LONG)lParam);
		}
		else
		{
			Impl* pThis = (Impl*)GetWindowLong(hWnd, 0);
			if (pThis != nullptr)
			{
				return pThis->WndProc(hWnd,message,wParam,lParam);
			}
		}
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
Example #17
0
void
PluginAdapterBase::Impl::vampSelectProgram(VampPluginHandle handle,
                                           unsigned int program)
{
#ifdef DEBUG_PLUGIN_ADAPTER
    std::cerr << "PluginAdapterBase::Impl::vampSelectProgram(" << handle << ", " << program << ")" << std::endl;
#endif

    Impl *adapter = lookupAdapter(handle);
    if (!adapter) return;

    Plugin::ProgramList &list = adapter->m_programs;
    ((Plugin *)handle)->selectProgram(list[program]);

    adapter->markOutputsChanged((Plugin *)handle);
}
Example #18
0
int
PluginAdapterBase::Impl::vampInitialise(VampPluginHandle handle,
                                        unsigned int channels,
                                        unsigned int stepSize,
                                        unsigned int blockSize)
{
#ifdef DEBUG_PLUGIN_ADAPTER
    std::cerr << "PluginAdapterBase::Impl::vampInitialise(" << handle << ", " << channels << ", " << stepSize << ", " << blockSize << ")" << std::endl;
#endif

    Impl *adapter = lookupAdapter(handle);
    if (!adapter) return 0;
    bool result = ((Plugin *)handle)->initialise(channels, stepSize, blockSize);
    adapter->markOutputsChanged((Plugin *)handle);
    return result ? 1 : 0;
}
Example #19
0
la_ssize_t OdinPatcher::Impl::laReadCb(archive *a, void *userdata,
                                       const void **buffer)
{
    (void) a;
    Impl *impl = static_cast<Impl *>(userdata);
    *buffer = impl->laBuf;
    uint64_t bytesRead;
    bool ret = true;

#ifdef __ANDROID__
    if (impl->fd >= 0) {
        ssize_t n = read(impl->fd, impl->laBuf, sizeof(impl->laBuf));
        if (n < 0) {
            LOGE("%s: Failed to read: %s", impl->info->inputPath().c_str(),
                 strerror(errno));
            ret = false;
        } else {
            bytesRead = n;
        }
    } else {
#endif
        ret = impl->laFile.read(impl->laBuf, sizeof(impl->laBuf), &bytesRead);
        if (!ret && impl->laFile.error() == io::File::ErrorEndOfFile) {
            ret = true;
        }
        if (!ret) {
            LOGE("%s: Failed to read: %s", impl->info->inputPath().c_str(),
                 impl->laFile.errorString().c_str());
        }
#ifdef __ANDROID__
    }
#endif

    if (ret) {
        impl->bytes += bytesRead;
        impl->updateProgress(impl->bytes, impl->maxBytes);
    } else {
        impl->error = ErrorCode::FileReadError;
    }

    return ret ? (la_ssize_t) bytesRead : -1;
}
	static DWORD WINAPI MyThread(
		LPVOID lpThreadParameter
		){
		Impl *This = (Impl*)lpThreadParameter;

		DWORD threadidx = GetCurrentThreadId();
		while (!This->m_exit){

			if (WAIT_OBJECT_0 == This->m_queueSemaphore.WaitAndDec(1000))
			{
				std::shared_ptr<MyTaskData> task;

				task = This->getTaskAndPop(threadidx);
				assert(task);	

				// run
				task->Run();
			}
		}
		return 0;
	}
Example #21
0
    void connect(const std::string& srcPortName, Impl& dstImpl,
                 const std::string& dstPortName)
    {
        if (!hasOutputPort(srcPortName))
            throwPortError(srcPortName);

        if (!dstImpl.hasInputPort(dstPortName))
            throwPortError(dstPortName);

        // The value on the output port may already be set
        if (!dstImpl._manuallySetPortsMap.count(dstPortName))
            std::runtime_error(std::string("The value on port:  ") +
                               dstPortName + "is already set");

        _outputMap.find(srcPortName)
            ->second.connect(dstImpl._inputMap.find(dstPortName)->second);
    }
Example #22
0
File: main.cpp Project: CCJY/coliru
int main (int argc, char* argv[])
{
    Impl impl;
    
    Global& global = impl;
    A& a = impl;
    B& b = impl;
    
    impl.A1();
    impl.B1();
    impl.AB1();
    impl.AB2();
    impl.AB3();
    
    std::cout << std::endl;
    
    a.A1();
    b.B1();
    
    std::cout << std::endl;
    
    a.AB1();
    a.AB2();
    a.AB3();
    
    std::cout << std::endl;
    
    b.AB1();
    b.AB2();
    b.AB3();

    std::cout << std::endl;

    global.A1();
    global.B1();
    global.AB1();
    global.AB2();
    // global.AB3(); // Does not compile

  return 0;
}
Example #23
0
	Edges edges() const noexcept { return shape_.edges(); }
Example #24
0
	Vertices vertices() const noexcept { return transformMesh_.vertices(); }
Example #25
0
File: db.hpp Project: mrktj/tmwa
 size_t size() const
 {
     return impl.size();
 }
Example #26
0
File: db.hpp Project: mrktj/tmwa
 void clear()
 {
     impl.clear();
 }
Example #27
0
File: db.hpp Project: mrktj/tmwa
 void erase(const K& k)
 {
     impl.erase(k);
 }
Example #28
0
File: db.hpp Project: mrktj/tmwa
 const_iterator end() const { return impl.end(); }
Example #29
0
File: db.hpp Project: mrktj/tmwa
 bool empty() const
 {
     return impl.empty();
 }
Example #30
0
	Triangles triangles() const noexcept { return transformMesh_.triangles(); }