From e4d71aca3cc153bbac505dac430b3b5574f15016 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 13 Feb 2014 00:01:40 +0100 Subject: remove fmt parameter from ausrc/auplay api --- include/baresip.h | 2 -- modules/alsa/alsa_play.c | 2 -- modules/alsa/alsa_src.c | 2 -- modules/auloop/auloop.c | 2 -- modules/coreaudio/coreaudio.c | 26 -------------------------- modules/coreaudio/coreaudio.h | 2 -- modules/coreaudio/player.c | 10 +++++----- modules/coreaudio/recorder.c | 10 +++++----- modules/gst/gst.c | 2 -- modules/oss/oss.c | 4 ---- modules/portaudio/portaudio.c | 4 ---- modules/rst/audio.c | 2 -- modules/winwave/play.c | 2 -- modules/winwave/src.c | 2 -- src/audio.c | 2 -- src/play.c | 1 - 16 files changed, 10 insertions(+), 65 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index 03ea090..8abb2ee 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -256,7 +256,6 @@ struct ausrc_st; /** Audio Source parameters */ struct ausrc_prm { - int fmt; /**< Audio format (enum aufmt) */ uint32_t srate; /**< Sampling rate in [Hz] */ uint8_t ch; /**< Number of channels */ uint32_t ptime; /**< Wanted packet-time in [ms] */ @@ -288,7 +287,6 @@ struct auplay_st; /** Audio Player parameters */ struct auplay_prm { - int fmt; /**< Audio format (enum aufmt) */ uint32_t srate; /**< Sampling rate in [Hz] */ uint8_t ch; /**< Number of channels */ uint32_t ptime; /**< Wanted packet-time in [ms] */ diff --git a/modules/alsa/alsa_play.c b/modules/alsa/alsa_play.c index a0afa4e..8c9de96 100644 --- a/modules/alsa/alsa_play.c +++ b/modules/alsa/alsa_play.c @@ -95,8 +95,6 @@ int alsa_play_alloc(struct auplay_st **stp, struct auplay *ap, if (!stp || !ap || !prm || !wh) return EINVAL; - if (prm->fmt != AUFMT_S16LE) - return EINVAL; if (!str_isset(device)) device = alsa_dev; diff --git a/modules/alsa/alsa_src.c b/modules/alsa/alsa_src.c index 67e6bcb..4e2a16a 100644 --- a/modules/alsa/alsa_src.c +++ b/modules/alsa/alsa_src.c @@ -96,8 +96,6 @@ int alsa_src_alloc(struct ausrc_st **stp, struct ausrc *as, if (!stp || !as || !prm || !rh) return EINVAL; - if (prm->fmt != AUFMT_S16LE) - return EINVAL; if (!str_isset(device)) device = alsa_dev; diff --git a/modules/auloop/auloop.c b/modules/auloop/auloop.c index 821c5e6..a55997f 100644 --- a/modules/auloop/auloop.c +++ b/modules/auloop/auloop.c @@ -223,7 +223,6 @@ static int auloop_reset(struct audio_loop *al) if (err) return err; - auplay_prm.fmt = AUFMT_S16LE; auplay_prm.srate = al->srate; auplay_prm.ch = al->ch; auplay_prm.ptime = PTIME; @@ -236,7 +235,6 @@ static int auloop_reset(struct audio_loop *al) return err; } - ausrc_prm.fmt = AUFMT_S16LE; ausrc_prm.srate = al->srate; ausrc_prm.ch = al->ch; ausrc_prm.ptime = PTIME; diff --git a/modules/coreaudio/coreaudio.c b/modules/coreaudio/coreaudio.c index bb6ea64..0d21e2b 100644 --- a/modules/coreaudio/coreaudio.c +++ b/modules/coreaudio/coreaudio.c @@ -14,32 +14,6 @@ static struct auplay *auplay; static struct ausrc *ausrc; -int audio_fmt(enum aufmt fmt) -{ - switch (fmt) { - - case AUFMT_S16LE: return kAudioFormatLinearPCM; - case AUFMT_PCMA: return kAudioFormatALaw; - case AUFMT_PCMU: return kAudioFormatULaw; - default: - warning("coreaudio: unknown format %d\n", fmt); - return -1; - } -} - - -int bytesps(enum aufmt fmt) -{ - switch (fmt) { - - case AUFMT_S16LE: return 2; - case AUFMT_PCMA: return 1; - case AUFMT_PCMU: return 1; - default: return 0; - } -} - - #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_2_0 static void interruptionListener(void *data, UInt32 inInterruptionState) { diff --git a/modules/coreaudio/coreaudio.h b/modules/coreaudio/coreaudio.h index 530e45e..67cb7d5 100644 --- a/modules/coreaudio/coreaudio.h +++ b/modules/coreaudio/coreaudio.h @@ -8,8 +8,6 @@ int audio_session_enable(void); void audio_session_disable(void); -int audio_fmt(enum aufmt fmt); -int bytesps(enum aufmt fmt); int coreaudio_player_alloc(struct auplay_st **stp, struct auplay *ap, struct auplay_prm *prm, const char *device, diff --git a/modules/coreaudio/player.c b/modules/coreaudio/player.c index 68aca4e..1243450 100644 --- a/modules/coreaudio/player.c +++ b/modules/coreaudio/player.c @@ -110,17 +110,17 @@ int coreaudio_player_alloc(struct auplay_st **stp, struct auplay *ap, goto out; fmt.mSampleRate = (Float64)prm->srate; - fmt.mFormatID = audio_fmt(prm->fmt); + fmt.mFormatID = kAudioFormatLinearPCM; fmt.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; #ifdef __BIG_ENDIAN__ fmt.mFormatFlags |= kAudioFormatFlagIsBigEndian; #endif fmt.mFramesPerPacket = 1; - fmt.mBytesPerFrame = prm->ch * bytesps(prm->fmt); - fmt.mBytesPerPacket = prm->ch * bytesps(prm->fmt); + fmt.mBytesPerFrame = prm->ch * 2; + fmt.mBytesPerPacket = prm->ch * 2; fmt.mChannelsPerFrame = prm->ch; - fmt.mBitsPerChannel = 8*bytesps(prm->fmt); + fmt.mBitsPerChannel = 16; status = AudioQueueNewOutput(&fmt, play_handler, st, NULL, kCFRunLoopCommonModes, 0, &st->queue); @@ -131,7 +131,7 @@ int coreaudio_player_alloc(struct auplay_st **stp, struct auplay *ap, } sampc = prm->srate * prm->ch * prm->ptime / 1000; - bytc = sampc * bytesps(prm->fmt); + bytc = sampc * 2; for (i=0; ibuf); i++) { diff --git a/modules/coreaudio/recorder.c b/modules/coreaudio/recorder.c index b1f91fc..57f2390 100644 --- a/modules/coreaudio/recorder.c +++ b/modules/coreaudio/recorder.c @@ -132,7 +132,7 @@ int coreaudio_recorder_alloc(struct ausrc_st **stp, struct ausrc *as, st->arg = arg; sampc = prm->srate * prm->ch * prm->ptime / 1000; - bytc = sampc * bytesps(prm->fmt); + bytc = sampc * 2; st->mb = mbuf_alloc(bytc); if (!st->mb) { @@ -149,7 +149,7 @@ int coreaudio_recorder_alloc(struct ausrc_st **stp, struct ausrc *as, goto out; fmt.mSampleRate = (Float64)prm->srate; - fmt.mFormatID = audio_fmt(prm->fmt); + fmt.mFormatID = kAudioFormatLinearPCM; fmt.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; #ifdef __BIG_ENDIAN__ @@ -157,10 +157,10 @@ int coreaudio_recorder_alloc(struct ausrc_st **stp, struct ausrc *as, #endif fmt.mFramesPerPacket = 1; - fmt.mBytesPerFrame = prm->ch * bytesps(prm->fmt); - fmt.mBytesPerPacket = prm->ch * bytesps(prm->fmt); + fmt.mBytesPerFrame = prm->ch * 2; + fmt.mBytesPerPacket = prm->ch * 2; fmt.mChannelsPerFrame = prm->ch; - fmt.mBitsPerChannel = 8*bytesps(prm->fmt); + fmt.mBitsPerChannel = 16; status = AudioQueueNewInput(&fmt, record_handler, st, NULL, kCFRunLoopCommonModes, 0, &st->queue); diff --git a/modules/gst/gst.c b/modules/gst/gst.c index 7af74f4..2f4d7f2 100644 --- a/modules/gst/gst.c +++ b/modules/gst/gst.c @@ -371,8 +371,6 @@ static int gst_alloc(struct ausrc_st **stp, struct ausrc *as, if (!prm) return EINVAL; - prm->fmt = AUFMT_S16LE; - st = mem_zalloc(sizeof(*st), gst_destructor); if (!st) return ENOMEM; diff --git a/modules/oss/oss.c b/modules/oss/oss.c index d7bff51..a69d44c 100644 --- a/modules/oss/oss.c +++ b/modules/oss/oss.c @@ -227,8 +227,6 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as, if (!device) device = oss_dev; - prm->fmt = AUFMT_S16LE; - sampc = prm->srate * prm->ch * prm->ptime / 1000; st->mb = mbuf_alloc(2 * sampc); @@ -285,8 +283,6 @@ static int play_alloc(struct auplay_st **stp, struct auplay *ap, if (!device) device = oss_dev; - prm->fmt = AUFMT_S16LE; - sampc = prm->srate * prm->ch * prm->ptime / 1000; st->sz = 2 * sampc; diff --git a/modules/portaudio/portaudio.c b/modules/portaudio/portaudio.c index 36ca3f1..764aa81 100644 --- a/modules/portaudio/portaudio.c +++ b/modules/portaudio/portaudio.c @@ -206,8 +206,6 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as, else dev_index = Pa_GetDefaultInputDevice(); - prm->fmt = AUFMT_S16LE; - st = mem_zalloc(sizeof(*st), ausrc_destructor); if (!st) return ENOMEM; @@ -251,8 +249,6 @@ static int play_alloc(struct auplay_st **stp, struct auplay *ap, else dev_index = Pa_GetDefaultOutputDevice(); - prm->fmt = AUFMT_S16LE; - st = mem_zalloc(sizeof(*st), auplay_destructor); if (!st) return ENOMEM; diff --git a/modules/rst/audio.c b/modules/rst/audio.c index 554ec21..8809e37 100644 --- a/modules/rst/audio.c +++ b/modules/rst/audio.c @@ -194,8 +194,6 @@ static int alloc_handler(struct ausrc_st **stp, struct ausrc *as, st->ptime = prm->ptime; st->psize = sampc * 2; - prm->fmt = AUFMT_S16LE; - re_printf("rst: audio ptime=%u psize=%u aubuf=[%u:%u]\n", st->ptime, st->psize, prm->srate * prm->ch * 2, diff --git a/modules/winwave/play.c b/modules/winwave/play.c index 1de2e1f..e2e5051 100644 --- a/modules/winwave/play.c +++ b/modules/winwave/play.c @@ -201,8 +201,6 @@ int winwave_play_alloc(struct auplay_st **stp, struct auplay *ap, st->wh = wh; st->arg = arg; - prm->fmt = AUFMT_S16LE; - err = write_stream_open(st, prm); if (err) goto out; diff --git a/modules/winwave/src.c b/modules/winwave/src.c index 1793bf3..c264a3d 100644 --- a/modules/winwave/src.c +++ b/modules/winwave/src.c @@ -193,8 +193,6 @@ int winwave_src_alloc(struct ausrc_st **stp, struct ausrc *as, st->rh = rh; st->arg = arg; - prm->fmt = AUFMT_S16LE; - err = read_stream_open(st, prm); if (err) diff --git a/src/audio.c b/src/audio.c index 548b5ac..dd43b0a 100644 --- a/src/audio.c +++ b/src/audio.c @@ -927,7 +927,6 @@ static int start_player(struct aurx *rx, struct audio *a) struct auplay_prm prm; - prm.fmt = AUFMT_S16LE; prm.srate = srate_dsp; prm.ch = channels_dsp; prm.ptime = rx->ptime; @@ -1004,7 +1003,6 @@ static int start_source(struct autx *tx, struct audio *a) struct ausrc_prm prm; - prm.fmt = AUFMT_S16LE; prm.srate = srate_dsp; prm.ch = channels_dsp; prm.ptime = tx->ptime; diff --git a/src/play.c b/src/play.c index fcd06a2..9fceecf 100644 --- a/src/play.c +++ b/src/play.c @@ -237,7 +237,6 @@ int play_tone(struct play **playp, struct mbuf *tone, uint32_t srate, if (err) goto out; - wprm.fmt = AUFMT_S16LE; wprm.ch = ch; wprm.srate = srate; wprm.ptime = PTIME; -- cgit v1.2.3