Switch to unified view

a/sc2src/alsadirect.cpp b/sc2src/alsadirect.cpp
...
...
87
        //ad->period_position = 0;
87
        //ad->period_position = 0;
88
        err = snd_pcm_prepare(pcm);
88
        err = snd_pcm_prepare(pcm);
89
        break;
89
        break;
90
    case SND_PCM_STATE_DISCONNECTED:
90
    case SND_PCM_STATE_DISCONNECTED:
91
        break;
91
        break;
92
  /* this is no error, so just keep running */
92
        /* this is no error, so just keep running */
93
    case SND_PCM_STATE_RUNNING:
93
    case SND_PCM_STATE_RUNNING:
94
        err = 0;
94
        err = 0;
95
        break;
95
        break;
96
    default:
96
    default:
97
        /* unknown state, do nothing */
97
        /* unknown state, do nothing */
...
...
436
// Data always comes in host order, because this is what we
436
// Data always comes in host order, because this is what we
437
// request from upstream. 24 and 32 bits are untested.
437
// request from upstream. 24 and 32 bits are untested.
438
static bool fixToFloats(AudioMessage *tsk, SRC_DATA& src_data,
438
static bool fixToFloats(AudioMessage *tsk, SRC_DATA& src_data,
439
                        size_t tot_samples)
439
                        size_t tot_samples)
440
{
440
{
441
442
    // For some reason, newer versions of libsamplerate define
443
    // data_in as const
444
    float *datain = (float *)&(src_data.data_in[0]);
441
    switch (tsk->m_bits) {
445
    switch (tsk->m_bits) {
442
    case 16: 
446
    case 16: 
443
    {
447
    {
444
        const short *sp = (const short *)tsk->m_buf;
448
        const short *sp = (const short *)tsk->m_buf;
445
        for (unsigned int i = 0; i < tot_samples; i++) {
449
        for (unsigned int i = 0; i < tot_samples; i++) {
446
            src_data.data_in[i] = *sp++;
450
            datain[i] = *sp++;
447
        }
451
        }
448
    }
452
    }
449
    break;
453
    break;
450
    case 24: 
454
    case 24: 
451
    {
455
    {
...
...
455
        for (unsigned int i = 0; i < tot_samples; i++) {
459
        for (unsigned int i = 0; i < tot_samples; i++) {
456
            ocp[0] = *icp++;
460
            ocp[0] = *icp++;
457
            ocp[1] = *icp++;
461
            ocp[1] = *icp++;
458
            ocp[2] = *icp++;
462
            ocp[2] = *icp++;
459
            ocp[3] = (ocp[2] & 0x80) ? 0xff : 0;
463
            ocp[3] = (ocp[2] & 0x80) ? 0xff : 0;
460
            src_data.data_in[i] = o;
464
            datain[i] = o;
461
        }
465
        }
462
    }
466
    }
463
    break;
467
    break;
464
    case 32: 
468
    case 32: 
465
    {
469
    {
466
        const int *ip = (const int *)tsk->m_buf;
470
        const int *ip = (const int *)tsk->m_buf;
467
        for (unsigned int i = 0; i < tot_samples; i++) {
471
        for (unsigned int i = 0; i < tot_samples; i++) {
468
            src_data.data_in[i] = *ip++;
472
            datain[i] = *ip++;
469
        }
473
        }
470
    }
474
    }
471
    break;
475
    break;
472
    default:
476
    default:
473
        LOGERR("audioEater:alsa: bad m_bits: " << tsk->m_bits << endl);
477
        LOGERR("audioEater:alsa: bad m_bits: " << tsk->m_bits << endl);
...
...
600
604
601
    // Possibly reallocate buffer
605
    // Possibly reallocate buffer
602
    size_t needed_bytes = tot_samples * sizeof(float);
606
    size_t needed_bytes = tot_samples * sizeof(float);
603
    if (src_input_bytes < needed_bytes) {
607
    if (src_input_bytes < needed_bytes) {
604
        src_data.data_in =
608
        src_data.data_in =
605
            (float *)realloc(src_data.data_in, needed_bytes);
609
            (float *)realloc((void *)src_data.data_in, needed_bytes);
606
        src_data.data_out = (float *)realloc(src_data.data_out,
610
        src_data.data_out = (float *)realloc(src_data.data_out,
607
                                             2 * needed_bytes);
611
                                             2 * needed_bytes);
608
        src_data.output_frames = 2 * tot_samples / tsk->m_chans;
612
        src_data.output_frames = 2 * tot_samples / tsk->m_chans;
609
        src_input_bytes = needed_bytes;
613
        src_input_bytes = needed_bytes;
610
    }
614
    }
...
...
744
            src_delete(src_state);
748
            src_delete(src_state);
745
        } else {
749
        } else {
746
            free(src_state);
750
            free(src_state);
747
        }
751
        }
748
    }
752
    }
749
    free(src_data.data_in);
753
    free((void *)src_data.data_in);
750
    free(src_data.data_out);
754
    free(src_data.data_out);
751
    LOGDEB("audioEater returning");
755
    LOGDEB("audioEater returning");
752
    return (void *)1;
756
    return (void *)1;
753
}
757
}
754
758