[nas] Re: Can play file with AuSoundPlayFromFile
Pooly
pooly7 at gmail.com
Fri Jul 28 09:09:37 MDT 2006
2006/7/28, Pooly <pooly7 at gmail.com>:
> Hi,
>
> I've installed NAS successfully and auplay works correctly. But if I
> do AuSoundPlayFromFile, I can't hear anything from the speaker.
>
> bool HFInitSound()
> {
> nas = AuOpenServer( NULL, 0, NULL, 0, NULL, NULL);
> if ( nas == NULL)
> fprintf(stderr, "Can't connect to audio server.\n");
> return nas != NULL;
> }
>
> the above code return true, so I guess the connection to the server is ok.
> The following runs fine, but no sound though :
> void HFPlaySound( const char *soundName)
> {
> if ( nas ) {
> AuFixedPoint volume, AuFixedPointFromFraction(100,100);
> if ( AuSoundPlayFromFile( nas, soundName, AuNone, volume,
> NULL, NULL, NULL, NULL, NULL, NULL ) == NULL )
> fprintf(stderr, "Can't play audio.\n");
> AuFlush(nas);
> }
I managed to get a sound by doing :
if ( nas ) {
AuStatus ret;
AuEvent ev;
AuFixedPoint volume, AuFixedPointFromFraction(100,100);
//sync_play_cb is a dummy callback and does not do anything
if ( AuSoundPlayFromFile( nas, soundName, AuNone, volume,
sync_play_cb, NULL, &autoflowid, NULL,
NULL, &ret) == NULL )
fprintf(stderr, "Can't play audio.\n");
AuNextEvent(nas, AuTrue, &ev);
AuDispatchEvent(nas, &ev);
}
Is it the correct way to play a file asynchronously ? I don't want to
have AuNextEvent waiting for an incoming event.
--
http://www.w-fenec.org/
More information about the Nas
mailing list