Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 274659
Collapse All | Expand All

(-)a/src/vorbis/vorbis.c (-41 / +22 lines)
Lines 119-125 Link Here
119
static OggVorbis_File vf;
119
static OggVorbis_File vf;
120
120
121
static GThread *thread;
121
static GThread *thread;
122
static volatile int seekneeded = -1;
122
static volatile int seekneeded;
123
static volatile char pause_flag;
123
static volatile char pause_flag;
124
static int samplerate, channels;
124
static int samplerate, channels;
125
GMutex *vf_mutex;
125
GMutex *vf_mutex;
Lines 291-298 Link Here
291
     * alert us what section we're currently decoding in case we
291
     * alert us what section we're currently decoding in case we
292
     * need to change playback settings at a section boundary
292
     * need to change playback settings at a section boundary
293
     */
293
     */
294
 
294
295
   
295
296
    g_mutex_lock(vf_mutex);
296
    g_mutex_lock(vf_mutex);
297
    if (ov_open_callbacks(datasource, &vf, NULL, 0, aud_vfs_is_streaming(fd->fd) ? vorbis_callbacks_stream : vorbis_callbacks) < 0) {
297
    if (ov_open_callbacks(datasource, &vf, NULL, 0, aud_vfs_is_streaming(fd->fd) ? vorbis_callbacks_stream : vorbis_callbacks) < 0) {
298
        vorbis_callbacks.close_func(datasource);
298
        vorbis_callbacks.close_func(datasource);
Lines 316-322 Link Here
316
    title = vorbis_generate_title(&vf, filename);
316
    title = vorbis_generate_title(&vf, filename);
317
    vorbis_update_replaygain(&rg_info);
317
    vorbis_update_replaygain(&rg_info);
318
    playback->set_replaygain_info(playback, &rg_info);
318
    playback->set_replaygain_info(playback, &rg_info);
319
    
319
320
    vi = ov_info(&vf, -1);
320
    vi = ov_info(&vf, -1);
321
321
322
    samplerate = vi->rate;
322
    samplerate = vi->rate;
Lines 331-338 Link Here
331
        goto play_cleanup;
331
        goto play_cleanup;
332
    }
332
    }
333
333
334
    seekneeded = -1;
335
336
    /*
334
    /*
337
     * Note that chaining changes things here; A vorbis file may
335
     * Note that chaining changes things here; A vorbis file may
338
     * be a mix of different channels, bitrates and sample rates.
336
     * be a mix of different channels, bitrates and sample rates.
Lines 341-349 Link Here
341
     */
339
     */
