return lrint(rate * speed); } // Return the format libavresample should convert to, given the final output // format mp_format. In some cases (S24) we perform an extra conversion step, // and signal here what exactly libavresample should output. It will be the // input to the final conversion to mp_format. static int check_output_conversion(int mp_format) { if (mp_format == AF_FORMAT_S24) return AV_SAMPLE_FMT_S32; return af_to_avformat(mp_format); } static struct mp_chmap fudge_pairs[][2] = { {MP_CHMAP2(BL, BR), MP_CHMAP2(SL, SR)}, {MP_CHMAP2(SL, SR), MP_CHMAP2(BL, BR)}, {MP_CHMAP2(SDL, SDR), MP_CHMAP2(SL, SR)}, {MP_CHMAP2(SL, SR), MP_CHMAP2(SDL, SDR)}, }; // Modify out_layout and return the new value. The intention is reducing the // loss libswresample's rematrixing will cause by exchanging similar, but // strictly speaking incompatible channel pairs. For example, 7.1 should be // changed to 7.1(wide) without dropping the SL/SR channels. (We still leave // it to libswresample to create the remix matrix.) static uint64_t fudge_layout_conversion(struct af_instance *af, uint64_t in, uint64_t out) { for (int n = 0; n < MP_ARRAY_SIZE(fudge_pairs); n++) { uint64_t a = mp_chmap_to_lavc(&fudge_pairs[n][0]);
p->delay -= delta * (int)(p->par.bps * p->par.pchan); } /* * call-back invoked to notify about volume changes */ static void volcb(void *addr, unsigned newvol) { struct priv *p = addr; p->vol = newvol; } static const struct mp_chmap sndio_layouts[MP_NUM_CHANNELS + 1] = { {0}, // empty {1, {MP_SPEAKER_ID_FL}}, // mono MP_CHMAP2(FL, FR), // stereo {0}, // 2.1 MP_CHMAP4(FL, FR, BL, BR), // 4.0 {0}, // 5.0 MP_CHMAP6(FL, FR, BL, BR, FC, LFE), // 5.1 {0}, // 6.1 MP_CHMAP8(FL, FR, BL, BR, FC, LFE, SL, SR), // 7.1 /* above is the fixed channel assignment for sndio, since we need to fill all channels and cannot insert silence, not all layouts are supported. */ }; /* * open device and setup parameters * return: 0=success -1=fail */ static int init(struct ao *ao)