mirror of
https://github.com/mpv-player/mpv
synced 2025-01-21 23:23:19 +00:00
audio: replace af_fmt2str_short -> af_fmt_to_str
Also, remove all af_fmt2str usages.
This commit is contained in:
parent
aa48eeac97
commit
91626b1c06
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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};
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user