Index: pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp	(revision 3024)
+++ pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp	(revision 3025)
@@ -246,4 +246,6 @@
     TInt GetMaxGain() { TInt gain;iVoIPUplink->GetMaxGain(gain);return gain; }
 
+    TBool IsStarted();
+    
 private:
     CPjAudioEngine(struct vas_stream *parent_strm,
@@ -261,19 +263,19 @@
 
     // From MVoIPDownlinkObserver
-    virtual void FillBuffer(const CVoIPAudioDownlinkStream& aSrc,
+    void FillBuffer(const CVoIPAudioDownlinkStream& aSrc,
                             CVoIPDataBuffer* aBuffer);
-    virtual void Event(const CVoIPAudioDownlinkStream& aSrc,
+    void Event(const CVoIPAudioDownlinkStream& aSrc,
                        TInt aEventType,
                        TInt aError);
 
     // From MVoIPUplinkObserver
-    virtual void EmptyBuffer(const CVoIPAudioUplinkStream& aSrc,
+    void EmptyBuffer(const CVoIPAudioUplinkStream& aSrc,
                              CVoIPDataBuffer* aBuffer);
-    virtual void Event(const CVoIPAudioUplinkStream& aSrc,
+    void Event(const CVoIPAudioUplinkStream& aSrc,
                        TInt aEventType,
                        TInt aError);
 
     // From MVoIPFormatObserver
-    virtual void Event(const CVoIPFormatIntfc& aSrc, TInt aEventType);
+    void Event(const CVoIPFormatIntfc& aSrc, TInt aEventType);
 
     State			 dn_state_;
@@ -370,4 +372,12 @@
 }
 
+TBool CPjAudioEngine::IsStarted()
+{
+    return ((((parentStrm_->param.dir & PJMEDIA_DIR_CAPTURE) == 0) || 
+	       up_state_ == STATE_STREAMING) &&
+	    (((parentStrm_->param.dir & PJMEDIA_DIR_PLAYBACK) == 0) || 
+	       dn_state_ == STATE_STREAMING));
+}
+
 TInt CPjAudioEngine::InitPlay()
 {
@@ -669,6 +679,7 @@
 // Callback from MVoIPFormatObserver
 void CPjAudioEngine::Event(const CVoIPFormatIntfc& /*aSrc*/, 
-			   TInt /*aEventType*/)
-{
+			   TInt aEventType)
+{
+    snd_perror("Format event", aEventType);
 }
 
@@ -1310,5 +1321,5 @@
 {
     struct vas_factory *af = (struct vas_factory*)f;
-    CVoIPUtilityFactory *vas_factory;
+    CVoIPUtilityFactory *vas_factory_;
     CVoIPAudioUplinkStream *vas_uplink;
     CVoIPAudioDownlinkStream *vas_dnlink;
@@ -1333,5 +1344,5 @@
 
     /* Enumerate supported formats */
-    err = CVoIPUtilityFactory::CreateFactory(vas_factory);
+    err = CVoIPUtilityFactory::CreateFactory(vas_factory_);
     if (err != KErrNone)
 	goto on_error;
@@ -1340,5 +1351,5 @@
      * querying formats.
      */
-    err = vas_factory->CreateUplinkStream(vas_version, 
+    err = vas_factory_->CreateUplinkStream(vas_version, 
 				          CVoIPUtilityFactory::EVoIPCall,
 				          vas_uplink);
@@ -1346,5 +1357,5 @@
 	goto on_error;
     
-    err = vas_factory->CreateDownlinkStream(vas_version, 
+    err = vas_factory_->CreateDownlinkStream(vas_version, 
 				            CVoIPUtilityFactory::EVoIPCall,
 				            vas_dnlink);
@@ -1353,10 +1364,10 @@
     
     uplink_formats.Reset();
-    err = vas_factory->GetSupportedUplinkFormats(uplink_formats);
+    err = vas_factory_->GetSupportedUplinkFormats(uplink_formats);
     if (err != KErrNone)
 	goto on_error;
 
     dnlink_formats.Reset();
-    err = vas_factory->GetSupportedDownlinkFormats(dnlink_formats);
+    err = vas_factory_->GetSupportedDownlinkFormats(dnlink_formats);
     if (err != KErrNone)
 	goto on_error;
@@ -1367,4 +1378,6 @@
     delete vas_dnlink;
     vas_dnlink = NULL;
+    delete vas_factory_;
+    vas_factory_ = NULL;
     
     for (TInt i = 0; i < dnlink_formats.Count(); i++) {
@@ -1884,10 +1897,26 @@
 
     if (stream->engine) {
+	enum { VAS_WAIT_START = 2000 }; /* in msecs */
+	TTime start, now;
 	TInt err = stream->engine->Start();
+	
     	if (err != KErrNone)
     	    return PJ_RETURN_OS_ERROR(err);
-    }
-
-    return PJ_SUCCESS;
+
+    	/* Perform synchronous start, timeout after VAS_WAIT_START ms */
+	start.UniversalTime();
+	do {
+    	    pj_symbianos_poll(-1, 100);
+    	    now.UniversalTime();
+    	} while (!stream->engine->IsStarted() &&
+		 (now.MicroSecondsFrom(start) < VAS_WAIT_START * 1000));
+	
+	if (stream->engine->IsStarted())
+	    return PJ_SUCCESS;
+	else
+	    return PJ_ETIMEDOUT;
+    }    
+
+    return PJ_EINVALIDOP;
 }
 
