diff options
Diffstat (limited to 'audio')
-rw-r--r-- | audio/filter/af.c | 34 | ||||
-rw-r--r-- | audio/filter/af.h | 3 | ||||
-rw-r--r-- | audio/filter/af_scaletempo.c | 5 | ||||
-rw-r--r-- | audio/mixer.c | 4 | ||||
-rw-r--r-- | audio/out/ao_alsa.c | 27 | ||||
-rw-r--r-- | audio/out/ao_coreaudio_utils.c | 12 |
6 files changed, 52 insertions, 33 deletions
diff --git a/audio/filter/af.c b/audio/filter/af.c index 2889e87bb7..8d29e332a8 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -561,6 +561,23 @@ static int af_reinit(struct af_stream *s) retry++; continue; } + // If the format conversion is (probably) caused by spdif, then + // (as a feature) drop the filter, instead of failing hard. + int fmt_in1 = af->prev->data->format; + int fmt_in2 = in.format; + if (af_fmt_is_valid(fmt_in1) && af_fmt_is_valid(fmt_in2)) { + bool spd1 = AF_FORMAT_IS_IEC61937(fmt_in1); + bool spd2 = AF_FORMAT_IS_IEC61937(fmt_in2); + if (spd1 != spd2) { + MP_WARN(af, "Filter %s apparently cannot be used due to " + "spdif passthrough - removing it.\n", + af->info->name); + struct af_instance *aft = af->prev; + af_remove(s, af); + af = aft->next; + break; + } + } goto negotiate_error; } case AF_DETACH: { // Filter is redundant and wants to be unloaded @@ -689,8 +706,14 @@ int af_init(struct af_stream *s) to the stream s. The filter will be inserted somewhere nice in the list of filters. The return value is a pointer to the new filter, If the filter couldn't be added the return value is NULL. */ -struct af_instance *af_add(struct af_stream *s, char *name, char **args) +struct af_instance *af_add(struct af_stream *s, char *name, char *label, + char **args) { + assert(label); + + if (af_find_by_label(s, label)) + return NULL; + struct af_instance *new; // Insert the filter somewhere nice if (af_is_conversion_filter(s->first->next)) @@ -699,17 +722,14 @@ struct af_instance *af_add(struct af_stream *s, char *name, char **args) new = af_prepend(s, s->first->next, name, args); if (!new) return NULL; + new->label = talloc_strdup(new, label); // Reinitalize the filter list if (af_reinit(s) != AF_OK) { - af_remove(s, new); - if (af_reinit(s) != AF_OK) { - af_uninit(s); - af_init(s); - } + af_remove_by_label(s, label); return NULL; } - return new; + return af_find_by_label(s, label); } struct af_instance *af_find_by_label(struct af_stream *s, char *label) diff --git a/audio/filter/af.h b/audio/filter/af.h index 4c67208123..65a30f7dd1 100644 --- a/audio/filter/af.h +++ b/audio/filter/af.h @@ -141,7 +141,8 @@ struct af_stream *af_new(struct mpv_global *global); void af_destroy(struct af_stream *s); int af_init(struct af_stream *s); void af_uninit(struct af_stream *s); -struct af_instance *af_add(struct af_stream *s, char *name, char **args); +struct af_instance *af_add(struct af_stream *s, char *name, char *label, + char **args); int af_remove_by_label(struct af_stream *s, char *label); struct af_instance *af_find_by_label(struct af_stream *s, char *label); struct af_instance *af_control_any_rev(struct af_stream *s, int cmd, void *arg); diff --git a/audio/filter/af_scaletempo.c b/audio/filter/af_scaletempo.c index 1f187a98bc..ad8e520601 100644 --- a/audio/filter/af_scaletempo.c +++ b/audio/filter/af_scaletempo.c @@ -303,11 +303,6 @@ static int control(struct af_instance *af, int cmd, void *arg) int nch = data->nch; int use_int = 0; - if (AF_FORMAT_IS_SPECIAL(data->format)) { - MP_ERR(af, "Changing speed is not supported with spdif formats.\n"); - return AF_ERROR; - } - mp_audio_force_interleaved_format(data); mp_audio_copy_config(af->data, data); diff --git a/audio/mixer.c b/audio/mixer.c index 0eb9c86453..7ae7ed458d 100644 --- a/audio/mixer.c +++ b/audio/mixer.c @@ -135,7 +135,7 @@ static void setvolume_internal(struct mixer *mixer, float l, float r) if (gain == 1.0) return; MP_VERBOSE(mixer, "Inserting volume filter.\n"); - if (!(af_add(mixer->af, "volume", NULL) + if (!(af_add(mixer->af, "volume", "softvol", NULL) && af_control_any_rev(mixer->af, AF_CONTROL_SET_VOLUME, &gain))) MP_ERR(mixer, "No volume control available.\n"); } @@ -222,7 +222,7 @@ void mixer_setbalance(struct mixer *mixer, float val) if (val == 0) return; - if (!(af_pan_balance = af_add(mixer->af, "pan", NULL))) { + if (!(af_pan_balance = af_add(mixer->af, "pan", "autopan", NULL))) { MP_ERR(mixer, "No balance control available.\n"); return; } diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index f84a781e8a..b60c8363f1 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -376,6 +376,7 @@ static int try_open_device(struct ao *ao, const char *device) IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER, map_iec958_srate(ao->samplerate)); const char *ac3_device = append_params(tmp, device, params); + MP_VERBOSE(ao, "opening device '%s' => '%s'\n", device, ac3_device); int err = snd_pcm_open (&p->alsa, ac3_device, SND_PCM_STREAM_PLAYBACK, 0); talloc_free(tmp); @@ -383,6 +384,7 @@ static int try_open_device(struct ao *ao, const char *device) return 0; } + MP_VERBOSE(ao, "opening device '%s'\n", device); return snd_pcm_open(&p->alsa, device, SND_PCM_STREAM_PLAYBACK, 0); } @@ -408,23 +410,14 @@ static int init_device(struct ao *ao) struct priv *p = ao->priv; int err; - if (!p->cfg_ni) - ao->format = af_fmt_from_planar(ao->format); - const char *device = "default"; - if (AF_FORMAT_IS_IEC61937(ao->format)) { + if (AF_FORMAT_IS_IEC61937(ao->format)) device = "iec958"; - MP_VERBOSE(ao, "playing AC3/iec61937/iec958, %i channels\n", - ao->channels.num); - } if (ao->device) device = ao->device; if (p->cfg_device && p->cfg_device[0]) device = p->cfg_device; - MP_VERBOSE(ao, "using device: %s\n", device); - MP_VERBOSE(ao, "using ALSA version: %s\n", snd_asoundlib_version()); - err = try_open_device(ao, device); CHECK_ALSA_ERROR("Playback open error"); @@ -551,8 +544,11 @@ static int init_device(struct ao *ao) err = snd_pcm_set_chmap(p->alsa, alsa_chmap); if (err == -ENXIO) { - MP_WARN(ao, "Device does not support requested channel map (%s)\n", - mp_chmap_to_str(&dev_chmap)); + // I consider this an ALSA bug: the channel map was reported as + // supported, but we still can't set it. It happens virtually + // always with dmix, though. + MP_VERBOSE(ao, "Device does not support requested channel map (%s)\n", + mp_chmap_to_str(&dev_chmap)); } else { CHECK_ALSA_WARN("Channel map setup failed"); } @@ -607,6 +603,7 @@ static int init_device(struct ao *ao) // the number of channels to 2 either, because the hw params // are already set! So just fuck it and reopen the device with // the chmap "cleaned out" of NA entries. + MP_VERBOSE(ao, "Working around braindead ALSA behavior.\n"); err = snd_pcm_close(p->alsa); p->alsa = NULL; CHECK_ALSA_ERROR("pcm close error"); @@ -678,6 +675,12 @@ alsa_error: static int init(struct ao *ao) { + struct priv *p = ao->priv; + if (!p->cfg_ni) + ao->format = af_fmt_from_planar(ao->format); + + MP_VERBOSE(ao, "using ALSA version: %s\n", snd_asoundlib_version()); + int r = init_device(ao); if (r == INIT_BRAINDEATH) r = init_device(ao); // retry with normalized channel layout diff --git a/audio/out/ao_coreaudio_utils.c b/audio/out/ao_coreaudio_utils.c index 64d98e5ece..8485011722 100644 --- a/audio/out/ao_coreaudio_utils.c +++ b/audio/out/ao_coreaudio_utils.c @@ -117,12 +117,12 @@ OSStatus ca_select_device(struct ao *ao, char* name, AudioDeviceID *device) if (mp_msg_test(ao->log, MSGL_V)) { char *desc; err = CA_GET_STR(*device, kAudioObjectPropertyName, &desc); - CHECK_CA_ERROR("could not get selected audio device name"); - - MP_VERBOSE(ao, "selected audio output device: %s (%" PRIu32 ")\n", - desc, *device); - - talloc_free(desc); + CHECK_CA_WARN("could not get selected audio device name"); + if (err == noErr) { + MP_VERBOSE(ao, "selected audio output device: %s (%" PRIu32 ")\n", + desc, *device); + talloc_free(desc); + } } coreaudio_error: |