~oxalin/lightspark/buildnaudioplugin

« back to all changes in this revision

Viewing changes to scripting/flashnet.cpp

  • Committer: Alessandro
  • Date: 2010-09-06 19:31:31 UTC
  • mfrom: (911.13.93)
  • Revision ID: git-v1:9f6175895e49dc81d39f6f99e66e2adc5a82bdb3
Merge branch 'master' of http://github.com/Oxalin/lightspark

Conflicts:
        CMakeLists.txt
        scripting/flashnet.cpp

Show diffs side-by-side

added added

removed removed

Lines of Context:
379
379
                return new Undefined;
380
380
}
381
381
 
382
 
NetStream::NetStream():frameRate(0),tickStarted(false),downloader(NULL),videoDecoder(NULL),audioDecoder(NULL),soundStreamId(0),streamTime(0),paused(false),soundPaused(false),closed(true)
 
382
//NetStream::NetStream():frameRate(0),tickStarted(false),downloader(NULL),videoDecoder(NULL),audioDecoder(NULL),audioStream(NULL),streamTime(0),paused(false),audioPaused(false),closed(true)
 
383
NetStream::NetStream():frameRate(0),tickStarted(false),downloader(NULL),videoDecoder(NULL),audioDecoder(NULL),audioStream(NULL),streamTime(0),paused(false),closed(true)
383
384
{
384
385
        sem_init(&mutex,0,1);
385
386
}
473
474
 
474
475
        //Reset the paused states
475
476
        th->paused = false;
476
 
        th->soundPaused = false;
 
477
//      th->audioPaused = false;
477
478
 
478
479
        assert_and_throw(argslen==1);
479
480
        const tiny_string& arg0=args[0]->toString();
588
589
        if(paused)
589
590
        {
590
591
                //If sound is enabled, pause the sound stream too. This will stop all time from running.
591
 
#if ENABLE_SOUND
592
 
                if(!soundPaused)
 
592
//              if(!audioPaused)
 
593
                if(!audioStream->paused())
593
594
                {
594
 
                        sys->soundManager->pauseStream(soundStreamId);
595
 
                        soundPaused = true;
 
595
                        sys->audioManager->pauseStreamPlugin(audioStream);
 
596
//                      audioPaused = true;
596
597
                }
597
 
#endif
598
598
                return;
599
599
        }
 
600
 
600
601
        //If sound is enabled, and the stream is not paused anymore, resume the sound stream. This will restart time.
601
 
#if ENABLE_SOUND
602
 
        else if(soundPaused)
 
602
//      else if(audioPaused)
 
603
        else if(audioStream->paused())
603
604
        {
604
 
                sys->soundManager->resumeStream(soundStreamId);
605
 
                soundPaused = false;
 
605
                sys->audioManager->resumeStreamPlugin(audioStream);
 
606
//              audioPaused = false;
606
607
        }
607
 
#endif
608
608
 
609
609
        //Advance video and audio to current time, follow the audio stream time
610
610
        //No mutex needed, ticking can happen only when stream is completely ready
611
 
#ifdef ENABLE_SOUND
612
 
        if(soundStreamId && sys->soundManager->isTimingAvailable())
 
611
        if(audioStream && sys->audioManager->isTimingAvailablePlugin())
613
612
        {
614
613
                assert(audioDecoder);
615
 
                streamTime=sys->soundManager->getPlayedTime(soundStreamId);
 
614
                streamTime=audioStream->getPlayedTime();
616
615
        }
617
616
        else
618
 
#endif
619
617
        {
620
618
                streamTime+=1000/frameRate;
621
619
                audioDecoder->skipAll();
700
698
                                        {
701
699
                                                AudioDataTag tag(s);
702
700
                                                prevSize=tag.getTotalLen();
703
 
#ifdef ENABLE_SOUND
 
701
 
704
702
                                                if(audioDecoder==NULL)
705
703
                                                {
706
704
                                                        audioCodec=tag.SoundFormat;
730
728
                                                                        throw RunTimeException("Unsupported SoundFormat");
731
729
                                                        }
732
730
                                                        if(audioDecoder->isValid())
733
 
                                                                soundStreamId=sys->soundManager->createStream(audioDecoder);
 
731
                                                                audioStream=sys->audioManager->createStreamPlugin(audioDecoder);
734
732
                                                }
735
733
                                                else
736
734
                                                {
737
735
                                                        assert_and_throw(audioCodec==tag.SoundFormat);
738
736
                                                        decodedAudioBytes+=audioDecoder->decodeData(tag.packetData,tag.packetLen,decodedTime);
739
 
                                                        if(soundStreamId==0 && audioDecoder->isValid())
740
 
                                                                soundStreamId=sys->soundManager->createStream(audioDecoder);
 
737
                                                        if(audioStream==0 && audioDecoder->isValid())
 
738
                                                                audioStream=sys->audioManager->createStreamPlugin(audioDecoder);
741
739
                                                        //Adjust timing
742
740
                                                        decodedTime=decodedAudioBytes/audioDecoder->getBytesPerMSec();
743
741
                                                }
744
 
#endif
745
742
                                                break;
746
743
                                        }
747
744
                                        case 9:
908
905
        if(videoDecoder)
909
906
                delete videoDecoder;
910
907
        videoDecoder=NULL;
911
 
#if ENABLE_SOUND
912
 
        if(soundStreamId)
913
 
                sys->soundManager->freeStream(soundStreamId);
 
908
        if(audioStream)
 
909
                sys->audioManager->freeStreamPlugin(audioStream);
914
910
        if(audioDecoder)
915
911
                delete audioDecoder;
916
 
        soundStreamId = 0;
 
912
//      soundStreamId = 0;
917
913
        audioDecoder=NULL;
918
 
#endif
 
914
 
919
915
        sem_post(&mutex);
920
916
}
921
917