Fix memory leak : valgrind
[platform/core/api/audio-io.git] / test / audio_io_test.c
index b1926a3..717b8d2 100644 (file)
@@ -59,11 +59,13 @@ void play_file(char *file, int length, int ch)
 
        audio_out_prepare(output);
        audio_out_write(output, buf, length);
+       audio_out_drain(output);
        audio_out_unprepare(output);
 
        audio_out_destroy(output);
 
        fclose(fp);
+       free(buf);
 
        printf("play done\n");
 }
@@ -109,6 +111,8 @@ void play_file_sample(char *file, int frequency, int ch, int type)
                return;
        }
 
+       getchar();
+
        while (file_size > 0) {
                read_bytes = fread(buf, 1, buffer_size, fp);
                printf("Read %d Requested - %d\n", read_bytes, buffer_size);
@@ -559,11 +563,11 @@ int audio_io_async_test(int mode)
        }
 
        do {
-               int gotchar;
                printf("command(q:quit) : ");
-               gotchar = getchar();
-               if (gotchar == EOF)
+               ret = getchar();
+               if (ret == EOF)
                        goto EXIT;
+               cmd = (char)ret;
                if (cmd != '\n')
                        getchar();
                cmd_ret = _convert_cmd_and_run(cmd, mode);