summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-06-21 19:46:30 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-07-22 21:53:17 +0200
commitf9a31bc3d9fba6f42f5d8c9dd0afccbe5f690589 (patch)
treeee5c6ca68224fa7a1182dd8d15ede6c98ef3f5f3
parentf35f6a34b534cf4524f035e442fff6324875ed85 (diff)
downloadmpv-f9a31bc3d9fba6f42f5d8c9dd0afccbe5f690589.tar.bz2
mpv-f9a31bc3d9fba6f42f5d8c9dd0afccbe5f690589.tar.xz
ao_coreaudio: refactor print_help
-rw-r--r--audio/out/ao_coreaudio.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c
index 4986e3a817..acab24799b 100644
--- a/audio/out/ao_coreaudio.c
+++ b/audio/out/ao_coreaudio.c
@@ -183,12 +183,6 @@ static int AudioStreamChangeFormat(AudioStreamID i_stream_id,
static void print_help(void)
{
- OSStatus err;
- UInt32 i_param_size;
- int num_devices;
- AudioDeviceID *devids;
- char *device_name;
-
ca_msg(MSGL_FATAL,
"\n-ao coreaudio commandline help:\n"
"Example: mpv -ao coreaudio:device_id=266\n"
@@ -201,29 +195,31 @@ static void print_help(void)
"\n"
"Available output devices:\n");
- i_param_size = GetGlobalAudioPropertyArray(kAudioObjectSystemObject,
- kAudioHardwarePropertyDevices,
- (void **)&devids);
-
- if (!i_param_size) {
+ AudioDeviceID *devs;
+ uint32_t devs_size =
+ GetGlobalAudioPropertyArray(kAudioObjectSystemObject,
+ kAudioHardwarePropertyDevices,
+ (void **)&devs);
+ if (!devs_size) {
ca_msg(MSGL_FATAL, "Failed to get list of output devices.\n");
return;
}
- num_devices = i_param_size / sizeof(AudioDeviceID);
+ int devs_n = devs_size / sizeof(AudioDeviceID);
- for (int i = 0; i < num_devices; ++i) {
- err = GetAudioPropertyString(devids[i], kAudioObjectPropertyName,
- &device_name);
+ for (int i = 0; i < devs_n; ++i) {
+ char *name;
+ OSStatus err =
+ GetAudioPropertyString(devs[i], kAudioObjectPropertyName, &name);
if (err == noErr) {
- ca_msg(MSGL_FATAL, "%s (id: %" PRIu32 ")\n", device_name, devids[i]);
- free(device_name);
+ ca_msg(MSGL_FATAL, "%s (id: %" PRIu32 ")\n", name, devs[i]);
+ free(name);
} else
- ca_msg(MSGL_FATAL, "Unknown (id: %" PRIu32 ")\n", devids[i]);
+ ca_msg(MSGL_FATAL, "Unknown (id: %" PRIu32 ")\n", devs[i]);
}
- free(devids);
+ free(devs);
}
static int init(struct ao *ao, char *params)
@@ -240,7 +236,7 @@ static int init(struct ao *ao, char *params)
UInt32 size, maxFrames, b_alive;
char *psz_name;
AudioDeviceID devid_def = 0;
- int device_id, display_help = 0;
+ int device_id = 0, display_help = 0;
const opt_t subopts[] = {
{"device_id", OPT_ARG_INT, &device_id, NULL},
@@ -248,15 +244,14 @@ static int init(struct ao *ao, char *params)
{NULL}
};
- // set defaults
- device_id = 0;
-
- if (subopt_parse(ao_subdevice, subopts) != 0 || display_help) {
+ if (subopt_parse(params, subopts) != 0) {
print_help();
- if (!display_help)
- return 0;
+ return 0;
}
+ if (display_help)
+ print_help();
+
ca_msg(MSGL_V, "init([%dHz][%dch][%s][%d])\n",
ao->samplerate, ao->channels.num, af_fmt2str_short(ao->format), 0);