]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - ao_write.c
paraslash 0.7.3
[paraslash.git] / ao_write.c
index e469a394fa6ee8df698a633274cf16394891e102..43a58dd6d5a364f2370659608302e6c7d9f24324 100644 (file)
@@ -1,8 +1,4 @@
-/*
- * Copyright (C) 2011 Andre Noll <maan@tuebingen.mpg.de>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2011 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
 
 /** \file ao_write.c Paraslash's libao output plugin. */
 
 
 /** \file ao_write.c Paraslash's libao output plugin. */
 
@@ -46,7 +42,7 @@ static void aow_close(struct writer_node *wn)
        ao_shutdown();
 }
 
        ao_shutdown();
 }
 
-static void aow_pre_select(struct sched *s, void *context)
+static void aow_pre_monitor(struct sched *s, void *context)
 {
        struct writer_node *wn = context;
        struct private_aow_data *pawd = wn->private_data;
 {
        struct writer_node *wn = context;
        struct private_aow_data *pawd = wn->private_data;
@@ -91,7 +87,7 @@ static int aow_set_sample_format(unsigned sample_rate, unsigned channels,
                case SF_U8:
                case SF_U16_LE:
                case SF_U16_BE:
                case SF_U8:
                case SF_U16_LE:
                case SF_U16_BE:
-                       return -E_AO_BAD_SAMPLE_FORMAT;
+                       return -E_BAD_SAMPLE_FORMAT;
                case SF_S8:
                        /* no need to set byte_format */
                        result->bits = 8;
                case SF_S8:
                        /* no need to set byte_format */
                        result->bits = 8;
@@ -163,8 +159,8 @@ static void aow_show_drivers(void)
 
                if (info->type == AO_TYPE_FILE)
                        continue;
 
                if (info->type == AO_TYPE_FILE)
                        continue;
-               PARA_DEBUG_LOG("%s: %s", info->short_name, info->name);
-               PARA_DEBUG_LOG("priority: %d", info->priority);
+               PARA_DEBUG_LOG("name: %s: %s\n", info->short_name, info->name);
+               PARA_DEBUG_LOG("priority: %d\n", info->priority);
                for (j = 0; j < info->option_count; j++) {
                        tmp = make_message("%s%s%s", keys? keys : "",
                                keys? ", " : "",
                for (j = 0; j < info->option_count; j++) {
                        tmp = make_message("%s%s%s", keys? keys : "",
                                keys? ", " : "",
@@ -172,9 +168,9 @@ static void aow_show_drivers(void)
                        free(keys);
                        keys = tmp;
                }
                        free(keys);
                        keys = tmp;
                }
-               PARA_DEBUG_LOG("keys: %s", keys? keys : "[none]");
+               PARA_DEBUG_LOG("keys: %s\n", keys? keys : "[none]");
                free(keys);
                free(keys);
-               PARA_DEBUG_LOG("comment: %s", info->comment?
+               PARA_DEBUG_LOG("comment: %s\n", info->comment?
                        info->comment : "[none]");
        }
 }
                        info->comment : "[none]");
        }
 }
@@ -188,7 +184,7 @@ static int aow_init(struct writer_node *wn, unsigned sample_rate,
        ao_info *info;
        const struct lls_opt_result *r;
        unsigned n;
        ao_info *info;
        const struct lls_opt_result *r;
        unsigned n;
-       struct private_aow_data *pawd = para_malloc(sizeof(*pawd));
+       struct private_aow_data *pawd = alloc(sizeof(*pawd));
 
        ao_initialize();
        aow_show_drivers();
 
        ao_initialize();
        aow_show_drivers();
@@ -248,7 +244,7 @@ fail:
        return ret;
 }
 
        return ret;
 }
 
-__noreturn static void *aow_play(void *priv)
+static void *aow_play(void *priv)
 {
        struct writer_node *wn = priv;
        struct private_aow_data *pawd = wn->private_data;
 {
        struct writer_node *wn = priv;
        struct private_aow_data *pawd = wn->private_data;
@@ -270,7 +266,7 @@ __noreturn static void *aow_play(void *priv)
                                if (frames > 0)
                                        break;
                                /* eof and less than a single frame available */
                                if (frames > 0)
                                        break;
                                /* eof and less than a single frame available */
-                               ret = -E_WRITE_COMMON_EOF;
+                               ret = -E_EOF;
                                goto fail;
                        }
                        /*
                                goto fail;
                        }
                        /*
@@ -346,7 +342,7 @@ fail:
        return -E_AO_PTHREAD;
 }
 
        return -E_AO_PTHREAD;
 }
 
-static int aow_post_select(__a_unused struct sched *s, void *context)
+static int aow_post_monitor(__a_unused struct sched *s, void *context)
 {
        struct writer_node *wn = context;
        struct private_aow_data *pawd = wn->private_data;
 {
        struct writer_node *wn = context;
        struct private_aow_data *pawd = wn->private_data;
@@ -361,9 +357,15 @@ static int aow_post_select(__a_unused struct sched *s, void *context)
                        goto remove_btrn;
                if (ret == 0)
                        return 0;
                        goto remove_btrn;
                if (ret == 0)
                        return 0;
-               get_btr_sample_rate(wn->btrn, &rate);
-               get_btr_channels(wn->btrn, &ch);
-               get_btr_sample_format(wn->btrn, &format);
+               ret = get_btr_sample_rate(wn->btrn, &rate);
+               if (ret < 0)
+                       goto remove_btrn;
+               ret = get_btr_channels(wn->btrn, &ch);
+               if (ret < 0)
+                       goto remove_btrn;
+               ret = get_btr_sample_format(wn->btrn, &format);
+               if (ret < 0)
+                       goto remove_btrn;
                ret = aow_init(wn, rate, ch, format);
                if (ret < 0)
                        goto remove_btrn;
                ret = aow_init(wn, rate, ch, format);
                if (ret < 0)
                        goto remove_btrn;
@@ -386,7 +388,7 @@ static int aow_post_select(__a_unused struct sched *s, void *context)
        if (!wn->btrn) {
                if (!pawd->thread_btrn) {
                        pthread_join(pawd->thread, NULL);
        if (!wn->btrn) {
                if (!pawd->thread_btrn) {
                        pthread_join(pawd->thread, NULL);
-                       return -E_AO_EOF;
+                       return -E_EOF;
                }
                PARA_INFO_LOG("waiting for play thread to terminate\n");
                return 0;
                }
                PARA_INFO_LOG("waiting for play thread to terminate\n");
                return 0;
@@ -419,7 +421,7 @@ out:
 
 struct writer lsg_write_cmd_com_ao_user_data = {
        .close = aow_close,
 
 struct writer lsg_write_cmd_com_ao_user_data = {
        .close = aow_close,
-       .pre_select = aow_pre_select,
-       .post_select = aow_post_select,
+       .pre_monitor = aow_pre_monitor,
+       .post_monitor = aow_post_monitor,
 };
 
 };