Subversion Repositories Kolibri OS

Rev

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

Rev 6133 Rev 6144
Line 27... Line 27...
27
static int snd_format;
27
static int snd_format;
28
int sample_rate;
28
int sample_rate;
Line 29... Line 29...
29
 
29
 
30
static uint32_t samples_written = 0;
-
 
31
double audio_base = -1.0;
-
 
32
 
-
 
Line 33... Line 30...
33
double get_audio_base();
30
static uint32_t samples_written = 0;
34
 
31
 
35
int init_audio(int format)
32
int init_audio(int format)
36
{
33
{
Line 126... Line 123...
126
            int planar    = av_sample_fmt_is_planar(ctx->sample_fmt);
123
            int planar    = av_sample_fmt_is_planar(ctx->sample_fmt);
127
            int data_size = av_samples_get_buffer_size(&plane_size, ctx->channels,
124
            int data_size = av_samples_get_buffer_size(&plane_size, ctx->channels,
128
                                                   aFrame->nb_samples,
125
                                                   aFrame->nb_samples,
129
                                                   ctx->sample_fmt, 1);
126
                                                   ctx->sample_fmt, 1);
130
 
127
            pkt_tmp.data += len;
131
//            if(audio_base == -1.0)
-
 
132
//            {
-
 
133
//                if (pkt.pts != AV_NOPTS_VALUE)
-
 
134
//                    audio_base = get_audio_base() * pkt.pts;
-
 
135
//                printf("audio base %f\n", audio_base);
-
 
136
//            };
-
 
137
 
-
 
138
            pkt_tmp.data += len;
-
 
139
            pkt_tmp.size -= len;
128
            pkt_tmp.size -= len;
140
 
129
 
Line 141... Line 130...
141
            dec_channel_layout =
130
            dec_channel_layout =
142
                (aFrame->channel_layout && aFrame->channels == av_get_channel_layout_nb_channels(aFrame->channel_layout)) ?
131
                (aFrame->channel_layout && aFrame->channels == av_get_channel_layout_nb_channels(aFrame->channel_layout)) ?
Line 252... Line 241...
252
};
241
};
Line 253... Line 242...
253
 
242
 
254
int audio_thread(void *param)
243
int audio_thread(void *param)
-
 
244
{
255
{
245
    vst_t *vst = param;
Line 256... Line 246...
256
    SND_EVENT evnt;
246
    SND_EVENT evnt;
257
 
247
 
258
    int       buffsize;
248
    int       buffsize;
Line 304... Line 294...
304
                    if(astream.count)
294
                    if(astream.count)
305
                        memcpy(astream.buffer, astream.buffer+buffsize*2, astream.count);
295
                        memcpy(astream.buffer, astream.buffer+buffsize*2, astream.count);
306
                mutex_unlock(&astream.lock);
296
                mutex_unlock(&astream.lock);
307
 
297
 
Line 308... Line 298...
308
                SetTimeBase(hBuff, audio_base);
298
                SetTimeBase(hBuff, vst->audio_timer_base);
Line 309... Line 299...
309
 
299
 
310
            case PAUSE_2_PLAY:
300
            case PAUSE_2_PLAY:
311
                GetTimeStamp(hBuff, &last_time_stamp);
-
 
Line 312... Line 301...
312
//                printf("last audio time stamp %f\n", last_time_stamp);
301
                GetTimeStamp(hBuff, &last_time_stamp);
313
 
302
 
314
                if((err = PlayBuffer(hBuff, 0)) !=0 )
303
                if((err = PlayBuffer(hBuff, 0)) !=0 )
315
                {
304
                {
316
                    errstr = "Cannot play buffer\n\r";
305
                    errstr = "Cannot play buffer\n\r";
317
                    goto exit_whith_error;
306
                    goto exit_whith_error;
318
                };
307
                };
319
                active = 1;
308
                active = 1;
320
                sync_audio(hBuff, buffsize);
-
 
Line 321... Line 309...
321
                sound_state = PLAY;
309
                sync_audio(hBuff, buffsize);
Line 322... Line 310...
322
//                printf("render: set audio latency to %f\n", audio_delta);
310
                sound_state = PLAY;
323
 
311
 
Line 383... Line 371...
383
            case PLAY_2_STOP:
371
            case PLAY_2_STOP:
384
                if( active )
372
                if( active )
385
                {
373
                {
386
                    ResetBuffer(hBuff, SND_RESET_ALL);
374
                    ResetBuffer(hBuff, SND_RESET_ALL);
387
                    audio_base = -1.0;
375
                	vst->audio_timer_valid = 0;
388
                    active = 0;
376
                    active = 0;
389
                }
377
                }
390
                sound_state = STOP;
378
                sound_state = STOP;
391
                break;
379
                break;