OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 #include <mmsystem.h> | 6 #include <mmsystem.h> |
7 #pragma comment(lib, "winmm.lib") | 7 #pragma comment(lib, "winmm.lib") |
8 | 8 |
9 #include "media/audio/win/waveout_output_win.h" | 9 #include "media/audio/win/waveout_output_win.h" |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 bool PCMWaveOutAudioOutputStream::Open(size_t buffer_size) { | 71 bool PCMWaveOutAudioOutputStream::Open(size_t buffer_size) { |
72 if (state_ != PCMA_BRAND_NEW) | 72 if (state_ != PCMA_BRAND_NEW) |
73 return false; | 73 return false; |
74 // Open the device. We'll be getting callback in WaveCallback function. They | 74 // Open the device. We'll be getting callback in WaveCallback function. They |
75 // occur in a magic, time-critical thread that windows creates. | 75 // occur in a magic, time-critical thread that windows creates. |
76 MMRESULT result = ::waveOutOpen(&waveout_, device_id_, &format_, | 76 MMRESULT result = ::waveOutOpen(&waveout_, device_id_, &format_, |
77 reinterpret_cast<DWORD_PTR>(WaveCallback), | 77 reinterpret_cast<DWORD_PTR>(WaveCallback), |
78 reinterpret_cast<DWORD_PTR>(this), | 78 reinterpret_cast<DWORD_PTR>(this), |
79 CALLBACK_FUNCTION); | 79 CALLBACK_FUNCTION); |
80 if (result != MMSYSERR_NOERROR) | 80 if (result != MMSYSERR_NOERROR) { |
| 81 fprintf(stderr, "waveOutOpen error %d\n", result); |
81 return false; | 82 return false; |
82 | 83 } |
83 // If we don't have a packet size we use 100ms. | 84 // If we don't have a packet size we use 100ms. |
84 if (!buffer_size) | 85 if (!buffer_size) |
85 buffer_size = format_.nAvgBytesPerSec / 10; | 86 buffer_size = format_.nAvgBytesPerSec / 10; |
86 | 87 |
87 SetupBuffers(buffer_size); | 88 SetupBuffers(buffer_size); |
88 buffer_size_ = buffer_size; | 89 buffer_size_ = buffer_size; |
89 state_ = PCMA_READY; | 90 state_ = PCMA_READY; |
90 return true; | 91 return true; |
91 } | 92 } |
92 | 93 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } | 247 } |
247 obj->QueueNextPacket(buffer); | 248 obj->QueueNextPacket(buffer); |
248 } else if (msg == WOM_CLOSE) { | 249 } else if (msg == WOM_CLOSE) { |
249 // We can be closed before calling Start, so it is possible to have a | 250 // We can be closed before calling Start, so it is possible to have a |
250 // null callback at this point. | 251 // null callback at this point. |
251 if (obj->callback_) | 252 if (obj->callback_) |
252 obj->callback_->OnClose(obj); | 253 obj->callback_->OnClose(obj); |
253 } | 254 } |
254 } | 255 } |
255 | 256 |
OLD | NEW |