void connectHelper(TreeLinkNode *root){
     if(!root)
         return;
     if(root->left){
         root->left->next = root->right?root->right:NULL;
     }
     if(root->right){
         root->right->next = root->next?root->next->left:NULL;
     }
     connectHelper(root->left);
     connectHelper(root->right);
 }
DatabaseCon::DatabaseCon (const std::string& strName, const char* initStrings[], int initCount)
{
    connectHelper(strName);
    for (int i = 0; i < initCount; ++i) {
        bool res = mDatabase->executeSQL (initStrings[i], false);
        assert(res);
    }
}
DatabaseCon::DatabaseCon (const std::string& strName, const std::vector<const char *> &init)
{
    connectHelper(strName);

    for(const char * const &statement: init) {
        bool res = mDatabase->executeSQL (statement, false);
        assert(res);
    }
}
Example #4
0
void QPulseAudioThread::reconnect(SourceContainer::const_iterator pos = s_sourceList.end())
{

    if (s_sourceList.empty())
        return;

    if (pos != s_sourceList.end()) {
        s_sourcePosition = pos;
        qDebug() << "reconnecting with" << *pos;
    } else
        s_sourcePosition = scanForPlaybackMonitor();

    if (s_sourcePosition == s_sourceList.end()) {
        s_sourcePosition = s_sourceList.begin();
    }

    if (stream && (pa_stream_get_state(stream) == PA_STREAM_READY)) {
        //qDebug() << "disconnect";
        pa_stream_disconnect ( stream );
        //	pa_stream_unref(stream);
        //qDebug() << "* return *";

    }

    if ( ! ( stream = pa_stream_new ( context, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL ) ) ) {
        fprintf ( stderr, "pa_stream_new() failed: %s\n", pa_strerror ( pa_context_errno ( context ) ) );
        return;
    }

    pa_stream_set_state_callback
    ( stream, stream_state_callback, &s_sourceList );
    pa_stream_set_read_callback ( stream, stream_read_callback, &s_sourceList );
    pa_stream_set_moved_callback(stream, stream_moved_callback, &s_sourceList );

    switch (pa_stream_get_state(stream)) {
    case PA_STREAM_UNCONNECTED:// 	The stream is not yet connected to any sink or source.
        qDebug() << "unconnected: connecting...";
        connectHelper(s_sourcePosition);
        break;
    case PA_STREAM_CREATING 	://The stream is being created.
        break;
    case PA_STREAM_READY ://	The stream is established, you may pass audio data to it now.
        qDebug() << "stream is still ready, waiting for callback...";
        break;
    case PA_STREAM_FAILED ://	An error occured that made the stream invalid.
        qDebug() << "stream is now invalid. great.";
        break;
    case PA_STREAM_TERMINATED:// 	The stream has been terminated cleanly.
        qDebug() << "terminated...";
        break;

    }
}
 void connectHelper(TreeLinkNode *root){
     if(!root->left || !root->right)
         return;
     
     TreeLinkNode* cur = root;
     while(cur){
         if(cur->left)
         	cur->left->next = cur->right;
         if(cur->right)
         	cur->right->next = (cur->next) ? cur->next->left : NULL;
         cur = cur->next;
     }   
     connectHelper(root->left);
 }
 void connect(TreeLinkNode *root) {
     if(!root)
         return;
     root->next = NULL;
     connectHelper(root);
 }