342
340
343
    while (playback->playing) {
341
    while (playback->playing) {
344
       
342
345
        if (playback->eof) {
343
        if (playback->eof) {
346
            g_usleep(20000);
344
            g_usleep(1000);
347
            continue;
345
            continue;
348
        }
346
        }
349
347
Lines 352-364 Link Here
352
        if (pause_flag)
350
        if (pause_flag)
353
            do_pause (playback);
351
            do_pause (playback);
354
352
355
        
353
356
        int current_section = last_section;
354
        int current_section = last_section;
357
355
358
        g_mutex_lock(vf_mutex);
356
        g_mutex_lock(vf_mutex);
359
        
357
360
        bytes = ov_read_float(&vf, &pcm, PCM_FRAMES, &current_section);
358
        bytes = ov_read_float(&vf, &pcm, PCM_FRAMES, &current_section);
361
        
359
362
        if (bytes > 0)
360
        if (bytes > 0)
363
            bytes = vorbis_interleave_buffer(pcm, bytes, channels, pcmout);
361
            bytes = vorbis_interleave_buffer(pcm, bytes, channels, pcmout);
364
362
Lines 393-399 Link Here
393
            if (vi->rate != samplerate || vi->channels != channels) {
391
            if (vi->rate != samplerate || vi->channels != channels) {
394
                samplerate = vi->rate;
392
                samplerate = vi->rate;
395
                channels = vi->channels;
393
                channels = vi->channels;
396
                while(playback->output->buffer_playing()) g_usleep(50000);
394
                while (playback->output->buffer_playing())
395
                    g_usleep(1000);
397
                playback->output->close_audio();
396
                playback->output->close_audio();
398
                if (!playback->output->
397
                if (!playback->output->
399
                        open_audio(FMT_FLOAT, vi->rate, vi->channels)) {
398
                        open_audio(FMT_FLOAT, vi->rate, vi->channels)) {
Lines 412-425 Link Here
412
411
413
        playback->pass_audio(playback, FMT_FLOAT, channels, bytes, pcmout, &playback->playing);
412
        playback->pass_audio(playback, FMT_FLOAT, channels, bytes, pcmout, &playback->playing);
414
413
415
        if (!playback->playing)
416
            goto stop_processing;
417
418
        if (seekneeded != -1)
419
            do_seek(playback);
420
421
        stop_processing:
414
        stop_processing:
422
   
415
423
        if (current_section <= last_section) {
416
        if (current_section <= last_section) {
424
            /*
417
            /*
425
            * set total play time, bitrate, rate, and channels of
418
            * set total play time, bitrate, rate, and channels of
Lines 435-467 Link Here
435
                time = ov_time_total(&vf, -1) * 1000;
428
                time = ov_time_total(&vf, -1) * 1000;
436
429
437
            g_mutex_unlock(vf_mutex);
430
            g_mutex_unlock(vf_mutex);
438
        
431
439
            playback->set_params(playback, title, time, br, samplerate, channels);
432
            playback->set_params(playback, title, time, br, samplerate, channels);
440
433
441
            timercount = playback->output->output_time();
434
            timercount = playback->output->output_time();
442
435
443
            last_section = current_section;
436
            last_section = current_section;
444
         
437
445
        }
438
        }
446
    } /* main loop */
439
    } /* main loop */
447
440
448
    if (!playback->error) {
441
  play_cleanup:
449
        /*this loop makes it not skip the last ~4 seconds, but the playback 
442
    playback->output->close_audio();
450
         * timer isn't updated in this period, so it still needs a bit of work 
451
         *
452
         * majeru
453
         */
454
        if(playback->eof) /* do it only on EOF --asphyx */
455
            while(playback->output->buffer_playing()) {
456
                AUDDBG("waiting for empty output buffer\n");
457
                g_usleep(50000);
458
            }
459
460
        playback->output->close_audio();
461
    }
462
443
463
464
    play_cleanup:
465
    g_free(title);
444
    g_free(title);
466
445
467
    /*
446
    /*
Lines 481-486 Link Here
481
    playback->playing = 1;
460
    playback->playing = 1;
482
    playback->eof = 0;
461
    playback->eof = 0;
483
    playback->error = FALSE;
462
    playback->error = FALSE;
463
    seekneeded = -1;
464
    pause_flag = 0;
484
465
485
    thread = g_thread_self();
466
    thread = g_thread_self();
486
    playback->set_pb_ready(playback);
467
    playback->set_pb_ready(playback);
Lines 527-540 Link Here
527
    rg_gain = vorbis_comment_query(comment, "replaygain_album_gain", 0);
508
    rg_gain = vorbis_comment_query(comment, "replaygain_album_gain", 0);
528
    if (!rg_gain) rg_gain = vorbis_comment_query(comment, "rg_audiophile", 0);    /* Old */
509
    if (!rg_gain) rg_gain = vorbis_comment_query(comment, "rg_audiophile", 0);    /* Old */
529
    rg_info->album_gain = rg_gain != NULL ? atof(rg_gain) : 0.0;
510
    rg_info->album_gain = rg_gain != NULL ? atof(rg_gain) : 0.0;
530
    
511
531
    rg_gain = vorbis_comment_query(comment, "replaygain_track_gain", 0);
512
    rg_gain = vorbis_comment_query(comment, "replaygain_track_gain", 0);
532
    if (!rg_gain) rg_gain = vorbis_comment_query(comment, "rg_radio", 0);    /* Old */
513
    if (!rg_gain) rg_gain = vorbis_comment_query(comment, "rg_radio", 0);    /* Old */
533
    rg_info->track_gain = rg_gain != NULL ? atof(rg_gain) : 0.0;
514
    rg_info->track_gain = rg_gain != NULL ? atof(rg_gain) : 0.0;
534
    
515
535
    rg_peak = vorbis_comment_query(comment, "replaygain_album_peak", 0);
516
    rg_peak = vorbis_comment_query(comment, "replaygain_album_peak", 0);
536
    rg_info->album_peak = rg_peak != NULL ? atof(rg_peak) : 0.0;
517
    rg_info->album_peak = rg_peak != NULL ? atof(rg_peak) : 0.0;
537
    
518
538
    rg_peak = vorbis_comment_query(comment, "replaygain_track_peak", 0);
519
    rg_peak = vorbis_comment_query(comment, "replaygain_track_peak", 0);
539
    if (!rg_peak) rg_peak = vorbis_comment_query(comment, "rg_peak", 0);  /* Old */
520
    if (!rg_peak) rg_peak = vorbis_comment_query(comment, "rg_peak", 0);  /* Old */
540
    rg_info->track_peak = rg_peak != NULL ? atof(rg_peak) : 0.0;
521
    rg_info->track_peak = rg_peak != NULL ? atof(rg_peak) : 0.0;
Lines 608-614 Link Here
608
    }
589
    }
609
    else
590
    else
610
        aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "Ogg Vorbis");
591
        aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "Ogg Vorbis");
611
    
592
612
    aud_tuple_associate_string(tuple, FIELD_MIMETYPE, NULL, "application/ogg");
593
    aud_tuple_associate_string(tuple, FIELD_MIMETYPE, NULL, "application/ogg");
613
594
614
    return tuple;
595
    return tuple;

Return to bug 274659