Subversion Repositories Kolibri OS

Rev

Rev 2427 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2427 Rev 2693
Line 23... Line 23...
23
static int snd_format;
23
static int snd_format;
24
int sample_rate;
24
int sample_rate;
Line 25... Line 25...
25
 
25
 
-
 
26
static uint32_t samples_written = 0;
-
 
27
double audio_base = -1.0;
-
 
28
 
Line 26... Line 29...
26
static uint32_t samples_written = 0;
29
double get_audio_base();
27
 
30
 
28
int init_audio(int format)
31
int init_audio(int format)
29
{
32
{
Line 102... Line 105...
102
                                   &data_size, &pkt_tmp);
105
                                   &data_size, &pkt_tmp);
103
 
106
 
Line 104... Line 107...
104
        if(len >= 0)
107
        if(len >= 0)
105
        {
108
        {
-
 
109
//            if(audio_base == -1.0)
-
 
110
//            {
-
 
111
//                if (pkt.pts != AV_NOPTS_VALUE)
-
 
112
//                    audio_base = get_audio_base() * pkt.pts;
-
 
113
//                printf("audio base %f\n", audio_base);                
-
 
114
//            };
-
 
115
            
106
            pkt_tmp.data += len;
116
            pkt_tmp.data += len;
107
            pkt_tmp.size -= len;
117
            pkt_tmp.size -= len;
Line 108... Line 118...
108
 
118
 
109
            mutex_lock(&astream.lock);
119
            mutex_lock(&astream.lock);
Line 212... Line 222...
212
        uint32_t  offset;
222
        uint32_t  offset;
213
        double    event_stamp, wait_stamp;
223
        double    event_stamp, wait_stamp;
214
        int       too_late = 0;
224
        int       too_late = 0;
215
 
225
 
Line 216... Line 226...
216
        if(player_state == PAUSE)
226
        if((player_state == PAUSE) ||
-
 
227
           (player_state == PLAY_INIT) )
217
        {
228
        {
218
            if( active )
229
            if( active )
219
            {
230
            {
220
                StopBuffer(hBuff);
231
                StopBuffer(hBuff);
221
                active = 0;
232
                active = 0;
-
 
233
            };
-
 
234
            delay(1);
-
 
235
            continue;
222
            }
236
        }
-
 
237
        else if(player_state == REWIND)
-
 
238
        {
-
 
239
            if( active )
-
 
240
            {
-
 
241
                StopBuffer(hBuff);
-
 
242
                active = 0;
-
 
243
            };
-
 
244
            mutex_lock(&astream.lock);
-
 
245
            astream.count = 0;
-
 
246
            mutex_unlock(&astream.lock);
223
            delay(1);
247
            delay(1);
224
            continue;
248
            continue;
225
        }
249
        }
226
        else if(player_state == PLAY_RESTART)
250
        else if(player_state == PAUSE_2_PLAY)
-
 
251
        {
-
 
252
//            SetTimeBase(hBuff, audio_base);
-
 
253
            GetTimeStamp(hBuff, &last_time_stamp);
-
 
254
//            printf("last_time_stamp %f\n", last_time_stamp);
-
 
255
            
-
 
256
            if((err = PlayBuffer(hBuff, 0)) !=0 )
-
 
257
            {
-
 
258
                errstr = "Cannot play buffer\n\r";
-
 
259
                goto exit_whith_error;
-
 
260
            };
-
 
261
            active = 1;
-
 
262
            sync_audio(hBuff, buffsize);
-
 
263
            player_state = PLAY;
-
 
264
            printf("render: set audio latency to %f\n", audio_delta);
-
 
265
        }
-
 
266
        else if(player_state == REWIND_2_PLAY)
227
        {
267
        {
-
 
268
            while( (astream.count < buffsize*2) &&
-
 
269
                   (player_state != CLOSED) )
-
 
270
            yield();
-
 
271
 
-
 
272
            SetTimeBase(hBuff, audio_base);
228
            GetTimeStamp(hBuff, &last_time_stamp);
273
            GetTimeStamp(hBuff, &last_time_stamp);
-
 
274
            printf("last audio time stamp %f\n", last_time_stamp);
-
 
275
            
229
            if((err = PlayBuffer(hBuff, 0)) !=0 )
276
            if((err = PlayBuffer(hBuff, 0)) !=0 )
230
            {
277
            {
231
                errstr = "Cannot play buffer\n\r";
278
                errstr = "Cannot play buffer\n\r";
232
                goto exit_whith_error;
279
                goto exit_whith_error;
233
            };
280
            };
234
            active = 1;
281
            active = 1;
235
            sync_audio(hBuff, buffsize);
282
            sync_audio(hBuff, buffsize);
236
            player_state = PLAY;
283
            player_state = PLAY;
237
            printf("audio delta %f\n", audio_delta);
284
            printf("render: set audio latency to %f\n", audio_delta);
238
        };
285
        };
Line 239... Line 286...
239
 
286
 
Line 240... Line 287...
240
        GetNotify(&evnt);
287
        GetNotify(&evnt);