]> git.alsa-project.org Git - tinycompress.git/commitdiff
fcplay: Add gapless playback support
authorMohammad Rafi Shaik <quic_mohs@quicinc.com>
Thu, 28 Sep 2023 06:52:36 +0000 (12:22 +0530)
committerJaroslav Kysela <perex@perex.cz>
Wed, 22 Nov 2023 08:07:50 +0000 (09:07 +0100)
Add Gapless playback support while playing multiple audio files.

Gapless play command:
fcplay -c 1 -d 2 -g 1 test1.mp3 test2.mp3

In command "-g 1" option for enable gapless play.

Signed-off-by: Mohammad Rafi Shaik <quic_mohs@quicinc.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
src/utils-lgpl/fcplay.c

index f007d9bc46e5a1dfbcd5f8784e81508d53df9eba..c534292de0003f34d6bd9580ba2cb5317e42728b 100644 (file)
@@ -57,13 +57,16 @@ static void usage(void)
                "-d\tdevice node\n"
                "-I\tspecify codec ID (default is mp3)\n"
                "-b\tbuffer size\n"
-               "-f\tfragments\n\n"
+               "-f\tfragments\n"
+               "-g\tgapless play\n\n"
                "-v\tverbose mode\n"
                "-h\tPrints this help list\n\n"
                "Example:\n"
                "\tfcplay -c 1 -d 2 test.mp3\n"
                "\tfcplay -f 5 test.mp3\n"
-               "\tfcplay -c 1 -d 2 test1.mp3 test2.mp3\n\n"
+               "\tfcplay -c 1 -d 2 test1.mp3 test2.mp3\n"
+               "\tGapless:\n"
+               "\t\tfcplay -c 1 -d 2 -g 1 test1.mp3 test2.mp3\n\n"
                "Valid codec IDs:\n");
 
        for (i = 0; i < CPLAY_NUM_CODEC_IDS; ++i)
@@ -77,7 +80,7 @@ static void usage(void)
 
 void play_samples(char **files, unsigned int card, unsigned int device,
                unsigned long buffer_size, unsigned int frag,
-               unsigned long codec_id, unsigned int file_count);
+               unsigned long codec_id, unsigned int file_count, unsigned int gapless);
 
 static int print_time(struct compress *compress)
 {
@@ -100,13 +103,13 @@ int main(int argc, char **argv)
        int c, i;
        unsigned int card = 0, device = 0, frag = 0;
        unsigned int codec_id = SND_AUDIOCODEC_MP3;
-       unsigned int file_count = 0;
+       unsigned int file_count = 0, gapless = 0;
 
        if (argc < 2)
                usage();
 
        verbose = 0;
-       while ((c = getopt(argc, argv, "hvb:f:c:d:I:")) != -1) {
+       while ((c = getopt(argc, argv, "hvb:f:c:d:I:g:")) != -1) {
                switch (c) {
                case 'h':
                        usage();
@@ -123,6 +126,9 @@ int main(int argc, char **argv)
                case 'd':
                        device = strtol(optarg, NULL, 10);
                        break;
+               case 'g':
+                       gapless = strtol(optarg, NULL, 10);
+                       break;
                case 'I':
                        if (optarg[0] == '0') {
                                codec_id = strtol(optarg, NULL, 0);
@@ -157,7 +163,8 @@ int main(int argc, char **argv)
        //file_count represents total number of files to play
        file_count = argc - optind;
 
-       play_samples(file, card, device, buffer_size, frag, codec_id, file_count);
+       play_samples(file, card, device, buffer_size, frag, codec_id,
+                       file_count, gapless);
 
        fprintf(stderr, "Finish Playing.... Close Normally\n");
        exit(EXIT_SUCCESS);