File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,15 @@ DecoderAudio::~DecoderAudio()
3434}
3535
3636bool  DecoderAudio::start (const  char * err)
37+ {
38+     if (!prepare (err))
39+     {
40+         return  false ;
41+     }
42+     return  decode (NULL );
43+ }
44+ 
45+ bool  DecoderAudio::startAsync (const  char * err)
3746{
3847    if (!prepare (err))
3948    {
@@ -91,7 +100,7 @@ bool DecoderAudio::process(AVPacket *packet)
91100    return  true ;
92101}
93102
94- void  DecoderAudio::decode (void * ptr)
103+ bool  DecoderAudio::decode (void * ptr)
95104{
96105    AVPacket        pPacket;
97106
@@ -103,12 +112,12 @@ void DecoderAudio::decode(void* ptr)
103112        if (mQueue ->get (&pPacket, true ) < 0 )
104113        {
105114            mDecoding  = false ;
106-             continue ;
115+             return   false ;
107116        }
108117        if (!process (&pPacket))
109118        {
110119            mDecoding  = false ;
111-             continue ;
120+             return   false ;
112121        }
113122        //  Free the packet that was allocated by av_read_frame
114123        av_free_packet (&pPacket);
@@ -120,4 +129,5 @@ void DecoderAudio::decode(void* ptr)
120129
121130    //  Free audio samples buffer
122131    av_free (mSamples );
132+     return  true ;
123133}
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ class DecoderAudio
2323    ~DecoderAudio ();
2424
2525    bool  start (const  char * err);
26+     bool  startAsync (const  char * err);
2627    void  stop ();
2728
2829private: 
@@ -35,7 +36,7 @@ class DecoderAudio
3536    int                          mSamplesSize ;
3637
3738    bool                         prepare (const  char  *err);
38-     void                         decode (void * ptr);
39+     bool                         decode (void * ptr);
3940    bool                         process (AVPacket *packet);
4041    static  void *                startDecoding (void * ptr);
4142};
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments