Mercurial > mplayer.hg
diff libao2/ao_dsound.c @ 29263:0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
author | diego |
---|---|
date | Wed, 13 May 2009 02:58:57 +0000 |
parents | 9a5b8c2ed6de |
children | 2eff450157cd |
line wrap: on
line diff
--- a/libao2/ao_dsound.c Tue May 12 19:25:35 2009 +0000 +++ b/libao2/ao_dsound.c Wed May 13 02:58:57 2009 +0000 @@ -113,17 +113,17 @@ }; static HINSTANCE hdsound_dll = NULL; ///handle to the dll -static LPDIRECTSOUND hds = NULL; ///direct sound object +static LPDIRECTSOUND hds = NULL; ///direct sound object static LPDIRECTSOUNDBUFFER hdspribuf = NULL; ///primary direct sound buffer static LPDIRECTSOUNDBUFFER hdsbuf = NULL; ///secondary direct sound buffer (stream buffer) -static int buffer_size = 0; ///size in bytes of the direct sound buffer +static int buffer_size = 0; ///size in bytes of the direct sound buffer static int write_offset = 0; ///offset of the write cursor in the direct sound buffer static int min_free_space = 0; ///if the free space is below this value get_space() will return 0 ///there will always be at least this amout of free space to prevent ///get_space() from returning wrong values when buffer is 100% full. ///will be replaced with nBlockAlign in init() static int device_num = 0; ///wanted device number -static GUID device; ///guid of the device +static GUID device; ///guid of the device /***************************************************************************************/ @@ -221,17 +221,17 @@ // initialize directsound HRESULT (WINAPI *OurDirectSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN); - HRESULT (WINAPI *OurDirectSoundEnumerate)(LPDSENUMCALLBACKA, LPVOID); + HRESULT (WINAPI *OurDirectSoundEnumerate)(LPDSENUMCALLBACKA, LPVOID); int device_index=0; opt_t subopts[] = { {"device", OPT_ARG_INT, &device_num,NULL}, {NULL} - }; + }; if (subopt_parse(ao_subdevice, subopts) != 0) { print_help(); return 0; } - + hdsound_dll = LoadLibrary("DSOUND.DLL"); if (hdsound_dll == NULL) { mp_msg(MSGT_AO, MSGL_ERR, "ao_dsound: cannot load DSOUND.DLL\n"); @@ -245,7 +245,7 @@ FreeLibrary(hdsound_dll); return 0; } - + // Enumerate all directsound devices mp_msg(MSGT_AO, MSGL_V,"ao_dsound: Output Devices:\n"); OurDirectSoundEnumerate(DirectSoundEnum,&device_index); @@ -310,22 +310,22 @@ static int write_buffer(unsigned char *data, int len) { HRESULT res; - LPVOID lpvPtr1; - DWORD dwBytes1; - LPVOID lpvPtr2; - DWORD dwBytes2; - + LPVOID lpvPtr1; + DWORD dwBytes1; + LPVOID lpvPtr2; + DWORD dwBytes2; + // Lock the buffer - res = IDirectSoundBuffer_Lock(hdsbuf,write_offset, len, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); - // If the buffer was lost, restore and retry lock. - if (DSERR_BUFFERLOST == res) - { + res = IDirectSoundBuffer_Lock(hdsbuf,write_offset, len, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); + // If the buffer was lost, restore and retry lock. + if (DSERR_BUFFERLOST == res) + { IDirectSoundBuffer_Restore(hdsbuf); res = IDirectSoundBuffer_Lock(hdsbuf,write_offset, len, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); } - - - if (SUCCEEDED(res)) + + + if (SUCCEEDED(res)) { if( (ao_data.channels == 6) && (ao_data.format!=AF_FORMAT_AC3) ) { // reorder channels while writing to pointers. @@ -354,27 +354,27 @@ write_offset+=dwBytes1+dwBytes2; if(write_offset>=buffer_size)write_offset=dwBytes2; } else { - // Write to pointers without reordering. + // Write to pointers without reordering. fast_memcpy(lpvPtr1,data,dwBytes1); if (NULL != lpvPtr2 )fast_memcpy(lpvPtr2,data+dwBytes1,dwBytes2); write_offset+=dwBytes1+dwBytes2; if(write_offset>=buffer_size)write_offset=dwBytes2; } - - // Release the data back to DirectSound. + + // Release the data back to DirectSound. res = IDirectSoundBuffer_Unlock(hdsbuf,lpvPtr1,dwBytes1,lpvPtr2,dwBytes2); - if (SUCCEEDED(res)) - { - // Success. + if (SUCCEEDED(res)) + { + // Success. DWORD status; IDirectSoundBuffer_GetStatus(hdsbuf, &status); if (!(status & DSBSTATUS_PLAYING)){ res = IDirectSoundBuffer_Play(hdsbuf, 0, 0, DSBPLAY_LOOPING); } - return dwBytes1+dwBytes2; - } - } - // Lock, Unlock, or Restore failed. + return dwBytes1+dwBytes2; + } + } + // Lock, Unlock, or Restore failed. return 0; } @@ -408,7 +408,7 @@ return -1; } -/** +/** \brief setup sound device \param rate samplerate \param channels number of channels @@ -436,7 +436,7 @@ default: mp_msg(MSGT_AO, MSGL_V,"ao_dsound: format %s not supported defaulting to Signed 16-bit Little-Endian\n",af_fmt2str_short(format)); format=AF_FORMAT_S16_LE; - } + } //fill global ao_data ao_data.channels = channels; ao_data.samplerate = rate; @@ -493,7 +493,7 @@ ao_data.outburst = wformat.Format.nBlockAlign * 512; // create primary buffer and set its format - + res = IDirectSound_CreateSoundBuffer( hds, &dsbpridesc, &hdspribuf, NULL ); if ( res != DS_OK ) { UninitDirectSound(); @@ -553,7 +553,7 @@ IDirectSoundBuffer_Play(hdsbuf, 0, 0, DSBPLAY_LOOPING); } -/** +/** \brief close audio device \param immed stop playback immediately */ @@ -579,7 +579,7 @@ int space; DWORD play_offset; IDirectSoundBuffer_GetCurrentPosition(hdsbuf,&play_offset,NULL); - space=buffer_size-(write_offset-play_offset); + space=buffer_size-(write_offset-play_offset); // | | <-- const --> | | | // buffer start play_cursor write_cursor write_offset buffer end // play_cursor is the actual postion of the play cursor @@ -601,10 +601,10 @@ { DWORD play_offset; int space; - + // make sure we have enough space to write data IDirectSoundBuffer_GetCurrentPosition(hdsbuf,&play_offset,NULL); - space=buffer_size-(write_offset-play_offset); + space=buffer_size-(write_offset-play_offset); if(space > buffer_size)space -= buffer_size; // write_offset < play_offset if(space < len) len = space; @@ -622,7 +622,7 @@ DWORD play_offset; int space; IDirectSoundBuffer_GetCurrentPosition(hdsbuf,&play_offset,NULL); - space=play_offset-write_offset; + space=play_offset-write_offset; if(space <= 0)space += buffer_size; return (float)(buffer_size - space) / (float)ao_data.bps; }