diff mbox

aplay: Fix header for raw format

Message ID 1498735036-26126-1-git-send-email-ion-horia.petrisor@nxp.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ion-Horia Petrisor June 29, 2017, 11:17 a.m. UTC
Raw format has no header, so use 0 when calling playback_go.

Signed-off-by: Ion-Horia Petrisor <ion-horia.petrisor@nxp.com>
---
 aplay/aplay.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Takashi Iwai June 30, 2017, 6:54 a.m. UTC | #1
On Thu, 29 Jun 2017 13:17:16 +0200,
Ion-Horia Petrisor wrote:
> 
> Raw format has no header, so use 0 when calling playback_go.

It's the value passed for the length that has been already loaded.
The program has read dta bytes for parsing the header, and it's raw
data without header.  Thus you need to pass dta there.


thanks,

Takashi

> 
> Signed-off-by: Ion-Horia Petrisor <ion-horia.petrisor@nxp.com>
> ---
>  aplay/aplay.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/aplay/aplay.c b/aplay/aplay.c
> index 00af662..fe274ed 100644
> --- a/aplay/aplay.c
> +++ b/aplay/aplay.c
> @@ -2831,7 +2831,7 @@ static void playback(char *name)
>  		/* should be raw data */
>  		init_raw_data();
>  		pbrec_count = calc_count();
> -		playback_go(fd, dta, pbrec_count, FORMAT_RAW, name);
> +		playback_go(fd, 0, pbrec_count, FORMAT_RAW, name);
>  	}
>        __end:
>  	if (fd != 0)
> -- 
> 2.7.4
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
Daniel Baluta June 30, 2017, 1:11 p.m. UTC | #2
Hi Takashi,

Thanks a lot for your feedback.

On Fri, Jun 30, 2017 at 9:54 AM, Takashi Iwai <tiwai@suse.de> wrote:
> On Thu, 29 Jun 2017 13:17:16 +0200,
> Ion-Horia Petrisor wrote:
>>
>> Raw format has no header, so use 0 when calling playback_go.
>
> It's the value passed for the length that has been already loaded.
> The program has read dta bytes for parsing the header, and it's raw
> data without header.  Thus you need to pass dta there.
>
With the current code we assume that the raw files have at least 26 bytes.
(sizeof (VocHeader).

I think it doesn't matter here that dta bytes has already been loaded. These
bytes useful to figure out the file header type.

To keep things simple we can assume that in the case of raw files there is no
header, so second parameter of playback_go (named loaded) can be set to 0.

The worst things that can happen is that we re-read the first 26 bytes
(previously
read as VoC header).

We are trying to introduce a new parameter --samples which tells aplay to  only
playback/record s number of samples.

We modified calc_count() accordingly so that when receives the
--samples parameter
computes the correct number of bytes to be read.

Anyhow, it doesn't work as expected because aplay expects files to have at least
26 bytes.

The correct solution would be that in the case of raw files not assume
any header
and read samples * sample_size bytes from the beginning of the file.

>
> thanks,
>
> Takashi
>
>>
>> Signed-off-by: Ion-Horia Petrisor <ion-horia.petrisor@nxp.com>
>> ---
>>  aplay/aplay.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/aplay/aplay.c b/aplay/aplay.c
>> index 00af662..fe274ed 100644
>> --- a/aplay/aplay.c
>> +++ b/aplay/aplay.c
>> @@ -2831,7 +2831,7 @@ static void playback(char *name)
>>               /* should be raw data */
>>               init_raw_data();
>>               pbrec_count = calc_count();
>> -             playback_go(fd, dta, pbrec_count, FORMAT_RAW, name);
>> +             playback_go(fd, 0, pbrec_count, FORMAT_RAW, name);
>>       }
>>        __end:
>>       if (fd != 0)
>> --
>> 2.7.4
>>
>> _______________________________________________
>> Alsa-devel mailing list
>> Alsa-devel@alsa-project.org
>> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
diff mbox

Patch

diff --git a/aplay/aplay.c b/aplay/aplay.c
index 00af662..fe274ed 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -2831,7 +2831,7 @@  static void playback(char *name)
 		/* should be raw data */
 		init_raw_data();
 		pbrec_count = calc_count();
-		playback_go(fd, dta, pbrec_count, FORMAT_RAW, name);
+		playback_go(fd, 0, pbrec_count, FORMAT_RAW, name);
 	}
       __end:
 	if (fd != 0)