comparison libao2/ao_dsound.c @ 14555:6fb9eca97d41

support immed flag, always initialize write_offset, min_free_space doesn't seem to be required anymore after Florian Dietrichs patches
author faust3
date Fri, 21 Jan 2005 13:22:59 +0000
parents cae0dbeb44bb
children 2f4f347bd5e4
comparison
equal deleted inserted replaced
14554:d1023c2b0414 14555:6fb9eca97d41
112 static LPDIRECTSOUND hds = NULL; ///direct sound object 112 static LPDIRECTSOUND hds = NULL; ///direct sound object
113 static LPDIRECTSOUNDBUFFER hdspribuf = NULL; ///primary direct sound buffer 113 static LPDIRECTSOUNDBUFFER hdspribuf = NULL; ///primary direct sound buffer
114 static LPDIRECTSOUNDBUFFER hdsbuf = NULL; ///secondary direct sound buffer (stream buffer) 114 static LPDIRECTSOUNDBUFFER hdsbuf = NULL; ///secondary direct sound buffer (stream buffer)
115 static int buffer_size = 0; ///size in bytes of the direct sound buffer 115 static int buffer_size = 0; ///size in bytes of the direct sound buffer
116 static int write_offset = 0; ///offset of the write cursor in the direct sound buffer 116 static int write_offset = 0; ///offset of the write cursor in the direct sound buffer
117 static int min_free_space = 4096; ///if the free space is below this value get_space() will return 0 117 static int min_free_space = 0; ///if the free space is below this value get_space() will return 0
118 static int device_num = 0; ///wanted device number 118 static int device_num = 0; ///wanted device number
119 static GUID device; ///guid of the device 119 static GUID device; ///guid of the device
120 120
121 /***************************************************************************************/ 121 /***************************************************************************************/
122 122
479 wformat.Format.nAvgBytesPerSec = wformat.Format.nSamplesPerSec * wformat.Format.nBlockAlign; 479 wformat.Format.nAvgBytesPerSec = wformat.Format.nSamplesPerSec * wformat.Format.nBlockAlign;
480 480
481 dsbdesc.dwBufferBytes = ao_data.buffersize; 481 dsbdesc.dwBufferBytes = ao_data.buffersize;
482 dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&wformat; 482 dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&wformat;
483 buffer_size = dsbdesc.dwBufferBytes; 483 buffer_size = dsbdesc.dwBufferBytes;
484 write_offset = 0;
484 ao_data.outburst = wformat.Format.nBlockAlign * 512; 485 ao_data.outburst = wformat.Format.nBlockAlign * 512;
485 486
486 // create primary buffer and set its format 487 // create primary buffer and set its format
487 488
488 res = IDirectSound_CreateSoundBuffer( hds, &dsbpridesc, &hdspribuf, NULL ); 489 res = IDirectSound_CreateSoundBuffer( hds, &dsbpridesc, &hdspribuf, NULL );
544 IDirectSoundBuffer_Play(hdsbuf, 0, 0, DSBPLAY_LOOPING); 545 IDirectSoundBuffer_Play(hdsbuf, 0, 0, DSBPLAY_LOOPING);
545 } 546 }
546 547
547 /** 548 /**
548 \brief close audio device 549 \brief close audio device
549 \param immed stop playback immediately, currently not supported 550 \param immed stop playback immediately
550 */ 551 */
551 static void uninit(int immed) 552 static void uninit(int immed)
552 { 553 {
553 reset(); 554 if(immed)reset();
555 else{
556 DWORD status;
557 IDirectSoundBuffer_Play(hdsbuf, 0, 0, 0);
558 while(!IDirectSoundBuffer_GetStatus(hdsbuf,&status) && (status&DSBSTATUS_PLAYING))
559 usec_sleep(20000);
560 }
554 DestroyBuffer(); 561 DestroyBuffer();
555 UninitDirectSound(); 562 UninitDirectSound();
556 } 563 }
557 564
558 /** 565 /**