diff options
author | wm4 <wm4@nowhere> | 2014-11-24 19:56:01 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-11-24 19:56:01 +0100 |
commit | 28b6ce39d3d88d0159b54c8ca558e993eac93056 (patch) | |
tree | fa3c94a84cd2efebf24b1ea5fd75dd1fbcc01c12 /audio/out | |
parent | 2228d4737367fb0303bec263bc06ca90c9ff8757 (diff) |
audio: make mp_chmap_to_str() return a stack-allocated string
Simplifies memory management.
Diffstat (limited to 'audio/out')
-rw-r--r-- | audio/out/ao.c | 5 | ||||
-rw-r--r-- | audio/out/ao_alsa.c | 8 |
2 files changed, 4 insertions, 9 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c index f0461b8c09..893699e2f5 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -214,10 +214,9 @@ static struct ao *ao_alloc_pb(bool probing, struct mpv_global *global, static int ao_init(struct ao *ao) { - char *chmap = mp_chmap_to_str(&ao->channels); MP_VERBOSE(ao, "requested format: %d Hz, %s channels, %s\n", - ao->samplerate, chmap, af_fmt_to_str(ao->format)); - talloc_free(chmap); + ao->samplerate, mp_chmap_to_str(&ao->channels), + af_fmt_to_str(ao->format)); ao->api = ao->driver->play ? &ao_api_push : &ao_api_pull; ao->api_priv = talloc_zero_size(ao, ao->api->priv_size); diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 910ac98437..01414d63fc 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -317,10 +317,8 @@ static const char *select_chmap(struct ao *ao) return device_channel_layouts[n][0]; } - char *name = mp_chmap_to_str(&ao->channels); MP_ERR(ao, "channel layout %s (%d ch) not supported.\n", - name, ao->channels.num); - talloc_free(name); + mp_chmap_to_str(&ao->channels), ao->channels.num); return "default"; } @@ -587,9 +585,7 @@ static int init(struct ao *ao) for (int c = 0; c < chmap.num; c++) chmap.speaker[c] = find_mp_channel(alsa_chmap->pos[c]); - char *mp_map_str = mp_chmap_to_str(&chmap); - MP_VERBOSE(ao, "which we understand as: %s\n", mp_map_str); - talloc_free(mp_map_str); + MP_VERBOSE(ao, "which we understand as: %s\n", mp_chmap_to_str(&chmap)); if (mp_chmap_is_valid(&chmap) && chmap.num == ao->channels.num) { MP_VERBOSE(ao, "using the ALSA channel map.\n"); |