Click here to Skip to main content
15,900,653 members

Comments by mot sach (Top 15 by date)

mot sach 10-Jul-12 21:51pm View    
yeah, could you suggest for me how to solve that (sorry because i am newbie), ^_^.
mot sach 8-Jul-12 23:54pm View    
this is my source code:

#define DBG_MSG(msg) printk(KERN_INFO "[test] %s %s\n", __FUNCTION__, msg)

struct class* test_class;
dev_t devt;
struct device* dev;
static int __init test_init(void)
{
DBG_MSG("enter");
test_class = class_create(THIS_MODULE, "test_class");
if ( IS_ERR(test_class) ) {
printk ( "can't create test class\n" );
class_destroy(test_class);
return PTR_ERR(test_class);
}
//register test device
major = register_chrdev(FPGA_DYNAMIC_MAJOR, "test", &test_fops);
printk ( "[test] %d\n", major );
devt = MKDEV(major, 0);
dev = device_create(test_class, NULL, devt, NULL, "test");
device_register(dev);
DBG_MSG("exit succesfull");
return 0;
}


after installed modules, and called mdev -s command, i can read /sys/class/test_class/test/dev, but i can't read /dev/test. Could you help me solve this problem? Thank so much!
mot sach 4-Jul-12 3:42am View    
sorry, this is out put:
# ls -l /dev/test
output:
/dev/test

# cat /dev/test
output:
cat: can't open '/dev/test': No such device or address

i really don't understand difference between calling device_create function and mknod command
mot sach 12-Jan-12 21:32pm View    
yes, thank so much, this is my solution:
<pre lang="c++">
unsigned int period_size = 4096; // size of buffer
//init mix chunk
Mix_Chunk* sound = (Mix_Chunk*) malloc(sizeof(Mix_Chunk);

sound->alen = 4096;
sound->abuf = (uint8_t*) malloc(period_size);
sound->allocated = true;

void play(data, len)
{
while (len) {
//copy data to chunk
if (len > period_size) {
memcpy(sound->abuf, data + index, sound->alen);
len -= sound->alen;
index += sound->alen;
}
else {
memcpy(sound->abuf, data + index, len);
len -= len;
index += len;
}
//Play our sound file, and capture the channel on which it is played
channel2 = Mix_PlayChannel(-1, sound2, 0);
if (channel2 == -1) {
printf("Unable to play WAV file: %s\n", Mix_GetError());
exit(-1);
}
//Wait until the sound has stopped playing
while(Mix_Playing(channel2) != 0);
}
}
</pre>

Sequentially, I has copied data from stream by block (4096 bytes), then waiting finished play it . It work ok. But i think this is not good ideal. Do you think so
mot sach 12-Jan-12 5:38am View    
yes, if small file is ok, but if large file, can't allocate large buffer, so i think must split stream into smaller block, then write data to hardware using SDL lib. But with this solution, i met synchronization problem. i can't solve this. Can you help me?