From 91626b1c0606afb9bb582070e8a444a3ba8395ab Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 7 Nov 2013 22:12:36 +0100 Subject: audio: replace af_fmt2str_short -> af_fmt_to_str Also, remove all af_fmt2str usages. --- audio/audio.c | 2 +- audio/decode/dec_audio.c | 2 +- audio/filter/af_bs2b.c | 3 +-- audio/filter/af_dummy.c | 2 +- audio/filter/af_lavcac3enc.c | 3 +-- audio/fmt-conversion.c | 2 +- audio/format.c | 11 +---------- audio/format.h | 5 ++--- audio/out/ao_alsa.c | 2 +- audio/out/ao_dsound.c | 4 ++-- audio/out/ao_oss.c | 10 +++++----- audio/out/ao_pcm.c | 2 +- audio/out/ao_wasapi.c | 8 ++++---- stream/tv.c | 5 ++--- 14 files changed, 24 insertions(+), 37 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index e1d3a76978..9d41928436 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -65,7 +65,7 @@ char *mp_audio_fmt_to_str(int srate, const struct mp_chmap *chmap, int format) { char *chstr = mp_chmap_to_str(chmap); char *res = talloc_asprintf(NULL, "%dHz %s %dch %s", srate, chstr, - chmap->num, af_fmt2str_short(format)); + chmap->num, af_fmt_to_str(format)); talloc_free(chstr); return res; } diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index b9ca71692f..127139ff60 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -160,7 +160,7 @@ int init_best_audio_codec(sh_audio_t *sh_audio, char *audio_decoders) mp_msg(MSGT_DECAUDIO, MSGL_V, "AUDIO: %d Hz, %d ch, %s\n", sh_audio->samplerate, sh_audio->channels.num, - af_fmt2str_short(sh_audio->sample_format)); + af_fmt_to_str(sh_audio->sample_format)); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_BITRATE=%d\nID_AUDIO_RATE=%d\n" "ID_AUDIO_NCH=%d\n", sh_audio->i_bps * 8, sh_audio->samplerate, sh_audio->channels.num); diff --git a/audio/filter/af_bs2b.c b/audio/filter/af_bs2b.c index aa92b8be23..0e77b3e4eb 100644 --- a/audio/filter/af_bs2b.c +++ b/audio/filter/af_bs2b.c @@ -74,7 +74,6 @@ static int control(struct af_instance *af, int cmd, void *arg) switch (cmd) { case AF_CONTROL_REINIT: { int format; - char buf[256]; // Sanity check if (!arg) return AF_ERROR; @@ -150,7 +149,7 @@ static int control(struct af_instance *af, int cmd, void *arg) } bs2b_set_srate(s->filter, (long)af->data->rate); mp_msg(MSGT_AFILTER, MSGL_V, "[bs2b] using format %s\n", - af_fmt2str(af->data->format,buf,256)); + af_fmt_to_str(af->data->format)); return af_test_output(af,(struct mp_audio*)arg); } diff --git a/audio/filter/af_dummy.c b/audio/filter/af_dummy.c index 03c9aa9e99..ab601ba9bb 100644 --- a/audio/filter/af_dummy.c +++ b/audio/filter/af_dummy.c @@ -34,7 +34,7 @@ static int control(struct af_instance* af, int cmd, void* arg) case AF_CONTROL_REINIT: ; *af->data = *(struct mp_audio*)arg; mp_msg(MSGT_AFILTER, MSGL_V, "[dummy] Was reinitialized: %iHz/%ich/%s\n", - af->data->rate,af->data->nch,af_fmt2str_short(af->data->format)); + af->data->rate,af->data->nch,af_fmt_to_str(af->data->format)); return AF_OK; } return AF_UNKNOWN; diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c index cd3548ea8f..9ca193017a 100644 --- a/audio/filter/af_lavcac3enc.c +++ b/audio/filter/af_lavcac3enc.c @@ -362,9 +362,8 @@ static int af_open(struct af_instance* af){ break; } } - char buf[100]; mp_msg(MSGT_AFILTER, MSGL_V, "[af_lavcac3enc]: in sample format: %s\n", - af_fmt2str(s->in_sampleformat, buf, 100)); + af_fmt_to_str(s->in_sampleformat)); s->pending_data_size = AF_NCH * AC3_FRAME_SIZE * af_fmt2bits(s->in_sampleformat) / 8; s->pending_data = malloc(s->pending_data_size); diff --git a/audio/fmt-conversion.c b/audio/fmt-conversion.c index ce2a9054bf..bb32361ce5 100644 --- a/audio/fmt-conversion.c +++ b/audio/fmt-conversion.c @@ -45,7 +45,7 @@ enum AVSampleFormat af_to_avformat(int fmt) sample_fmt = audio_conversion_map[i].sample_fmt; if (sample_fmt == AF_FORMAT_UNKNOWN) mp_msg(MSGT_GLOBAL, MSGL_V, "Unsupported sample format: %s\n", - af_fmt2str_short(fmt)); + af_fmt_to_str(fmt)); return sample_fmt; } diff --git a/audio/format.c b/audio/format.c index 9b0967ae53..01c9a431a1 100644 --- a/audio/format.c +++ b/audio/format.c @@ -62,15 +62,6 @@ int af_fmt_change_bits(int format, int bits) return af_fmt_is_valid(format) ? format : 0; } -/* Convert format to str input str is a buffer for the - converted string, size is the size of the buffer */ -char *af_fmt2str(int format, char* str, int size) -{ - const char *name = af_fmt2str_short(format); - snprintf(str, size, "%s", name); - return str; -} - const struct af_fmt_entry af_fmtstr_table[] = { { "mpeg2", AF_FORMAT_MPEG2 }, { "ac3le", AF_FORMAT_AC3_LE }, @@ -119,7 +110,7 @@ bool af_fmt_is_valid(int format) return false; } -const char *af_fmt2str_short(int format) +const char *af_fmt_to_str(int format) { for (int i = 0; af_fmtstr_table[i].name; i++) { if (af_fmtstr_table[i].format == format) diff --git a/audio/format.h b/audio/format.h index 9a898fe55c..6ec435b6b7 100644 --- a/audio/format.h +++ b/audio/format.h @@ -130,15 +130,14 @@ struct af_fmt_entry { extern const struct af_fmt_entry af_fmtstr_table[]; int af_str2fmt_short(bstr str); +const char *af_fmt_to_str(int format); + int af_fmt2bits(int format); int af_fmt_change_bits(int format, int bits); // Amount of bytes that contain audio of the given duration, aligned to frames. int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate); -char *af_fmt2str(int format, char* str, int size); -const char *af_fmt2str_short(int format); - bool af_fmt_is_valid(int format); #endif /* MPLAYER_AF_FORMAT_H */ diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 1ad7598075..1f7dc71d3d 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -442,7 +442,7 @@ static int init(struct ao *ao) err = snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt); if (err < 0) { MP_INFO(ao, "Format %s is not supported by hardware, trying default.\n", - af_fmt2str_short(ao->format)); + af_fmt_to_str(ao->format)); p->alsa_fmt = SND_PCM_FORMAT_S16_LE; if (AF_FORMAT_IS_AC3(ao->format)) ao->format = AF_FORMAT_AC3_LE; diff --git a/audio/out/ao_dsound.c b/audio/out/ao_dsound.c index 034f5d8446..464947c0dc 100644 --- a/audio/out/ao_dsound.c +++ b/audio/out/ao_dsound.c @@ -407,7 +407,7 @@ static int init(struct ao *ao) break; default: MP_VERBOSE(ao, "format %s not supported defaulting to Signed 16-bit Little-Endian\n", - af_fmt2str_short(format)); + af_fmt_to_str(format)); format = AF_FORMAT_S16_LE; } //set our audio parameters @@ -416,7 +416,7 @@ static int init(struct ao *ao) ao->bps = ao->channels.num * rate * (af_fmt2bits(format) >> 3); int buffersize = ao->bps; // space for 1 sec MP_VERBOSE(ao, "Samplerate:%iHz Channels:%i Format:%s\n", rate, - ao->channels.num, af_fmt2str_short(format)); + ao->channels.num, af_fmt_to_str(format)); MP_VERBOSE(ao, "Buffersize:%d bytes (%d msec)\n", buffersize, buffersize / ao->bps * 1000); diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index 283b960255..1a28267613 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -205,7 +205,7 @@ static int init(struct ao *ao) mchan = p->cfg_oss_mixer_channel; MP_VERBOSE(ao, "%d Hz %d chans %s\n", ao->samplerate, - ao->channels.num, af_fmt2str_short(ao->format)); + ao->channels.num, af_fmt_to_str(ao->format)); if (mchan) { int fd, devs, i; @@ -274,7 +274,7 @@ ac3_retry: oss_format = format2oss(ao->format); if (oss_format == -1) { MP_VERBOSE(ao, "Unknown/not supported internal format: %s\n", - af_fmt2str_short(ao->format)); + af_fmt_to_str(ao->format)); #if BYTE_ORDER == BIG_ENDIAN oss_format = AFMT_S16_BE; #else @@ -286,8 +286,8 @@ ac3_retry: oss_format != format2oss(ao->format)) { MP_WARN(ao, "Can't set audio device %s to %s output, trying %s...\n", - p->dsp, af_fmt2str_short(ao->format), - af_fmt2str_short(AF_FORMAT_S16_NE)); + p->dsp, af_fmt_to_str(ao->format), + af_fmt_to_str(AF_FORMAT_S16_NE)); ao->format = AF_FORMAT_S16_NE; goto ac3_retry; } @@ -298,7 +298,7 @@ ac3_retry: return -1; } - MP_VERBOSE(ao, "sample format: %s\n", af_fmt2str_short(ao->format)); + MP_VERBOSE(ao, "sample format: %s\n", af_fmt_to_str(ao->format)); if (!AF_FORMAT_IS_AC3(ao->format)) { struct mp_chmap_sel sel = {0}; diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c index d2f5f791ec..f7d793700d 100644 --- a/audio/out/ao_pcm.c +++ b/audio/out/ao_pcm.c @@ -145,7 +145,7 @@ static int init(struct ao *ao) MP_INFO(ao, "File: %s (%s)\nPCM: Samplerate: %d Hz Channels: %d Format: %s\n", priv->outputfilename, priv->waveheader ? "WAVE" : "RAW PCM", ao->samplerate, - ao->channels.num, af_fmt2str_short(ao->format)); + ao->channels.num, af_fmt_to_str(ao->format)); MP_INFO(ao, "Info: Faster dumping is achieved with -no-video\n"); MP_INFO(ao, "Info: To write WAVE files use -ao pcm:waveheader (default).\n"); diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index 47c6fcfdb7..c605e1cd5d 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -325,7 +325,7 @@ static int try_format(struct wasapi_state *state, EnterCriticalSection(&state->print_lock); mp_msg(MSGT_AO, MSGL_V, "ao-wasapi: trying %dch %s @ %dhz\n", - channels.num, af_fmt2str_short(af_format), samplerate); + channels.num, af_fmt_to_str(af_format), samplerate); LeaveCriticalSection(&state->print_lock); union WAVEFMT u; @@ -351,7 +351,7 @@ static int try_format(struct wasapi_state *state, if (set_ao_format(state, ao, wformat)) { EnterCriticalSection(&state->print_lock); mp_msg(MSGT_AO, MSGL_V, "ao-wasapi: accepted as %dch %s @ %dhz\n", - ao->channels.num, af_fmt2str_short(ao->format), ao->samplerate); + ao->channels.num, af_fmt_to_str(ao->format), ao->samplerate); LeaveCriticalSection(&state->print_lock); return 1; @@ -361,7 +361,7 @@ static int try_format(struct wasapi_state *state, if (set_ao_format(state, ao, wformat)) { EnterCriticalSection(&state->print_lock); mp_msg(MSGT_AO, MSGL_V, "ao-wasapi: %dch %s @ %dhz accepted\n", - ao->channels.num, af_fmt2str_short(af_format), samplerate); + ao->channels.num, af_fmt_to_str(af_format), samplerate); LeaveCriticalSection(&state->print_lock); return 1; } @@ -418,7 +418,7 @@ static int try_passthrough(struct wasapi_state *state, EnterCriticalSection(&state->print_lock); mp_msg(MSGT_AO, MSGL_V, "ao-wasapi: trying passthrough for %s...\n", - af_fmt2str_short((ao->format&~AF_FORMAT_END_MASK) | AF_FORMAT_LE)); + af_fmt_to_str((ao->format&~AF_FORMAT_END_MASK) | AF_FORMAT_LE)); LeaveCriticalSection(&state->print_lock); HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient, diff --git a/stream/tv.c b/stream/tv.c index dd76230a2e..0e5fe8c22d 100644 --- a/stream/tv.c +++ b/stream/tv.c @@ -762,7 +762,6 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check) if (tvh->tv_param->noaudio == 0 && funcs->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE) { int audio_format; - char buf[128]; /* yeah, audio is present */ @@ -785,8 +784,8 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check) break; case AF_FORMAT_MPEG2: default: - mp_tmsg(MSGT_TV, MSGL_ERR, "Audio type '%s (%x)' unsupported!\n", - af_fmt2str(audio_format, buf, 128), audio_format); + mp_tmsg(MSGT_TV, MSGL_ERR, "Audio type '%s' unsupported!\n", + af_fmt_to_str(audio_format)); goto no_audio; } -- cgit v1.2.3