The Linux distribution of imx6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

The Linux distribution of imx6

1,158 Views
Mihan
Contributor IV

Could somebody tell me the distribution of imx6?

Cus I have some question about Qt media player. Or could someone tell me how to solve this problem:

defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"

Labels (1)
0 Kudos
3 Replies

926 Views
Rita_Wang
NXP TechSupport
NXP TechSupport

All the linux BSP released in our website, you can see them. About your question, could you tell us more information, which board and bsp are you using.

https://community.nxp.com/docs/DOC-94066?sr=search&searchId=48cdb04c-a64d-49a1-b57e-15839597c6b3&sea... This is for old BSP.

0 Kudos

926 Views
Mihan
Contributor IV

Hello b45499‌, these days I tried using alsa to play WAV file. On ubuntu desktop, it works well. But on the device,it doesn't work, with error message when snd_pcm_hw_params:

format=0x1, channels=0x1,sample_fq=8000,byte_p_sec=16000,byte_p_sample=2,bit_p_sample=16
pcm_data_size=0x2f18
hw_params: format=2, channels=1
set hw params error:Invalid argument

there is the code:

int CSound::PlayWAVFile(QString path)
{
int i, fd;
int ret, dir, size;
unsigned int val, val2;
char* buffer;
snd_pcm_t* handle;
snd_pcm_hw_params_t* params;
snd_pcm_uframes_t periodsize;
snd_pcm_uframes_t frames;
HWParams hw_params;
// if(argc<2)
// {
// qDebug("usage ./play ");
// return -1;
// }
fd = open(path.toLatin1().data(), O_RDWR);
if(fd<0)
{
qDebug("file open error");
return -1;
}
Check_WAVFile(fd, &hw_params); //从wav头中分析出的参数,保存在hw_param中

if( (ret = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, 0)) < 0)
{
qDebug("open pcm device error:%s", snd_strerror(ret));
return -1;
}

snd_pcm_hw_params_alloca(&params);
snd_pcm_hw_params_any(handle, params);
snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
//snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_S16_LE); //last param get from wav file
snd_pcm_hw_params_set_format(handle, params, hw_params.format);

//snd_pcm_hw_params_set_channels(handle, params, 2);
snd_pcm_hw_params_set_channels(handle, params, hw_params.channels); //last param get from wav file
qDebug("hw_params: format=%d, channels=%d", hw_params.format, hw_params.channels);

val = 44100;
snd_pcm_hw_params_set_rate_near(handle,params, &val, &dir);

frames = 32*4;
snd_pcm_hw_params_set_period_size_near(handle, params, &frames, &dir);
//3. set param to driver
if((ret=snd_pcm_hw_params(handle, params)) < 0)
{
qDebug("set hw params error:%s", snd_strerror(ret));
return -1;
}

snd_pcm_hw_params_get_period_size(params, &frames, &dir);
size = frames*4; //2byte/smaple, 2 channels
buffer = (char*)malloc(size);

snd_pcm_hw_params_get_period_time(params, &val, &dir);
while(1)
{
ret = read(fd, buffer, size); 
if(ret==0)
{
qDebug("end of file");
// return 0;
break;
}else if (ret!=size)
{
qDebug("short read");
}

ret = snd_pcm_writei(handle, buffer, frames); 
if(ret == -EPIPE)
{
//qDebug("-EPIPE");
snd_pcm_prepare(handle);
}
}

snd_pcm_drain(handle);
snd_pcm_close(handle);
free(buffer);
return EXIT_SUCCESS;
}

int CSound::Check_WAVFile(int fd, HWParams* hw_params)
{
int ret;
int i, len;
WaveHeader* header;
WaveFmtBody* fmt;
WaveChunkHeader* chunk_header;
unsigned char* pbuf = (unsigned char*)malloc(128);
if(NULL == pbuf)
{
qDebug("pbuf malloc error");
return -1;
}
//1. check Wave Header
len = sizeof(WaveHeader);
if( (ret=read(fd, pbuf, len)) != len)
{
qDebug("read error");
return -1;
}
header = (WaveHeader*)pbuf;
if( (header->magic!=WAV_RIFF) || (header->type!=WAV_WAVE))
{
qDebug("not a wav file");
return -1;
}
//2. check Wave Fmt
len = sizeof(WaveChunkHeader)+sizeof(WaveFmtBody);
if( (ret=read(fd, pbuf, len)) != len)
{
qDebug("read error");
return -1;
}
chunk_header = (WaveChunkHeader*)pbuf;
if( chunk_header->type!=WAV_FMT)
{
qDebug("fmt body error");
return -1;
}
fmt = (WaveFmtBody*)(pbuf+sizeof(WaveChunkHeader));
if(fmt->format != 0x0001) //WAV_FMT_PCM
{
qDebug("format is not pcm");
return -1;
}
qDebug("format=0x%x, channels=0x%x,sample_fq=%d,byte_p_sec=%d,byte_p_sample=%d,bit_p_sample=%d",
fmt->format, fmt->channels,fmt->sample_fq, fmt->byte_p_sec,
fmt->byte_p_spl, fmt->bit_p_spl);
//copy params
hw_params->channels = fmt->channels;
hw_params->rate = fmt->sample_fq;
switch(fmt->bit_p_spl)
{
case 8:
hw_params->format = SND_PCM_FORMAT_U8;
break;
case 16:
hw_params->format = SND_PCM_FORMAT_S16_LE;
break;
default:
qDebug("FIXME: add more format");
break;
}
//3. check data chunk
len = sizeof(WaveChunkHeader);
if( (ret=read(fd, pbuf, len)) != len)
{
qDebug("read error");
return -1;
}
chunk_header = (WaveChunkHeader*)pbuf;
if(chunk_header->type != WAV_DATA)
{
qDebug("not data chunk");
return -1;
}
qDebug("pcm_data_size=0x%x",chunk_header->length);

free(pbuf);
pbuf = NULL;
return -1;
}

0 Kudos

927 Views
Mihan
Contributor IV

Hi~ I'm so sorry that I didn't reply until now.

I have made a new topic https://community.nxp.com/thread/512276. But I still don't understand it.

What is the relationship between the interface and GStreamer or PulseAudio.

I just want to play a music by Qt. T^T

Does it mean I should rebuild the linux kernel or the Qt for Arm?

Thank you so much for your help.

0 Kudos